| 1 | 3 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Gentoo::Overlay::Package; | ||||||||||
| 6 | |||||||||||
| 7 | 3 | our $VERSION = '2.001002'; | |||||||||
| 8 | |||||||||||
| 9 | # ABSTRACT: Class for Package's in Gentoo Overlays | ||||||||||
| 10 | |||||||||||
| 11 | 3 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 12 | |||||||||||
| 13 | 3 | ▶ | use Moo qw( has ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 3 | ▶ | use MooX::HandlesVia; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 3 | ▶ | use MooseX::Has::Sugar qw( ro required lazy lazy_build); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 3 | ▶ | use Types::Standard qw( HashRef Str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 3 | ▶ | use Types::Path::Tiny qw( Path ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 3 | ▶ | use MooX::ClassAttribute qw( class_has ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | ▶ | use Gentoo::Overlay::Types qw( Gentoo__Overlay_PackageName Gentoo__Overlay_Category ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 3 | ▶ | use Gentoo::Overlay::Types qw( Gentoo__Overlay_RepositoryName Gentoo__Overlay_Category Gentoo__Overlay_Ebuild ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | 3 | ▶ | use Gentoo::Overlay::Exceptions qw( exception); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | 3 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | |||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | |||||||||||
| 31 | |||||||||||
| 32 | |||||||||||
| 33 | |||||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | |||||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | |||||||||||
| 45 | |||||||||||
| 46 | |||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | |||||||||||
| 50 | |||||||||||
| 51 | |||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | |||||||||||
| 57 | |||||||||||
| 58 | |||||||||||
| 59 | |||||||||||
| 60 | |||||||||||
| 61 | |||||||||||
| 62 | |||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | |||||||||||
| 66 | |||||||||||
| 67 | |||||||||||
| 68 | 3 | has name => ( isa => Gentoo__Overlay_PackageName, required, ro, ); | |||||||||
| 69 | 3 | has category => ( isa => Gentoo__Overlay_Category, required, ro, handles => [qw( overlay )], ); | |||||||||
| 70 | has path => ( | ||||||||||
| 71 | isa => Path, | ||||||||||
| 72 | ro, | ||||||||||
| 73 | lazy, | ||||||||||
| 74 | 5 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 75 | 5 | my ($self) = shift; | |||||||||
| 76 | 5 | return $self->overlay->default_path( 'package', $self->category->name, $self->name ); | |||||||||
| 77 | }, | ||||||||||
| 78 | 3 | ); | |||||||||
| 79 | |||||||||||
| 80 | |||||||||||
| 81 | |||||||||||
| 82 | |||||||||||
| 83 | |||||||||||
| 84 | |||||||||||
| 85 | |||||||||||
| 86 | |||||||||||
| 87 | |||||||||||
| 88 | |||||||||||
| 89 | |||||||||||
| 90 | |||||||||||
| 91 | |||||||||||
| 92 | |||||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | |||||||||||
| 98 | |||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | |||||||||||
| 103 | |||||||||||
| 104 | |||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | class_has _scan_blacklist => ( | ||||||||||
| 108 | isa => HashRef [Str], | ||||||||||
| 109 | ro, | ||||||||||
| 110 | lazy, | ||||||||||
| 111 | 2 | ▶ | default => sub { | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 112 | 2 | return { map { $_ => 1 } qw( . .. metadata.xml ) }; | |||||||||
| 113 | }, | ||||||||||
| 114 | 3 | ); | |||||||||
| 115 | |||||||||||
| 116 | 5 | ▶ | sub _scan_blacklisted { | ||||||||
|
Subroutine
_scan_blacklisted: called CC=1 SCAR=0.0
| |||||||||||
| 117 | 5 | my ( $self, $what ) = @_; | |||||||||
| 118 | 5 | return exists $self->_scan_blacklist->{$what}; | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | |||||||||||
| 122 | |||||||||||
| 123 | |||||||||||
| 124 | |||||||||||
| 125 | |||||||||||
| 126 | |||||||||||
| 127 | |||||||||||
| 128 | |||||||||||
| 129 | |||||||||||
| 130 | |||||||||||
| 131 | |||||||||||
| 132 | |||||||||||
| 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 | 3 | has _ebuilds => ( | |||||||||
| 173 | isa => HashRef [Gentoo__Overlay_Ebuild], | ||||||||||
| 174 | lazy, | ||||||||||
| 175 | builder => 1, | ||||||||||
| 176 | ro, | ||||||||||
| 177 | handles_via => 'Hash', | ||||||||||
| 178 | handles => { | ||||||||||
| 179 | _has_ebuild => exists =>, | ||||||||||
| 180 | ebuild_names => keys =>, | ||||||||||
| 181 | ebuilds => elements =>, | ||||||||||
| 182 | get_ebuild => get =>, | ||||||||||
| 183 | }, | ||||||||||
| 184 | ); | ||||||||||
| 185 | |||||||||||
| 186 | |||||||||||
| 187 | |||||||||||
| 188 | |||||||||||
| 189 | |||||||||||
| 190 | |||||||||||
| 191 | |||||||||||
| 192 | |||||||||||
| 193 | |||||||||||
| 194 | 1 | ▶ | sub _build__ebuilds { | ||||||||
|
Subroutine
_build__ebuilds: called CC=6 SCAR=18.2
| |||||||||||
| 195 | 1 | my ($self) = shift; | |||||||||
| 196 | 1 | require Gentoo::Overlay::Ebuild; | |||||||||
| 197 | 1 | my $it = $self->path->iterator(); | |||||||||
| 198 | 1 | my %out; | |||||||||
| 199 | 1 | ▶ | while ( defined( my $entry = $it->() ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 200 | 1 | my $ebuild = $entry->basename; | |||||||||
| 201 | 1 | ▶ | next if Gentoo::Overlay::Ebuild->is_blacklisted($ebuild); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 202 | 1 | ▶ | next if -d $entry; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 203 | ## no critic ( RegularExpressions ) | ||||||||||
| 204 | 1 | ▶ | next if $entry !~ /\.ebuild$/; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 205 | 1 | my $e = Gentoo::Overlay::Ebuild->new( | |||||||||
| 206 | name => $ebuild, | ||||||||||
| 207 | package => $self, | ||||||||||
| 208 | ); | ||||||||||
| 209 | 1 | ▶ | next unless $e->exists; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 210 | 1 | $out{$ebuild} = $e; | |||||||||
| 211 | } | ||||||||||
| 212 | 1 | return \%out; | |||||||||
| 213 | } | ||||||||||
| 214 | |||||||||||
| 215 | |||||||||||
| 216 | |||||||||||
| 217 | |||||||||||
| 218 | |||||||||||
| 219 | |||||||||||
| 220 | |||||||||||
| 221 | |||||||||||
| 222 | |||||||||||
| 223 | |||||||||||
| 224 | ## no critic ( ProhibitBuiltinHomonyms ) | ||||||||||
| 225 | 5 | ▶ | sub exists { | ||||||||
|
Subroutine
exists: called CC=5 SCAR=16.6
Pod
documented
| |||||||||||
| 226 | 5 | my $self = shift; | |||||||||
| 227 | 5 | ▶ | return if q{.} eq $self->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 228 | 5 | ▶ | return if q{..} eq $self->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 229 | 5 | ▶ | return if not -e $self->path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 230 | 5 | ▶ | return if not -d $self->path; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 231 | 1 | return 1; | |||||||||
| 232 | } | ||||||||||
| 233 | |||||||||||
| 234 | |||||||||||
| 235 | |||||||||||
| 236 | |||||||||||
| 237 | |||||||||||
| 238 | |||||||||||
| 239 | |||||||||||
| 240 | |||||||||||
| 241 | |||||||||||
| 242 | 5 | ▶ | sub is_blacklisted { | ||||||||
|
Subroutine
is_blacklisted: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 243 | 5 | my ( $self, $name ) = @_; | |||||||||
| 244 | 5 | ▶ | if ( not defined $name ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 245 | 0 | $name = $self->name; | |||||||||
| 246 | } | ||||||||||
| 247 | 5 | return $self->_scan_blacklisted($name); | |||||||||
| 248 | } | ||||||||||
| 249 | |||||||||||
| 250 | |||||||||||
| 251 | |||||||||||
| 252 | |||||||||||
| 253 | |||||||||||
| 254 | |||||||||||
| 255 | |||||||||||
| 256 | |||||||||||
| 257 | |||||||||||
| 258 | 0 | ▶ | sub pretty_name { | ||||||||
|
Subroutine
pretty_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 259 | 0 | my $self = shift; | |||||||||
| 260 | 0 | return $self->category->name . q{/} . $self->name . q{::} . $self->overlay->name; | |||||||||
| 261 | } | ||||||||||
| 262 | |||||||||||
| 263 | |||||||||||
| 264 | |||||||||||
| 265 | |||||||||||
| 266 | |||||||||||
| 267 | |||||||||||
| 268 | |||||||||||
| 269 | |||||||||||
| 270 | |||||||||||
| 271 | |||||||||||
| 272 | |||||||||||
| 273 | |||||||||||
| 274 | |||||||||||
| 275 | |||||||||||
| 276 | |||||||||||
| 277 | |||||||||||
| 278 | |||||||||||
| 279 | |||||||||||
| 280 | |||||||||||
| 281 | |||||||||||
| 282 | |||||||||||
| 283 | |||||||||||
| 284 | |||||||||||
| 285 | |||||||||||
| 286 | |||||||||||
| 287 | |||||||||||
| 288 | |||||||||||
| 289 | 0 | ▶ | sub iterate { | ||||||||
|
Subroutine
iterate: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 290 | 0 | my ( $self, $what, $callback ) = @_; ## no critic (Variables::ProhibitUnusedVarsStricter) | |||||||||
| 291 | 0 | my %method_map = ( ebuilds => _iterate_ebuilds =>, ); | |||||||||
| 292 | 0 | ▶ | if ( exists $method_map{$what} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 293 | 0 | goto $self->can( $method_map{$what} ); | |||||||||
| 294 | } | ||||||||||
| 295 | 0 | return exception( | |||||||||
| 296 | ident => 'bad iteration method', | ||||||||||
| 297 | message => 'The iteration method %{what_method}s is not a known way to iterate.', | ||||||||||
| 298 | payload => { what_method => $what }, | ||||||||||
| 299 | ); | ||||||||||
| 300 | } | ||||||||||
| 301 | |||||||||||
| 302 | |||||||||||
| 303 | |||||||||||
| 304 | |||||||||||
| 305 | |||||||||||
| 306 | |||||||||||
| 307 | |||||||||||
| 308 | |||||||||||
| 309 | |||||||||||
| 310 | |||||||||||
| 311 | |||||||||||
| 312 | # ebuilds = {/ebuilds } | ||||||||||
| 313 | 1 | ▶ | sub _iterate_ebuilds { | ||||||||
|
Subroutine
_iterate_ebuilds: called CC=2 SCAR=6.9
| |||||||||||
| 314 | 1 | my ( $self, undef, $callback ) = @_; | |||||||||
| 315 | 1 | my %ebuilds = $self->ebuilds(); | |||||||||
| 316 | 1 | my $num_ebuilds = scalar keys %ebuilds; | |||||||||
| 317 | 1 | my $last_ebuild = $num_ebuilds - 1; | |||||||||
| 318 | 1 | my $offset = 0; | |||||||||
| 319 | 1 | for my $ename ( sort keys %ebuilds ) { | |||||||||
| 320 | 1 | local $_ = $ebuilds{$ename}; | |||||||||
| 321 | $self->$callback( | ||||||||||
| 322 | { | ||||||||||
| 323 | ebuild_name => $ename, | ||||||||||
| 324 | 1 | ebuild => $ebuilds{$ename}, | |||||||||
| 325 | num_ebuilds => $num_ebuilds, | ||||||||||
| 326 | last_ebuild => $last_ebuild, | ||||||||||
| 327 | ebuild_num => $offset, | ||||||||||
| 328 | } | ||||||||||
| 329 | ); | ||||||||||
| 330 | 1 | $offset++; | |||||||||
| 331 | } | ||||||||||
| 332 | 1 | return; | |||||||||
| 333 | |||||||||||
| 334 | } | ||||||||||
| 335 | 3 | ▶ | no Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 336 | 3 | 1; | |||||||||
| 337 | |||||||||||
| 338 | __END__ | ||||||||||