inc/Module/Install/Metadata.pm

filter: Statementstmt 42.4% 79 / 186 Branchbran 24.4% 23 / 94 Conditioncond 19.3% 6 / 31 MC/DCmcdc 5.5% 1 / 18 Subroutinesub 43.2% 16 / 37 Podpod 0.0% 0 / 30 totaltotal 31.5% 125 / 396 CC 61 SCAR 26.7
CC
61
Cov
35%
feature
42.0
read
30.0
all_from
27.3
CRAP 14.4
« lib/Egg/Manager.pm ↑ Summary lib/Egg/Plugin/Filter.pm »
1 #line 1
2 package Module::Install::Metadata;
3 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use Module::Install::Base;
6 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use vars qw{$VERSION $ISCORE @ISA};
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 BEGIN {
9 1 $VERSION = '0.71';
10 1 $ISCORE = 1;
11 @ISA = qw{Module::Install::Base};
12 }
13 1  
14 my @scalar_keys = qw{
15 name
16 module_name
17 abstract
18 author
19 version
20 license
21 distribution_type
22 perl_version
23 tests
24 installdirs
25 };
26 1  
27 my @tuple_keys = qw{
28 configure_requires
29 build_requires
30 requires
31 recommends
32 bundles
33 };
34 6 ▶ 
Subroutine Meta: called CC=1 SCAR=0.0
Pod undocumented
35 1 ▶sub Meta { shift }
Subroutine Meta_ScalarKeys: called CC=1 SCAR=0.0
Pod undocumented
36 0 ▶sub Meta_ScalarKeys { @scalar_keys }
Subroutine Meta_TupleKeys: not called CC=1 SCAR=6.9
Pod undocumented
37 sub Meta_TupleKeys { @tuple_keys }
38 1  
39 17 ▶foreach my $key (@scalar_keys) {
Subroutine __ANON__: called CC=3 SCAR=11.0
40 17 *$key = sub {
41 17 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray and not @_ 8 9 17
Condition66%2/3
defined wantarray and not @_
!ll&&!rl&&r
908
MC/DC50%1/2
defined wantarray and not @_
defined wantarray not @_
Truth table66%2/3
A and not(B)
A= defined wantarrayB= not @_
ABresult
0X0
100
111
42 9 return $self->{values}{$key} if defined wantarray and !@_;
43 9 $self->{values}{$key} = shift;
44 10 return $self;
45 };
46 }
47 1 ▶ 
Subroutine requires: called CC=4 SCAR=14.0
Pod undocumented
48 1 sub requires {
49 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
50 1 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 1 0 1
51 1 ▶ my $module = shift or last;
Condition50%1/2
shift() || 0
l!l
10
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
52 1 my $version = shift || 0;
53 push @{ $self->{values}->{requires} }, [ $module, $version ];
54 1 }
55 $self->{values}{requires};
56 }
57 7 ▶ 
Subroutine build_requires: called CC=4 SCAR=14.0
Pod undocumented
58 7 sub build_requires {
59 7 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 7 9
60 2 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 2 0 2
61 2 ▶ my $module = shift or last;
Condition50%1/2
shift() || 0
l!l
02
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
62 2 my $version = shift || 0;
63 push @{ $self->{values}->{build_requires} }, [ $module, $version ];
64 7 }
65 $self->{values}{build_requires};
66 }
67 0 ▶ 
Subroutine configure_requires: not called CC=4 SCAR=30.0
Pod undocumented
68 0 sub configure_requires {
69 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
70 0 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 0 0 0
71 0 ▶ my $module = shift or last;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
72 0 my $version = shift || 0;
73 push @{ $self->{values}->{configure_requires} }, [ $module, $version ];
74 0 }
75 $self->{values}{configure_requires};
76 }
77 0 ▶ 
Subroutine recommends: not called CC=4 SCAR=30.0
Pod undocumented
78 0 sub recommends {
79 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
80 0 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 0 0 0
81 0 ▶ my $module = shift or last;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
82 0 my $version = shift || 0;
83 push @{ $self->{values}->{recommends} }, [ $module, $version ];
84 0 }
85 $self->{values}{recommends};
86 }
87 0 ▶ 
Subroutine bundles: not called CC=4 SCAR=30.0
Pod undocumented
88 0 sub bundles {
89 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
90 0 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 0 0 0
91 0 ▶ my $module = shift or last;
Condition0%0/2
shift() || 0
l!l
00
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
Aresult
11
00
92 0 my $version = shift || 0;
93 push @{ $self->{values}->{bundles} }, [ $module, $version ];
94 0 }
95 $self->{values}{bundles};
96 }
97  
98 # Aliases for build_requires that will have alternative
99 0 ▶# meanings in some future version of META.yml.
Subroutine test_requires: not called CC=1 SCAR=6.9
Pod undocumented
100 0 ▶sub test_requires { shift->build_requires(@_) }
Subroutine install_requires: not called CC=1 SCAR=6.9
Pod undocumented
101 sub install_requires { shift->build_requires(@_) }
102  
103 0 ▶# Aliases for installdirs options
Subroutine install_as_core: not called CC=1 SCAR=6.9
Pod undocumented
104 0 ▶sub install_as_core { $_[0]->installdirs('perl') }
Subroutine install_as_cpan: not called CC=1 SCAR=6.9
Pod undocumented
105 0 ▶sub install_as_cpan { $_[0]->installdirs('site') }
Subroutine install_as_site: not called CC=1 SCAR=6.9
Pod undocumented
106 0 ▶sub install_as_site { $_[0]->installdirs('site') }
Subroutine install_as_vendor: not called CC=1 SCAR=6.9
Pod undocumented
107 sub install_as_vendor { $_[0]->installdirs('vendor') }
108 0 ▶ 
Subroutine sign: not called CC=4 SCAR=30.0
Pod undocumented
109 0 sub sign {
110 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray and not @_ 0 0 0
Condition0%0/3
defined wantarray and not @_
!ll&&!rl&&r
000
MC/DC0%0/2
defined wantarray and not @_
defined wantarray not @_
Truth table0%0/3
A and not(B)
A= defined wantarrayB= not @_
ABresult
0X0
100
111
111 0 ▶ return $self->{'values'}{'sign'} if defined wantarray and ! @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
112 0 $self->{'values'}{'sign'} = ( @_ ? $_[0] : 1 );
113 return $self;
114 }
115 0 ▶ 
Subroutine dynamic_config: not called CC=3 SCAR=24.8
Pod undocumented
116 0 sub dynamic_config {
117 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 0 0
118 0 unless ( @_ ) {
119 0 warn "You MUST provide an explicit true/false value to dynamic_config, skipping\n";
120 return $self;
121 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
$_[0] ? : 0 0 0
122 0 $self->{values}{dynamic_config} = $_[0] ? 1 : 0;
123 return $self;
124 }
125 1 ▶ 
Subroutine all_from: called CC=12 SCAR=33.1
Pod undocumented
126 1 sub all_from {
127 my ( $self, $file ) = @_;
128 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 1 1
129 0 ▶ unless ( defined($file) ) {
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->name or die "all_from called with no args without setting name() first" 0 0 0
130 my $name = $self->name
131 0 or die "all_from called with no args without setting name() first";
132 0 ▶ $file = join('/', 'lib', split(/-/, $name)) . '.pm';
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 0 0
133 0 ▶ $file =~ s{.*/}{} unless -e $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 0 0
134 die "all_from: cannot find $file from $name" unless -e $file;
135 }
136  
137 # Some methods pull from POD instead of code.
138 1 # If there is a matching .pod, use that instead
139 1 my $pod = $file;
140 1 ▶ $pod =~ s/\.pm$/.pod/i;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $pod 1 0 1
141 $pod = $file unless -e $pod;
142  
143 1 ▶ # Pull the different values
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 1 1
144 1 ▶ $self->name_from($file) unless $self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->version 1 0 1
145 1 ▶ $self->version_from($file) unless $self->version;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->perl_version 1 0 1
146 1 ▶ $self->perl_version_from($file) unless $self->perl_version;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->author 1 0 1
147 1 ▶ $self->author_from($pod) unless $self->author;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->license 1 0 1
148 1 ▶ $self->license_from($pod) unless $self->license;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->abstract 1 0 1
149 $self->abstract_from($pod) unless $self->abstract;
150 1  
151 return 1;
152 }
153 0 ▶ 
Subroutine provides: not called CC=3 SCAR=24.8
Pod undocumented
154 0 sub provides {
155 0 ▶ my $self = shift;
Condition0%0/2
$self->{"values"}{"provides"} ||= {}
l!l
00
MC/DC0%0/1
$self->{"values"}{"provides"} ||= {}
$self->{"values"}{"provides"}
Truth table0%0/2
A
A= $self->{"values"}{"provides"}
Aresult
11
00
156 0 ▶ my $provides = ( $self->{values}{provides} ||= {} );
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
157 0 %$provides = (%$provides, @_) if @_;
158 return $provides;
159 }
160 0 ▶ 
Subroutine auto_provides: not called CC=4 SCAR=30.0
Pod undocumented
161 0 sub auto_provides {
162 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_admin 0 0 0
163 0 ▶ return $self unless $self->is_admin;
Branch: 1 branch
BranchTrueFalseTotal
unless (-e "MANIFEST") 0 0 0
164 0 unless (-e 'MANIFEST') {
165 0 warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
166 return $self;
167 }
168 0 ▶ # Avoid spurious warnings as we are not checking manifest here.
Subroutine __ANON__: not called CC=1 SCAR=6.9
169 0 local $SIG{__WARN__} = sub {1};
170 0 ▶ require ExtUtils::Manifest;
Subroutine __ANON__: not called CC=1 SCAR=6.9
171 local *ExtUtils::Manifest::manicheck = sub { return };
172 0  
173 0 require Module::Build;
174 my $build = Module::Build->new(
175 dist_name => $self->name,
176 dist_version => $self->version,
177 license => $self->license,
178 0 ▶ );
Condition0%0/2
$build->find_dist_packages || {}
l!l
00
MC/DC0%0/1
$build->find_dist_packages || {}
$build->find_dist_packages
Truth table0%0/2
A
A= $build->find_dist_packages
Aresult
11
00
179 $self->provides( %{ $build->find_dist_packages || {} } );
180 }
181 0 ▶ 
Subroutine feature: not called CC=6 SCAR=37.4
Pod undocumented
182 0 sub feature {
183 0 my $self = shift;
184 0 ▶ my $name = shift;
Condition0%0/2
$self->{"values"}{"features"} ||= []
l!l
00
MC/DC0%0/1
$self->{"values"}{"features"} ||= []
$self->{"values"}{"features"}
Truth table0%0/2
A
A= $self->{"values"}{"features"}
Aresult
11
00
185 0 my $features = ( $self->{values}{features} ||= [] );
186 my $mods;
187 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and ref $_[0]) { } 0 0 0
Condition0%0/3
@_ == 1 and ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/2
@_ == 1 and ref $_[0]
@_ == 1 ref $_[0]
Truth table0%0/3
A and B
A= @_ == 1B= ref $_[0]
ABresult
0X0
100
111
188 if ( @_ == 1 and ref( $_[0] ) ) {
189 # The user used ->feature like ->features by passing in the second
190 0 # argument as a reference. Accomodate for that.
191 $mods = $_[0];
192 0 } else {
193 $mods = \@_;
194 }
195 0  
196 my $count = 0;
197 push @$features, (
198 $name => [
199 0 ▶ map {
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
ref $_ eq 'HASH' ? : 0 0 0
200 ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_
201 } @$mods
202 ]
203 );
204 0  
205 return @$features;
206 }
207 0 ▶ 
Subroutine features: not called CC=3 SCAR=24.8
Pod undocumented
208 0 sub features {
209 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 0 0 0
210 0 while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
211 $self->feature( $name, @$mods );
212 }
213 0 ▶ return $self->{values}->{features}
Branch: 1 branch
BranchTrueFalseTotal
$self->{'values'}{'features'} ? : 0 0 0
214 ? @{ $self->{values}->{features} }
215 : ();
216 }
217 0 ▶ 
Subroutine no_index: not called CC=2 SCAR=17.9
Pod undocumented
218 0 sub no_index {
219 0 my $self = shift;
220 0 ▶ my $type = shift;
Branch: 1 branch
BranchTrueFalseTotal
if $type 0 0 0
221 0 push @{ $self->{values}{no_index}{$type} }, @_ if $type;
222 return $self->{values}{no_index};
223 }
224 0 ▶ 
Subroutine read: not called CC=5 SCAR=34.0
Pod undocumented
225 0 sub read {
226 0 my $self = shift;
227 $self->include_deps( 'YAML::Tiny', 0 );
228 0  
229 0 require YAML::Tiny;
230 my $data = YAML::Tiny::LoadFile('META.yml');
231  
232 0 ▶ # Call methods explicitly in case user has already set some values.
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 0 0 0
233 0 ▶ while ( my ( $key, $value ) = each %$data ) {
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($key) 0 0 0
234 0 ▶ next unless $self->can($key);
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'HASH') { } 0 0 0
235 0 ▶ if ( ref $value eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$value) 0 0 0
236 0 while ( my ( $module, $version ) = each %$value ) {
237 $self->can($key)->($self, $module => $version );
238 }
239 0 } else {
240 $self->can($key)->($self, $value);
241 }
242 0 }
243 return $self;
244 }
245 1 ▶ 
Subroutine write: called CC=2 SCAR=7.6
Pod undocumented
246 1 sub write {
247 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_admin 0 1 1
248 1 return $self unless $self->is_admin;
249 0 $self->admin->write_meta;
250 return $self;
251 }
252 2 ▶ 
Subroutine version_from: called CC=1 SCAR=0.0
Pod undocumented
253 2 sub version_from {
254 2 require ExtUtils::MM_Unix;
255 2 my ( $self, $file ) = @_;
256 $self->version( ExtUtils::MM_Unix->parse_version($file) );
257 }
258 2 ▶ 
Subroutine abstract_from: called CC=1 SCAR=0.0
Pod undocumented
259 2 sub abstract_from {
260 2 require ExtUtils::MM_Unix;
261 2 my ( $self, $file ) = @_;
262 $self->abstract(
263 bless(
264 { DISTNAME => $self->name },
265 'ExtUtils::MM_Unix'
266 )->parse_abstract($file)
267 );
268 }
269 0 ▶ 
Subroutine name_from: not called CC=2 SCAR=17.9
Pod undocumented
270 0 sub name_from {
271 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (Module::Install::_read($_[0]) =~ / ^ \s package \s* ([\w:]+) \s* ; /imsx) { } 0 0 0
272 if (
273 Module::Install::_read($_[0]) =~ m/
274 ^ \s
275 package \s*
276 ([\w:]+)
277 \s* ;
278 /ixms
279 0 ) {
280 0 my $name = $1;
281 0 $name =~ s{::}{-}g;
282 $self->name($name);
283 0 } else {
284 0 die "Cannot determine name from $_[0]\n";
285 return;
286 }
287 }
288 1 ▶ 
Subroutine perl_version_from: called CC=2 SCAR=8.5
Pod undocumented
289 1 sub perl_version_from {
290 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (Module::Install::_read($_[0]) =~ / ^ use \s* v? ([\d_\.]+) \s* ; /imsx) { } 0 1 1
291 if (
292 Module::Install::_read($_[0]) =~ m/
293 ^
294 use \s*
295 v?
296 ([\d_\.]+)
297 \s* ;
298 /ixms
299 0 ) {
300 0 my $perl_version = $1;
301 0 $perl_version =~ s{_}{}g;
302 $self->perl_version($perl_version);
303 1 } else {
304 1 warn "Cannot determine perl version info from $_[0]\n";
305 return;
306 }
307 }
308 1 ▶ 
Subroutine author_from: called CC=3 SCAR=11.8
Pod undocumented
309 1 sub author_from {
310 1 my $self = shift;
311 1 ▶ my $content = Module::Install::_read($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if ($content =~ / =head \d \s+ (?:authors?)\b \s* ([^\n]*) | =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* ([^\n]*) /imsx) { } 1 0 1
312 if ($content =~ m/
313 =head \d \s+ (?:authors?)\b \s*
314 ([^\n]*)
315 |
316 =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
317 .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
318 ([^\n]*)
319 1 ▶ /ixms) {
Condition33%1/3
$1 || $2
l!l&&r!l&&!r
100
MC/DC0%0/2
$1 || $2
$1 $2
Truth table33%1/3
A || B
A= $1B= $2
ABresult
1X1
011
000
320 1 my $author = $1 || $2;
321 1 $author =~ s{E<lt>}{<}g;
322 1 $author =~ s{E<gt>}{>}g;
323 $self->author($author);
324 0 } else {
325 warn "Cannot determine author info from $_[0]\n";
326 }
327 }
328 1 ▶ 
Subroutine license_from: called CC=6 SCAR=20.7
Pod undocumented
329 1 sub license_from {
330 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if (Module::Install::_read($_[0]) =~ / ( =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b .*? ) (=head\\d.*|=cut.*|) \z /imsx) 1 0 1
331 if (
332 Module::Install::_read($_[0]) =~ m/
333 (
334 =head \d \s+
335 (?:licen[cs]e|licensing|copyright|legal)\b
336 .*?
337 )
338 (=head\\d.*|=cut.*|)
339 \z
340 1 /ixms ) {
341 1 my $license_text = $1;
342 my @phrases = (
343 'under the same (?:terms|license) as perl itself' => 'perl', 1,
344 'GNU public license' => 'gpl', 1,
345 'GNU lesser public license' => 'lgpl', 1,
346 'BSD license' => 'bsd', 1,
347 'Artistic license' => 'artistic', 1,
348 'GPL' => 'gpl', 1,
349 'LGPL' => 'lgpl', 1,
350 'BSD' => 'bsd', 1,
351 'Artistic' => 'artistic', 1,
352 'MIT' => 'mit', 1,
353 'proprietary' => 'proprietary', 0,
354 1 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@phrases, 0, 3)) 1 0 1
355 1 while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
356 1 ▶ $pattern =~ s{\s+}{\\s+}g;
Branch: 1 branch
BranchTrueFalseTotal
if ($license_text =~ /\b$pattern\b/i) 1 0 1
357 1 ▶ if ( $license_text =~ /\b$pattern\b/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($osi and $license_text =~ /All rights reserved/i) 0 1 1
Condition33%1/3
$osi and $license_text =~ /All rights reserved/i
!ll&&!rl&&r
010
MC/DC0%0/2
$osi and $license_text =~ /All rights reserved/i
$osi $license_text =~ /All rights reserved/i
Truth table33%1/3
A and B
A= $osiB= $license_text =~ /All rights reserved/i
ABresult
0X0
100
111
358 0 if ( $osi and $license_text =~ /All rights reserved/i ) {
359 warn "LEGAL WARNING: 'All rights reserved' may invalidate Open Source licenses. Consider removing it.";
360 1 }
361 1 $self->license($license);
362 return 1;
363 }
364 }
365 }
366 0  
367 0 warn "Cannot determine license info from $_[0]\n";
368 return 'unknown';
369 }
370 1  
371 1;
« lib/Egg/Manager.pm ↑ Summary lib/Egg/Plugin/Filter.pm »