| 1 | 4 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package Gentoo::Overlay; | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 4 | our $VERSION = '2.001002'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # ABSTRACT: Tools for working with Gentoo Overlays | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 4 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Moo 1.006000 qw( has ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use MooX::HandlesVia; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use MooseX::Has::Sugar qw( ro coerce lazy_build lazy ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Types::Standard qw( HashRef CodeRef ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Types::Path::Tiny qw( File Dir ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use MooX::ClassAttribute qw( class_has ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Carp qw(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Gentoo::Overlay::Category; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use Gentoo::Overlay::Types qw( Gentoo__Overlay_RepositoryName Gentoo__Overlay_Category ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use Gentoo::Overlay::Exceptions qw( exception warning ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 4 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | has 'path' => ( | ||||||||||||||||||||||||||||
| 36 | ro, coerce, | ||||||||||||||||||||||||||||
| 37 | isa => Dir, | ||||||||||||||||||||||||||||
| 38 | 1 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 39 | 1 | exception( | |||||||||||||||||||||||||||
| 40 | ident => 'path parameter required', | ||||||||||||||||||||||||||||
| 41 | message => '%{package}s requires the \'path\' attribute passed during construction', | ||||||||||||||||||||||||||||
| 42 | payload => { package => __PACKAGE__ }, | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | }, | ||||||||||||||||||||||||||||
| 45 | 4 | ); | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 4 | has 'name' => ( isa => Gentoo__Overlay_RepositoryName, ro, lazy, builder => 1, ); | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 6 | ▶ | sub _build_name { | ||||||||||||||||||||||||||
|
Subroutine
_build_name: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 73 | 6 | my ($self) = shift; | |||||||||||||||||||||||||||
| 74 | 6 | my $f = $self->default_path( repo_name => ); | |||||||||||||||||||||||||||
| 75 | 6 | ▶ | if ( not $f->exists or $f->is_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $f->exists or $f->is_dir
MC/DC50%1/2
not $f->exists or $f->is_dir
not $f->exists
$f->is_dir
Truth table66%2/3
not(A) or B
A= not $f->existsB= $f->is_dir
| |||||||||||||||||||||||||||||
| 76 | 1 | exception( | |||||||||||||||||||||||||||
| 77 | ident => 'no repo_name', | ||||||||||||||||||||||||||||
| 78 | message => <<'EOF', | ||||||||||||||||||||||||||||
| 79 | No repo_name file for overlay at: %{overlay_path}s | ||||||||||||||||||||||||||||
| 80 | Expects:%{expected_path}s | ||||||||||||||||||||||||||||
| 81 | EOF | ||||||||||||||||||||||||||||
| 82 | payload => { | ||||||||||||||||||||||||||||
| 83 | overlay_path => $self->path->stringify, | ||||||||||||||||||||||||||||
| 84 | expected_path => $f->stringify, | ||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | 5 | return [ $f->lines_raw( { chomp => 1 } ) ]->[0]; | |||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 4 | has _profile_dir => ( isa => Dir, ro, lazy, builder => 1 ); | |||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 12 | ▶ | sub _build__profile_dir { | ||||||||||||||||||||||||||
|
Subroutine
_build__profile_dir: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 117 | 12 | my ($self) = shift; | |||||||||||||||||||||||||||
| 118 | 12 | my $pd = $self->default_path( profiles => ); | |||||||||||||||||||||||||||
| 119 | 12 | ▶ | if ( not $pd->exists or not $pd->is_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pd->exists and $pd->is_dir
MC/DC50%1/2
$pd->exists and $pd->is_dir
$pd->exists
$pd->is_dir
Truth table66%2/3
A and B
A= $pd->existsB= $pd->is_dir
| |||||||||||||||||||||||||||||
| 120 | 1 | exception( | |||||||||||||||||||||||||||
| 121 | ident => 'no profile directory', | ||||||||||||||||||||||||||||
| 122 | message => <<'EOF', | ||||||||||||||||||||||||||||
| 123 | No profile directory for overlay at: %{overlay_path}s | ||||||||||||||||||||||||||||
| 124 | Expects:%{expected_path}s | ||||||||||||||||||||||||||||
| 125 | EOF | ||||||||||||||||||||||||||||
| 126 | payload => { | ||||||||||||||||||||||||||||
| 127 | overlay_path => $self->path->stringify, | ||||||||||||||||||||||||||||
| 128 | expected_path => $pd->stringify, | ||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 11 | return $pd->absolute; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 4 | has _categories => ( | |||||||||||||||||||||||||||
| 199 | lazy, | ||||||||||||||||||||||||||||
| 200 | builder => 1, | ||||||||||||||||||||||||||||
| 201 | ro, | ||||||||||||||||||||||||||||
| 202 | isa => HashRef [Gentoo__Overlay_Category], | ||||||||||||||||||||||||||||
| 203 | handles_via => 'Hash', | ||||||||||||||||||||||||||||
| 204 | handles => { | ||||||||||||||||||||||||||||
| 205 | _has_category => exists =>, | ||||||||||||||||||||||||||||
| 206 | category_names => keys =>, | ||||||||||||||||||||||||||||
| 207 | categories => elements =>, | ||||||||||||||||||||||||||||
| 208 | get_category => get =>, | ||||||||||||||||||||||||||||
| 209 | }, | ||||||||||||||||||||||||||||
| 210 | ); | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 7 | ▶ | sub _build__categories { | ||||||||||||||||||||||||||
|
Subroutine
_build__categories: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 228 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||
| 229 | 7 | my $cf = $self->default_path('catfile'); | |||||||||||||||||||||||||||
| 230 | 7 | ▶ | if ( not $cf->exists or $cf->is_dir ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $cf->exists or $cf->is_dir
MC/DC50%1/2
not $cf->exists or $cf->is_dir
not $cf->exists
$cf->is_dir
Truth table66%2/3
not(A) or B
A= not $cf->existsB= $cf->is_dir
| |||||||||||||||||||||||||||||
| 231 | 2 | warning( | |||||||||||||||||||||||||||
| 232 | ident => 'no category file', | ||||||||||||||||||||||||||||
| 233 | message => <<'EOF', | ||||||||||||||||||||||||||||
| 234 | No category file for overlay %{name}s, expected: %{category_file}s. | ||||||||||||||||||||||||||||
| 235 | Falling back to scanning | ||||||||||||||||||||||||||||
| 236 | EOF | ||||||||||||||||||||||||||||
| 237 | payload => { | ||||||||||||||||||||||||||||
| 238 | name => $self->name, | ||||||||||||||||||||||||||||
| 239 | category_file => $cf->stringify, | ||||||||||||||||||||||||||||
| 240 | }, | ||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||
| 242 | 1 | goto $self->can('_build___categories_scan'); | |||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | 5 | goto $self->can('_build___categories_file'); | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | class_has _default_paths => ( | ||||||||||||||||||||||||||||
| 257 | ro, lazy, | ||||||||||||||||||||||||||||
| 258 | isa => HashRef [CodeRef], | ||||||||||||||||||||||||||||
| 259 | 3 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 260 | return { | ||||||||||||||||||||||||||||
| 261 | 12 | ▶ | 'profiles' => sub { shift->path->child('profiles') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 262 | 6 | ▶ | 'repo_name' => sub { shift->_profile_dir->child('repo_name') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 263 | 12 | ▶ | 'catfile' => sub { shift->_profile_dir->child('categories') }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 264 | 18 | ▶ | 'category' => sub { shift->path->child(shift) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 265 | 6 | ▶ | 'package' => sub { shift->default_path( 'category', shift )->child(shift) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 266 | 1 | ▶ | 'ebuild' => sub { shift->default_path( 'package', shift, shift )->child(shift) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 267 | 3 | }; | |||||||||||||||||||||||||||
| 268 | }, | ||||||||||||||||||||||||||||
| 269 | 4 | ); | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||
| 298 | 55 | ▶ | sub default_path { | ||||||||||||||||||||||||||
|
Subroutine
default_path: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 299 | 55 | my ( $self, $name, @args ) = @_; | |||||||||||||||||||||||||||
| 300 | 55 | ▶ | if ( !exists $self->_default_paths->{$name} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | 0 | exception( | |||||||||||||||||||||||||||
| 302 | ident => 'no default path', | ||||||||||||||||||||||||||||
| 303 | message => q[No default path '%{name}s'], | ||||||||||||||||||||||||||||
| 304 | payload => { path => $name }, | ||||||||||||||||||||||||||||
| 305 | ); | ||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | 55 | return $self->_default_paths->{$name}->( $self, @args ); | |||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||
| 318 | 5 | ▶ | sub _build___categories_file { | ||||||||||||||||||||||||||
|
Subroutine
_build___categories_file: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 319 | 5 | my ($self) = shift; | |||||||||||||||||||||||||||
| 320 | 5 | my %out; | |||||||||||||||||||||||||||
| 321 | 5 | for my $cat ( $self->default_path('catfile')->lines_raw( { chomp => 1 } ) ) { | |||||||||||||||||||||||||||
| 322 | 11 | my $category = Gentoo::Overlay::Category->new( | |||||||||||||||||||||||||||
| 323 | name => $cat, | ||||||||||||||||||||||||||||
| 324 | overlay => $self, | ||||||||||||||||||||||||||||
| 325 | ); | ||||||||||||||||||||||||||||
| 326 | 11 | ▶ | if ( !$category->exists ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 327 | 1 | exception( | |||||||||||||||||||||||||||
| 328 | ident => 'missing category', | ||||||||||||||||||||||||||||
| 329 | message => <<'EOF', | ||||||||||||||||||||||||||||
| 330 | category %{category_name}s is not an existing directory (%{expected_path}s) for overlay %{overlay_name}s | ||||||||||||||||||||||||||||
| 331 | EOF | ||||||||||||||||||||||||||||
| 332 | payload => { | ||||||||||||||||||||||||||||
| 333 | category_name => $category->name, | ||||||||||||||||||||||||||||
| 334 | expected_path => $category->path->stringify, | ||||||||||||||||||||||||||||
| 335 | overlay_name => $self->name, | ||||||||||||||||||||||||||||
| 336 | }, | ||||||||||||||||||||||||||||
| 337 | ); | ||||||||||||||||||||||||||||
| 338 | 0 | next; | |||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | 10 | $out{$cat} = $category; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | 4 | return \%out; | |||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 1 | ▶ | sub _build___categories_scan { | ||||||||||||||||||||||||||
|
Subroutine
_build___categories_scan: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 355 | 1 | my ($self) = shift; | |||||||||||||||||||||||||||
| 356 | 1 | my %out; | |||||||||||||||||||||||||||
| 357 | 1 | my $it = $self->path->absolute->iterator(); | |||||||||||||||||||||||||||
| 358 | 1 | ▶ | while ( my $entry = $it->() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 3 | my $cat = $entry->basename; | |||||||||||||||||||||||||||
| 360 | 3 | ▶ | next if Gentoo::Overlay::Category->is_blacklisted($cat); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 1 | my $category = Gentoo::Overlay::Category->new( | |||||||||||||||||||||||||||
| 363 | overlay => $self, | ||||||||||||||||||||||||||||
| 364 | name => $cat, | ||||||||||||||||||||||||||||
| 365 | ); | ||||||||||||||||||||||||||||
| 366 | 1 | ▶ | next unless $category->exists(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 1 | $out{$cat} = $category; | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | 1 | return \%out; | |||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 3 | ▶ | sub iterate { | ||||||||||||||||||||||||||
|
Subroutine
iterate: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||
| 435 | 3 | my ( $self, $what, $callback ) = @_; ## no critic (Variables::ProhibitUnusedVarsStricter) | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | 3 | my %method_map = ( | |||||||||||||||||||||||||||
| 438 | categories => _iterate_categories =>, | ||||||||||||||||||||||||||||
| 439 | packages => _iterate_packages =>, | ||||||||||||||||||||||||||||
| 440 | ebuilds => _iterate_ebuilds =>, | ||||||||||||||||||||||||||||
| 441 | ); | ||||||||||||||||||||||||||||
| 442 | 3 | ▶ | if ( exists $method_map{$what} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | 3 | goto $self->can( $method_map{$what} ); | |||||||||||||||||||||||||||
| 444 | } | ||||||||||||||||||||||||||||
| 445 | 0 | return exception( | |||||||||||||||||||||||||||
| 446 | ident => 'bad iteration method', | ||||||||||||||||||||||||||||
| 447 | message => 'The iteration method %{what_method}s is not a known way to iterate.', | ||||||||||||||||||||||||||||
| 448 | payload => { what_method => $what, }, | ||||||||||||||||||||||||||||
| 449 | ); | ||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | # ebuilds = { /categories/packages/ebuilds } | ||||||||||||||||||||||||||||
| 463 | 1 | ▶ | sub _iterate_ebuilds { | ||||||||||||||||||||||||||
|
Subroutine
_iterate_ebuilds: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 464 | 1 | my ( $self, undef, $callback ) = @_; | |||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 1 | ▶ | my $real_callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 467 | 1 | my (%cconfig) = %{ $_[1] }; | |||||||||||||||||||||||||||
| 468 | 1 | ▶ | my $inner_callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 469 | 1 | my %pconfig = %{ $_[1] }; | |||||||||||||||||||||||||||
| 470 | 1 | $self->$callback( { ( %cconfig, %pconfig ) } ); | |||||||||||||||||||||||||||
| 471 | 1 | }; | |||||||||||||||||||||||||||
| 472 | 1 | $cconfig{package}->_iterate_ebuilds( 'ebuilds' => $inner_callback ); | |||||||||||||||||||||||||||
| 473 | 1 | }; | |||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | 1 | $self->_iterate_packages( 'packages' => $real_callback ); | |||||||||||||||||||||||||||
| 476 | 1 | return; | |||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | # categories = { /categories } | ||||||||||||||||||||||||||||
| 491 | 3 | ▶ | sub _iterate_categories { | ||||||||||||||||||||||||||
|
Subroutine
_iterate_categories: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 492 | 3 | my ( $self, undef, $callback ) = @_; | |||||||||||||||||||||||||||
| 493 | 3 | my %categories = $self->categories(); | |||||||||||||||||||||||||||
| 494 | 3 | my $num_categories = scalar keys %categories; | |||||||||||||||||||||||||||
| 495 | 3 | my $last_category = $num_categories - 1; | |||||||||||||||||||||||||||
| 496 | 3 | my $offset = 0; | |||||||||||||||||||||||||||
| 497 | 3 | for my $cname ( sort keys %categories ) { | |||||||||||||||||||||||||||
| 498 | 6 | local $_ = $categories{$cname}; | |||||||||||||||||||||||||||
| 499 | $self->$callback( | ||||||||||||||||||||||||||||
| 500 | { | ||||||||||||||||||||||||||||
| 501 | category_name => $cname, | ||||||||||||||||||||||||||||
| 502 | 6 | category => $categories{$cname}, | |||||||||||||||||||||||||||
| 503 | num_categories => $num_categories, | ||||||||||||||||||||||||||||
| 504 | last_category => $last_category, | ||||||||||||||||||||||||||||
| 505 | category_num => $offset, | ||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||
| 507 | ); | ||||||||||||||||||||||||||||
| 508 | 6 | $offset++; | |||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||
| 510 | 3 | return; | |||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||
| 523 | # packages = { /categories/packages } | ||||||||||||||||||||||||||||
| 524 | 2 | ▶ | sub _iterate_packages { | ||||||||||||||||||||||||||
|
Subroutine
_iterate_packages: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 525 | 2 | my ( $self, undef, $callback ) = @_; | |||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||
| 527 | 4 | ▶ | my $real_callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 528 | 4 | my (%cconfig) = %{ $_[1] }; | |||||||||||||||||||||||||||
| 529 | 1 | ▶ | my $inner_callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 530 | 1 | my %pconfig = %{ $_[1] }; | |||||||||||||||||||||||||||
| 531 | 1 | $self->$callback( { ( %cconfig, %pconfig ) } ); | |||||||||||||||||||||||||||
| 532 | 4 | }; | |||||||||||||||||||||||||||
| 533 | 4 | $cconfig{category}->_iterate_packages( 'packages' => $inner_callback ); | |||||||||||||||||||||||||||
| 534 | 2 | }; | |||||||||||||||||||||||||||
| 535 | 2 | $self->_iterate_categories( 'categories' => $real_callback ); | |||||||||||||||||||||||||||
| 536 | 2 | return; | |||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||
| 538 | 4 | ▶ | no Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 539 | 4 | 1; | |||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||
| 541 | __END__ | ||||||||||||||||||||||||||||