| 1 | 2 | ▶ | use 5.006; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package Gentoo::Overlay::Ebuild; | ||||||||||
| 6 | |||||||||||
| 7 | 2 | our $VERSION = '2.001000'; | |||||||||
| 8 | |||||||||||
| 9 | # ABSTRACT: A Class for Ebuilds in Gentoo Overlays | ||||||||||
| 10 | |||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||
| 12 | |||||||||||
| 13 | 2 | ▶ | use Moo qw( has ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | 2 | ▶ | use MooseX::Has::Sugar qw( required ro lazy ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 15 | 2 | ▶ | use Types::Standard qw( HashRef Str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 2 | ▶ | use Types::Path::Tiny qw( File Dir ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | 2 | ▶ | use MooX::ClassAttribute qw( class_has ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 18 | 2 | ▶ | use Gentoo::Overlay::Types qw( Gentoo__Overlay_EbuildName Gentoo__Overlay_Package ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 2 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | |||||||||||
| 22 | |||||||||||
| 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 | |||||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | |||||||||||
| 73 | |||||||||||
| 74 | |||||||||||
| 75 | |||||||||||
| 76 | |||||||||||
| 77 | 2 | has name => ( isa => Gentoo__Overlay_EbuildName, required, ro ); | |||||||||
| 78 | 2 | has package => ( | |||||||||
| 79 | isa => Gentoo__Overlay_Package, | ||||||||||
| 80 | required, ro, | ||||||||||
| 81 | handles => [qw( overlay category )], | ||||||||||
| 82 | ); | ||||||||||
| 83 | |||||||||||
| 84 | has path => ( | ||||||||||
| 85 | isa => File, | ||||||||||
| 86 | ro, | ||||||||||
| 87 | lazy, | ||||||||||
| 88 | default => sub { | ||||||||||
| 89 | 1 | ▶ | my ($self) = shift; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 90 | 1 | return $self->overlay->default_path( 'ebuild', $self->category->name, $self->package->name, $self->name ); | |||||||||
| 91 | }, | ||||||||||
| 92 | 2 | ); | |||||||||
| 93 | |||||||||||
| 94 | |||||||||||
| 95 | |||||||||||
| 96 | |||||||||||
| 97 | |||||||||||
| 98 | |||||||||||
| 99 | |||||||||||
| 100 | |||||||||||
| 101 | |||||||||||
| 102 | |||||||||||
| 103 | |||||||||||
| 104 | |||||||||||
| 105 | |||||||||||
| 106 | |||||||||||
| 107 | |||||||||||
| 108 | |||||||||||
| 109 | |||||||||||
| 110 | |||||||||||
| 111 | |||||||||||
| 112 | |||||||||||
| 113 | |||||||||||
| 114 | |||||||||||
| 115 | |||||||||||
| 116 | |||||||||||
| 117 | |||||||||||
| 118 | |||||||||||
| 119 | |||||||||||
| 120 | |||||||||||
| 121 | class_has _scan_blacklist => ( | ||||||||||
| 122 | isa => HashRef [Str], | ||||||||||
| 123 | ro, | ||||||||||
| 124 | lazy, | ||||||||||
| 125 | default => sub { | ||||||||||
| 126 | 1 | ▶ | return { map { $_ => 1 } qw( . .. ChangeLog Manifest metadata.xml ) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 127 | }, | ||||||||||
| 128 | 2 | ); | |||||||||
| 129 | |||||||||||
| 130 | sub _scan_blacklisted { | ||||||||||
| 131 | 1 | ▶ | my ( $self, $what ) = @_; | ||||||||
|
Subroutine
_scan_blacklisted: called CC=1 SCAR=0.0
| |||||||||||
| 132 | 1 | return exists $self->_scan_blacklist->{$what}; | |||||||||
| 133 | } | ||||||||||
| 134 | |||||||||||
| 135 | |||||||||||
| 136 | |||||||||||
| 137 | |||||||||||
| 138 | |||||||||||
| 139 | |||||||||||
| 140 | |||||||||||
| 141 | |||||||||||
| 142 | |||||||||||
| 143 | |||||||||||
| 144 | ## no critic ( ProhibitBuiltinHomonyms ) | ||||||||||
| 145 | sub exists { | ||||||||||
| 146 | 1 | ▶ | my $self = shift; | ||||||||
|
Subroutine
exists: called CC=5 SCAR=17.2
Pod
documented
| |||||||||||
| 147 | 1 | ▶ | return if q{.} eq $self->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 148 | 1 | ▶ | return if q{..} eq $self->name; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 149 | 1 | ▶ | return unless $self->path->exists; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 150 | 1 | ▶ | return if $self->path->is_dir; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 151 | 1 | return 1; | |||||||||
| 152 | } | ||||||||||
| 153 | |||||||||||
| 154 | |||||||||||
| 155 | |||||||||||
| 156 | |||||||||||
| 157 | |||||||||||
| 158 | |||||||||||
| 159 | |||||||||||
| 160 | |||||||||||
| 161 | |||||||||||
| 162 | sub is_blacklisted { | ||||||||||
| 163 | 1 | ▶ | my ( $self, $name ) = @_; | ||||||||
|
Subroutine
is_blacklisted: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 164 | 1 | ▶ | if ( not defined $name ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 165 | 0 | $name = $self->name; | |||||||||
| 166 | } | ||||||||||
| 167 | 1 | return $self->_scan_blacklisted($name); | |||||||||
| 168 | } | ||||||||||
| 169 | |||||||||||
| 170 | |||||||||||
| 171 | |||||||||||
| 172 | |||||||||||
| 173 | |||||||||||
| 174 | |||||||||||
| 175 | |||||||||||
| 176 | |||||||||||
| 177 | |||||||||||
| 178 | sub pretty_name { | ||||||||||
| 179 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
pretty_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 180 | 0 | my $filename = $self->name; | |||||||||
| 181 | ## no critic (RegularExpressions) | ||||||||||
| 182 | 0 | $filename =~ s/\.ebuild$//; | |||||||||
| 183 | 0 | return q{=} . $self->category->name . q{/} . $filename . q{::} . $self->overlay->name; | |||||||||
| 184 | } | ||||||||||
| 185 | |||||||||||
| 186 | 2 | ▶ | no Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 187 | 2 | 1; | |||||||||
| 188 | |||||||||||
| 189 | __END__ | ||||||||||
| 190 | |||||||||||
| 191 | =pod | ||||||||||
| 192 | |||||||||||
| 193 | =encoding UTF-8 | ||||||||||
| 194 | |||||||||||
| 195 | =head1 NAME | ||||||||||
| 196 | |||||||||||
| 197 | Gentoo::Overlay::Ebuild - A Class for Ebuilds in Gentoo Overlays | ||||||||||
| 198 | |||||||||||
| 199 | =head1 VERSION | ||||||||||
| 200 | |||||||||||
| 201 | version 2.001000 | ||||||||||
| 202 | |||||||||||
| 203 | =head1 SYNOPSIS | ||||||||||
| 204 | |||||||||||
| 205 | my $ebuild = Overlay::Ebuild->new( | ||||||||||
| 206 | name => 'Moose-2.0.0.ebuild', | ||||||||||
| 207 | package => $package_object, | ||||||||||
| 208 | ); | ||||||||||
| 209 | |||||||||||
| 210 | $ebuild->exists(); # Ebuild listed exists. | ||||||||||
| 211 | |||||||||||
| 212 | print $ebuild->pretty_name # =dev-perl/Moose-2.0.0::gentoo | ||||||||||
| 213 | |||||||||||
| 214 | print $ebuild->path # /usr/portage/dev-perl/Moose/Moose-2.0.0.ebuild | ||||||||||
| 215 | |||||||||||
| 216 | =head1 METHODS | ||||||||||
| 217 | |||||||||||
| 218 | =head2 exists | ||||||||||
| 219 | |||||||||||
| 220 | Does the Ebuild exist, and is it a file? | ||||||||||
| 221 | |||||||||||
| 222 | $ebuild->exists(); | ||||||||||
| 223 | |||||||||||
| 224 | =head2 is_blacklisted | ||||||||||
| 225 | |||||||||||
| 226 | Does the ebuild name appear on a blacklist meaning auto-scan should ignore this? | ||||||||||
| 227 | |||||||||||
| 228 | ::Ebuild->is_blacklisted('..') # true | ||||||||||
| 229 | |||||||||||
| 230 | =head2 pretty_name | ||||||||||
| 231 | |||||||||||
| 232 | A pretty form of the name | ||||||||||
| 233 | |||||||||||
| 234 | $ebuild->pretty_name # =dev-perl/Moose-2.0.0::gentoo | ||||||||||
| 235 | |||||||||||
| 236 | =head1 ATTRIBUTES | ||||||||||
| 237 | |||||||||||
| 238 | =head2 name | ||||||||||
| 239 | |||||||||||
| 240 | The Ebuilds short name | ||||||||||
| 241 | |||||||||||
| 242 | isa => Gentoo__Overlay_EbuildName, required, ro | ||||||||||
| 243 | |||||||||||
| 244 | L<< C<EbuildName>|Gentoo::Overlay::Types/Gentoo__Overlay_EbuildName >> | ||||||||||
| 245 | |||||||||||
| 246 | =head2 package | ||||||||||
| 247 | |||||||||||
| 248 | The package object this ebuild is within. | ||||||||||
| 249 | |||||||||||
| 250 | isa => Gentoo__Overlay_EbuildName, required, ro | ||||||||||
| 251 | |||||||||||
| 252 | accessors => overlay category | ||||||||||
| 253 | |||||||||||
| 254 | L<< C<Package>|Gentoo::Overlay::Types/Gentoo__Overlay_Package >> | ||||||||||
| 255 | |||||||||||
| 256 | L</overlay> | ||||||||||
| 257 | |||||||||||
| 258 | L</category> | ||||||||||
| 259 | |||||||||||
| 260 | =head2 path | ||||||||||
| 261 | |||||||||||
| 262 | The full path to the ebuild. | ||||||||||
| 263 | |||||||||||
| 264 | isa => File, lazy, ro | ||||||||||
| 265 | |||||||||||
| 266 | L<MooseX::Types::Path::Tiny/File> | ||||||||||
| 267 | |||||||||||
| 268 | =head1 ATTRIBUTE ACCESSORS | ||||||||||
| 269 | |||||||||||
| 270 | =head2 overlay | ||||||||||
| 271 | |||||||||||
| 272 | $ebuild->overlay -> Gentoo::Overlay::Package->overlay | ||||||||||
| 273 | |||||||||||
| 274 | L<Gentoo::Overlay::Package/overlay> | ||||||||||
| 275 | |||||||||||
| 276 | L</package> | ||||||||||
| 277 | |||||||||||
| 278 | =head2 category | ||||||||||
| 279 | |||||||||||
| 280 | $ebuild->category -> Gentoo::Overlay::Package->category | ||||||||||
| 281 | |||||||||||
| 282 | L<Gentoo::Overlay::Package/category> | ||||||||||
| 283 | |||||||||||
| 284 | L</package> | ||||||||||
| 285 | |||||||||||
| 286 | =head1 PRIVATE CLASS ATTRIBUTES | ||||||||||
| 287 | |||||||||||
| 288 | =head2 _scan_blacklist | ||||||||||
| 289 | |||||||||||
| 290 | Class-Wide list of blacklisted ebuild names. | ||||||||||
| 291 | |||||||||||
| 292 | isa => HashRef[ Str ], ro, lazy, | ||||||||||
| 293 | |||||||||||
| 294 | accessors => _scan_blacklisted | ||||||||||
| 295 | |||||||||||
| 296 | L</_scan_blacklisted> | ||||||||||
| 297 | |||||||||||
| 298 | L<< C<MooseX::Types::Moose>|MooseX::Types::Moose >> | ||||||||||
| 299 | |||||||||||
| 300 | =head1 PRIVATE CLASS ATTRIBUTE ACCESSORS | ||||||||||
| 301 | |||||||||||
| 302 | =head2 _scan_blacklisted | ||||||||||
| 303 | |||||||||||
| 304 | is C<$arg> blacklisted in the Class Wide Blacklist? | ||||||||||
| 305 | |||||||||||
| 306 | ::Ebuild->_scan_blacklisted( $arg ) | ||||||||||
| 307 | -> | ||||||||||
| 308 | exists ::Ebuild->_scan_blacklist->{$arg} | ||||||||||
| 309 | |||||||||||
| 310 | L</_scan_blacklist> | ||||||||||
| 311 | |||||||||||
| 312 | =head1 AUTHOR | ||||||||||
| 313 | |||||||||||
| 314 | Kent Fredric <kentnl@cpan.org> | ||||||||||
| 315 | |||||||||||
| 316 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 317 | |||||||||||
| 318 | This software is copyright (c) 2014 by Kent Fredric <kentnl@cpan.org>. | ||||||||||
| 319 | |||||||||||
| 320 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 321 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 322 | |||||||||||
| 323 | =cut | ||||||||||