dist/t9vPd3GCmf/Foo-Bar-0.01/inc/Module/Install/Metadata.pm

filter: Statementstmt 25.0% 85 / 339 Branchbran 15.2% 25 / 164 Conditioncond 20.4% 10 / 49 MC/DCmcdc 6.9% 2 / 29 Subroutinesub 25.4% 14 / 55 Podpod 0.0% 0 / 38 totaltotal 20.1% 136 / 674 CC 104 SCAR 37.7
CC
104
Cov
22%
all_from
210.0
author_from
132.0
_write_mymeta_data
110.0
CRAP 43.3
« inc/Module/Install.pm ↑ Summary inc/Module/Install/Metadata.pm »
1 #line 1
2 #line 1
3 1 ▶package Module::Install::Metadata;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
5 use strict 'vars';
6 1 ▶use Module::Install::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 use vars qw{$VERSION @ISA $ISCORE};
9 1 BEGIN {
10 1 $VERSION = '1.17';
11 @ISA = 'Module::Install::Base';
12 $ISCORE = 1;
13 1 }
14  
15 my @boolean_keys = qw{
16 sign
17 1 };
18  
19 my @scalar_keys = qw{
20 name
21 module_name
22 abstract
23 version
24 distribution_type
25 tests
26 installdirs
27 1 };
28  
29 my @tuple_keys = qw{
30 configure_requires
31 build_requires
32 requires
33 recommends
34 bundles
35 resources
36 1 };
37  
38 my @resource_keys = qw{
39 homepage
40 bugtracker
41 repository
42 1 };
43  
44 my @array_keys = qw{
45 keywords
46 author
47 1 };
48  
49 1 ▶*authors = \&author;
Subroutine Meta: called CC=1 SCAR=0.0
Pod undocumented
50 0 ▶ 
Subroutine Meta_BooleanKeys: not called CC=1 SCAR=6.9
Pod undocumented
51 0 ▶sub Meta { shift }
Subroutine Meta_ScalarKeys: not called CC=1 SCAR=6.9
Pod undocumented
52 0 ▶sub Meta_BooleanKeys { @boolean_keys }
Subroutine Meta_TupleKeys: not called CC=1 SCAR=6.9
Pod undocumented
53 0 ▶sub Meta_ScalarKeys { @scalar_keys }
Subroutine Meta_ResourceKeys: not called CC=1 SCAR=6.9
Pod undocumented
54 0 ▶sub Meta_TupleKeys { @tuple_keys }
Subroutine Meta_ArrayKeys: not called CC=1 SCAR=6.9
Pod undocumented
55 sub Meta_ResourceKeys { @resource_keys }
56 1 sub Meta_ArrayKeys { @array_keys }
57 1 ▶ 
Subroutine __ANON__: called CC=4 SCAR=19.7
58 1 foreach my $key ( @boolean_keys ) {
59 1 ▶ *$key = sub {
Branch: 1 branch
BranchTrueFalseTotal
if (defined wantarray and not @_) 1 0 1
Condition33%1/3
defined wantarray and not @_
!ll&&!rl&&r
001
MC/DC0%0/2
defined wantarray and not @_
defined wantarray not @_
Truth table33%1/3
A and not(B)
A= defined wantarrayB= not @_
ABresult
0X0
100
111
60 1 my $self = shift;
61 if ( defined wantarray and not @_ ) {
62 0 ▶ return $self->{values}->{$key};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
63 0 }
64 1 $self->{values}->{$key} = ( @_ ? $_[0] : 1 );
65 return $self;
66 };
67 1 }
68 10 ▶ 
Subroutine __ANON__: called CC=3 SCAR=11.0
69 10 foreach my $key ( @scalar_keys ) {
70 10 ▶ *$key = sub {
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray and not @_ 7 3 10
Condition66%2/3
defined wantarray and not @_
!ll&&!rl&&r
307
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
71 3 my $self = shift;
72 3 return $self->{values}->{$key} if defined wantarray and !@_;
73 7 $self->{values}->{$key} = shift;
74 return $self;
75 };
76 1 }
77 2 ▶ 
Subroutine __ANON__: called CC=4 SCAR=14.0
78 2 foreach my $key ( @array_keys ) {
79 2 ▶ *$key = sub {
Branch: 1 branch
BranchTrueFalseTotal
if defined wantarray and not @_ 1 1 2
Condition66%2/3
defined wantarray and not @_
!ll&&!rl&&r
101
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
80 1 ▶ my $self = shift;
Condition50%1/2
$self->{"values"}{$key} ||= []
l!l
01
MC/DC0%0/1
$self->{"values"}{$key} ||= []
$self->{"values"}{$key}
Truth table50%1/2
A
A= $self->{"values"}{$key}
Aresult
11
00
81 1 return $self->{values}->{$key} if defined wantarray and !@_;
82 1 $self->{values}->{$key} ||= [];
83 2 push @{$self->{values}->{$key}}, @_;
84 return $self;
85 };
86 1 }
87 0 ▶ 
Subroutine __ANON__: not called CC=5 SCAR=34.0
88 0 foreach my $key ( @resource_keys ) {
89 0 ▶ *$key = sub {
Branch: 1 branch
BranchTrueFalseTotal
unless (@_) 0 0 0
90 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"values"}{"resources"} 0 0 0
91 0 unless ( @_ ) {
92 0 return () unless $self->{values}->{resources};
93 0 return map { $_->[1] }
94 grep { $_->[0] eq $key }
95 0 ▶ @{ $self->{values}->{resources} };
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
96 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
my $uri = shift() or die "Did not provide a value to $key()" 0 0 0
97 return $self->{values}->{resources}->{$key} unless @_;
98 my $uri = shift or die(
99 0 "Did not provide a value to $key()"
100 0 );
101 3 $self->resources( $key => $uri );
102 return 1;
103 };
104 1 }
105 6 ▶ 
Subroutine __ANON__: called CC=5 SCAR=16.2
106 6 foreach my $key ( grep { $_ ne "resources" } @tuple_keys) {
107 6 ▶ *$key = sub {
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 4 2 6
108 2 my $self = shift;
109 2 ▶ return $self->{values}->{$key} unless @_;
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 2 2 4
110 2 ▶ my @added;
Branch: 1 branch
BranchTrueFalseTotal
my $module = shift() or last 2 0 2
111 2 ▶ while ( @_ ) {
Condition50%1/2
shift() || 0
l!l
20
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
112 2 my $module = shift or last;
113 my $version = shift || 0;
114 2 push @added, [ $module, $version ];
115 2 }
116 5 push @{ $self->{values}->{$key} }, @added;
117 return map {@$_} @added;
118 };
119 }
120 1  
121 # Resource handling
122 my %lc_resource = map { $_ => 1 } qw{
123 homepage
124 license
125 bugtracker
126 repository
127 1 ▶};
Subroutine resources: called CC=7 SCAR=21.3
Pod undocumented
128 1  
129 1 ▶sub resources {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 1 1 2
130 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
my $name = shift() or last 1 0 1
131 1 ▶ while ( @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
my $value = shift() or next 1 0 1
132 1 ▶ my $name = shift or last;
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq lc $name and not $lc_resource{$name}) 0 1 1
Condition33%1/3
$name eq lc $name and not $lc_resource{$name}
!ll&&!rl&&r
010
MC/DC0%0/2
$name eq lc $name and not $lc_resource{$name}
$name eq lc $name not $lc_resource{$name}
Truth table33%1/3
A and not(B)
A= $name eq lc $nameB= not $lc_resource{$name}
ABresult
0X0
100
111
133 0 my $value = shift or next;
134 if ( $name eq lc $name and ! $lc_resource{$name} ) {
135 1 ▶ die("Unsupported reserved lowercase resource '$name'");
Condition50%1/2
$self->{"values"}{"resources"} ||= []
l!l
01
MC/DC0%0/1
$self->{"values"}{"resources"} ||= []
$self->{"values"}{"resources"}
Truth table50%1/2
A
A= $self->{"values"}{"resources"}
Aresult
11
00
136 1 }
137 $self->{values}->{resources} ||= [];
138 1 push @{ $self->{values}->{resources} }, [ $name, $value ];
139 }
140 $self->{values}->{resources};
141 }
142  
143 0 ▶# Aliases for build_requires that will have alternative
Subroutine test_requires: not called CC=1 SCAR=6.9
Pod undocumented
144 0 ▶# meanings in some future version of META.yml.
Subroutine install_requires: not called CC=1 SCAR=6.9
Pod undocumented
145 sub test_requires { shift->build_requires(@_) }
146 sub install_requires { shift->build_requires(@_) }
147 0 ▶ 
Subroutine install_as_core: not called CC=1 SCAR=6.9
Pod undocumented
148 0 ▶# Aliases for installdirs options
Subroutine install_as_cpan: not called CC=1 SCAR=6.9
Pod undocumented
149 0 ▶sub install_as_core { $_[0]->installdirs('perl') }
Subroutine install_as_site: not called CC=1 SCAR=6.9
Pod undocumented
150 0 ▶sub install_as_cpan { $_[0]->installdirs('site') }
Subroutine install_as_vendor: not called CC=1 SCAR=6.9
Pod undocumented
151 sub install_as_site { $_[0]->installdirs('site') }
152 0 ▶sub install_as_vendor { $_[0]->installdirs('vendor') }
Subroutine dynamic_config: not called CC=4 SCAR=30.0
Pod undocumented
153 0  
154 0 ▶sub dynamic_config {
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
155 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"values"}{"dynamic_config"}) 0 0 0
156 my $value = @_ ? shift : 1;
157 0 if ( $self->{values}->{dynamic_config} ) {
158 # Once dynamic we never change to static, for safety
159 0 ▶ return 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
160 0 }
161 $self->{values}->{dynamic_config} = $value ? 1 : 0;
162 return 1;
163 }
164 0 ▶ 
Subroutine static_config: not called CC=1 SCAR=6.9
Pod undocumented
165 0 # Convenience command
166 sub static_config {
167 shift->dynamic_config(0);
168 2 ▶}
Subroutine perl_version: called CC=4 SCAR=24.2
Pod undocumented
169 2  
170 2 ▶sub perl_version {
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 2 0 2
171 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
my $version = shift() or die "Did not provide a value to perl_version()" 0 0 0
172 return $self->{values}->{perl_version} unless @_;
173 my $version = shift or die(
174 "Did not provide a value to perl_version()"
175 );
176 0  
177 # Normalize the version
178 $version = $self->_perl_version($version);
179 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless ($version >= "5.005") 0 0 0
180 0 # We don't support the really old versions
181 unless ( $version >= 5.005 ) {
182 die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
183 0 }
184  
185 $self->{values}->{perl_version} = $version;
186 0 ▶}
Subroutine all_from: not called CC=14 SCAR=53.5
Pod undocumented
187 0  
188 sub all_from {
189 0 ▶ my ( $self, $file ) = @_;
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 0 0 0
190 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $name = $self->name or die "all_from called with no args without setting name() first" 0 0 0
191 unless ( defined($file) ) {
192 my $name = $self->name or die(
193 0 "all_from called with no args without setting name() first"
194 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
unless -e $file 0 0 0
195 0 ▶ $file = join('/', 'lib', split(/-/, $name)) . '.pm';
Branch: 1 branch
BranchTrueFalseTotal
unless (-e $file) 0 0 0
196 0 $file =~ s{.*/}{} unless -e $file;
197 unless ( -e $file ) {
198 die("all_from cannot find $file from $name");
199 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file) 0 0 0
200 0 }
201 unless ( -f $file ) {
202 die("The path '$file' does not exist, or is not a file");
203 0 }
204  
205 $self->{values}{all_from} = $file;
206  
207 0 # Some methods pull from POD instead of code.
208 0 # If there is a matching .pod, use that instead
209 0 ▶ my $pod = $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $pod 0 0 0
210 $pod =~ s/\.pm$/.pod/i;
211 $pod = $file unless -e $pod;
212 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless $self->name 0 0 0
213 0 ▶ # Pull the different values
Branch: 1 branch
BranchTrueFalseTotal
unless $self->version 0 0 0
214 0 ▶ $self->name_from($file) unless $self->name;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->perl_version 0 0 0
215 0 ▶ $self->version_from($file) unless $self->version;
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->author or [];} 0 0 0
Condition0%0/2
$self->author || []
l!l
00
MC/DC0%0/1
$self->author || []
$self->author
Truth table0%0/2
A
A= $self->author
Aresult
11
00
216 0 ▶ $self->perl_version_from($file) unless $self->perl_version;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->license 0 0 0
217 0 ▶ $self->author_from($pod) unless @{$self->author || []};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->abstract 0 0 0
218 $self->license_from($pod) unless $self->license;
219 0 $self->abstract_from($pod) unless $self->abstract;
220  
221 return 1;
222 0 ▶}
Subroutine provides: not called CC=3 SCAR=24.8
Pod undocumented
223 0  
224 0 ▶sub provides {
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
225 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
226 0 my $provides = ( $self->{values}->{provides} ||= {} );
227 %$provides = (%$provides, @_) if @_;
228 return $provides;
229 0 ▶}
Subroutine auto_provides: not called CC=4 SCAR=30.0
Pod undocumented
230 0  
231 0 ▶sub auto_provides {
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_admin 0 0 0
232 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless (-e "MANIFEST") 0 0 0
233 0 return $self unless $self->is_admin;
234 0 unless (-e 'MANIFEST') {
235 warn "Cannot deduce auto_provides without a MANIFEST, skipping\n";
236 return $self;
237 0 ▶ }
Subroutine __ANON__: not called CC=1 SCAR=6.9
238 0 # Avoid spurious warnings as we are not checking manifest here.
239 0 ▶ local $SIG{__WARN__} = sub {1};
Subroutine __ANON__: not called CC=1 SCAR=6.9
240 require ExtUtils::Manifest;
241 0 local *ExtUtils::Manifest::manicheck = sub { return };
242 0  
243 require Module::Build;
244 my $build = Module::Build->new(
245 dist_name => $self->name,
246 dist_version => $self->version,
247 0 ▶ license => $self->license,
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
248 );
249 $self->provides( %{ $build->find_dist_packages || {} } );
250 0 ▶}
Subroutine feature: not called CC=6 SCAR=37.4
Pod undocumented
251 0  
252 0 sub feature {
253 0 ▶ my $self = 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
254 0 my $name = shift;
255 my $features = ( $self->{values}->{features} ||= [] );
256 0 ▶ my $mods;
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
257  
258 if ( @_ == 1 and ref( $_[0] ) ) {
259 0 # The user used ->feature like ->features by passing in the second
260 # argument as a reference. Accomodate for that.
261 0 $mods = $_[0];
262 } else {
263 $mods = \@_;
264 0 }
265  
266 my $count = 0;
267 push @$features, (
268 0 ▶ $name => [
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
ref $_ eq 'HASH' ? : 0 0 0
269 map {
270 ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_
271 } @$mods
272 ]
273 0 );
274  
275 return @$features;
276 0 ▶}
Subroutine features: not called CC=3 SCAR=24.8
Pod undocumented
277 0  
278 0 ▶sub features {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 0 0 0
279 0 my $self = shift;
280 while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) {
281 $self->feature( $name, @$mods );
282 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
$self->{'values'}{'features'} ? : 0 0 0
283 return $self->{values}->{features}
284 ? @{ $self->{values}->{features} }
285 : ();
286 0 ▶}
Subroutine no_index: not called CC=2 SCAR=17.9
Pod undocumented
287 0  
288 0 sub no_index {
289 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if $type 0 0 0
290 0 my $type = shift;
291 push @{ $self->{values}->{no_index}->{$type} }, @_ if $type;
292 return $self->{values}->{no_index};
293 0 ▶}
Subroutine read: not called CC=5 SCAR=34.0
Pod undocumented
294 0  
295 0 sub read {
296 my $self = shift;
297 0 $self->include_deps( 'YAML::Tiny', 0 );
298 0  
299 require YAML::Tiny;
300 my $data = YAML::Tiny::LoadFile('META.yml');
301 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$data) 0 0 0
302 0 ▶ # Call methods explicitly in case user has already set some values.
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($key) 0 0 0
303 0 ▶ while ( my ( $key, $value ) = each %$data ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq 'HASH') { } 0 0 0
304 0 ▶ next unless $self->can($key);
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$value) 0 0 0
305 0 if ( ref $value eq 'HASH' ) {
306 while ( my ( $module, $version ) = each %$value ) {
307 $self->can($key)->($self, $module => $version );
308 0 }
309 } else {
310 $self->can($key)->($self, $value);
311 0 }
312 }
313 return $self;
314 1 ▶}
Subroutine write: called CC=2 SCAR=9.2
Pod undocumented
315 1  
316 1 ▶sub write {
Branch: 1 branch
BranchTrueFalseTotal
unless $self->is_admin 1 0 1
317 0 my $self = shift;
318 0 return $self unless $self->is_admin;
319 $self->admin->write_meta;
320 return $self;
321 0 ▶}
Subroutine version_from: not called CC=1 SCAR=6.9
Pod undocumented
322 0  
323 0 sub version_from {
324 0 require ExtUtils::MM_Unix;
325 my ( $self, $file ) = @_;
326 $self->version( ExtUtils::MM_Unix->parse_version($file) );
327 0  
328 # for version integrity check
329 $self->makemaker_args( VERSION_FROM => $file );
330 0 ▶}
Subroutine abstract_from: not called CC=1 SCAR=6.9
Pod undocumented
331 0  
332 0 sub abstract_from {
333 0 require ExtUtils::MM_Unix;
334 my ( $self, $file ) = @_;
335 $self->abstract(
336 bless(
337 { DISTNAME => $self->name },
338 'ExtUtils::MM_Unix'
339 )->parse_abstract($file)
340 );
341 }
342 0 ▶ 
Subroutine name_from: not called CC=3 SCAR=24.8
Pod undocumented
343 0 # Add both distribution and module name
344 0 ▶sub name_from {
Branch: 1 branch
BranchTrueFalseTotal
if (Module::Install::_read($file) =~ / ^ \s* package \s* ([\w:]+) [\s|;]* /imsx) { } 0 0 0
345 my ($self, $file) = @_;
346 if (
347 Module::Install::_read($file) =~ m/
348 ^ \s*
349 package \s*
350 ([\w:]+)
351 [\s|;]*
352 0 /ixms
353 0 ) {
354 0 my ($name, $module_name) = ($1, $1);
355 0 ▶ $name =~ s{::}{-}g;
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->module_name) 0 0 0
356 0 $self->name($name);
357 unless ( $self->module_name ) {
358 $self->module_name($module_name);
359 0 }
360 } else {
361 die("Cannot determine name from $file\n");
362 }
363 0 ▶}
Subroutine _extract_perl_version: not called CC=2 SCAR=17.9
364 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0] =~ / ^\s* (?:use|require) \s* v? ([\d_\.]+) \s* ; /imsx) { } 0 0 0
365 sub _extract_perl_version {
366 if (
367 $_[0] =~ m/
368 ^\s*
369 (?:use|require) \s*
370 v?
371 ([\d_\.]+)
372 \s* ;
373 0 /ixms
374 0 ) {
375 0 my $perl_version = $1;
376 $perl_version =~ s{_}{}g;
377 0 return $perl_version;
378 } else {
379 return;
380 }
381 0 ▶}
Subroutine perl_version_from: not called CC=2 SCAR=17.9
Pod undocumented
382 0  
383 0 sub perl_version_from {
384 0 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
if ($perl_version) { } 0 0 0
385 0 my $perl_version=_extract_perl_version(Module::Install::_read($_[0]));
386 if ($perl_version) {
387 0 $self->perl_version($perl_version);
388 0 } else {
389 warn "Cannot determine perl version info from $_[0]\n";
390 return;
391 }
392 0 ▶}
Subroutine author_from: not called CC=11 SCAR=48.8
Pod undocumented
393 0  
394 0 sub author_from {
395 0 ▶ my $self = shift;
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) { } 0 0 0
396 my $content = Module::Install::_read($_[0]);
397 if ($content =~ m/
398 =head \d \s+ (?:authors?)\b \s*
399 ([^\n]*)
400 |
401 =head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s*
402 .*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s*
403 0 ▶ ([^\n]*)
Condition0%0/3
$1 || $2
l!l&&r!l&&!r
000
MC/DC0%0/2
$1 || $2
$1 $2
Truth table0%0/3
A || B
A= $1B= $2
ABresult
1X1
011
000
404 /ixms) {
405 my $author = $1 || $2;
406 0 ▶ 
Branch: 2 branches
BranchTrueFalseTotal
if (eval 'require Pod::Escapes; 1') { } 0 0 0
elsif (eval 'require Pod::Text; 1' and $Pod::Text::VERSION < 3) { } 0 0 0
407 # XXX: ugly but should work anyway...
408 if (eval "require Pod::Escapes; 1") {
409 # Pod::Escapes has a mapping table.
410 # It's in core of perl >= 5.9.3, and should be installed
411 0 # as one of the Pod::Simple's prereqs, which is a prereq
412 # of Pod::Text 3.x (see also below).
413 $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
414 {
415 defined $2
416 ? chr($2)
417 0 ▶ : defined $Pod::Escapes::Name2character_number{$1}
Branch: 2 branches
BranchTrueFalseTotal
defined $2 ? : 0 0 0
defined $Pod::Escapes::Name2character_number{$1} ? : 0 0 0
418 0 ? chr($Pod::Escapes::Name2character_number{$1})
419 0 : do {
420 warn "Unknown escape: E<$1>";
421 "E<$1>";
422 };
423 ▶ }gex;
Condition0%0/3
eval "require Pod::Text; 1" and $Pod::Text::VERSION < 3
!ll&&!rl&&r
000
MC/DC0%0/2
eval "require Pod::Text; 1" and $Pod::Text::VERSION < 3
eval "require Pod::Text; 1" $Pod::Text::VERSION < 3
Truth table0%0/3
A and B
A= eval "require Pod::Text; 1"B= $Pod::Text::VERSION < 3
ABresult
0X0
100
111
424 }
425 elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) {
426 # Pod::Text < 3.0 has yet another mapping table,
427 # though the table name of 2.x and 1.x are different.
428 0 ▶ # (1.x is in core of Perl < 5.6, 2.x is in core of
Branch: 1 branch
BranchTrueFalseTotal
$Pod::Text::VERSION < 2 ? : 0 0 0
429 # Perl < 5.9.3)
430 my $mapping = ($Pod::Text::VERSION < 2)
431 0 ? \%Pod::Text::HTML_Escapes
432 : \%Pod::Text::ESCAPES;
433 $author =~ s{ E<( (\d+) | ([A-Za-z]+) )> }
434 {
435 defined $2
436 ? chr($2)
437 0 ▶ : defined $mapping->{$1}
Branch: 2 branches
BranchTrueFalseTotal
defined $2 ? : 0 0 0
defined $mapping->{$1} ? : 0 0 0
438 0 ? $mapping->{$1}
439 0 : do {
440 warn "Unknown escape: E<$1>";
441 "E<$1>";
442 };
443 }gex;
444 0 }
445 0 else {
446 $author =~ s{E<lt>}{<}g;
447 0 $author =~ s{E<gt>}{>}g;
448 }
449 0 $self->author($author);
450 } else {
451 warn "Cannot determine author info from $_[0]\n";
452 }
453 }
454 1  
455 #Stolen from M::B
456 my %license_urls = (
457 perl => 'http://dev.perl.org/licenses/',
458 apache => 'http://apache.org/licenses/LICENSE-2.0',
459 apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1',
460 artistic => 'http://opensource.org/licenses/artistic-license.php',
461 artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php',
462 lgpl => 'http://opensource.org/licenses/lgpl-license.php',
463 lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php',
464 lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html',
465 bsd => 'http://opensource.org/licenses/bsd-license.php',
466 gpl => 'http://opensource.org/licenses/gpl-license.php',
467 gpl2 => 'http://opensource.org/licenses/gpl-2.0.php',
468 gpl3 => 'http://opensource.org/licenses/gpl-3.0.html',
469 mit => 'http://opensource.org/licenses/mit-license.php',
470 mozilla => 'http://opensource.org/licenses/mozilla1.1.php',
471 open_source => undef,
472 unrestricted => undef,
473 restrictive => undef,
474 unknown => undef,
475 3 ▶);
Subroutine license: called CC=5 SCAR=16.7
Pod undocumented
476 3  
477 3 ▶sub license {
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 2 1 3
478 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
my $license = shift() or die "Did not provide a value to license()" 1 0 1
479 return $self->{values}->{license} unless @_;
480 my $license = shift or die(
481 1 ▶ 'Did not provide a value to license()'
Condition33%1/3
__extract_license($license) || lc $license
l!l&&r!l&&!r
010
MC/DC0%0/2
__extract_license($license) || lc $license
__extract_license($license) lc $license
Truth table33%1/3
A || B
A= __extract_license($license)B= lc $license
ABresult
1X1
011
000
482 1 );
483 $license = __extract_license($license) || lc $license;
484 $self->{values}->{license} = $license;
485 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($license_urls{$license}) 1 0 1
486 1 # Automatically fill in license URLs
487 if ( $license_urls{$license} ) {
488 $self->resources( license => $license_urls{$license} );
489 1 }
490  
491 return 1;
492 0 ▶}
Subroutine _extract_license: not called CC=2 SCAR=17.9
493 0  
494 0 sub _extract_license {
495 0 ▶ my $pod = shift;
Condition0%0/3
__extract_license(($matched) = $pod =~ / (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /msx) || __extract_license(($matched) = $pod =~ / (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /msx)
l!l&&r!l&&!r
000
MC/DC0%0/2
__extract_license(($matched) = $pod =~ / (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /msx) || __extract_license(($matched) = $pod =~ / (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /msx)
__extract_license(($matched) = $pod =~ / (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /msx) __extract_license(($matched) = $pod =~ / (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /msx)
Truth table0%0/3
A || B
A= __extract_license(($matched) = $pod =~ / (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) (=head \d.*|=cut.*|)\z /msx)B= __extract_license(($matched) = $pod =~ / (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) (=head \d.*|=cut.*|)\z /msx)
ABresult
1X1
011
000
496 my $matched;
497 return __extract_license(
498 ($matched) = $pod =~ m/
499 (=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?)
500 (=head \d.*|=cut.*|)\z
501 /xms
502 ) || __extract_license(
503 ($matched) = $pod =~ m/
504 (=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?)
505 (=head \d.*|=cut.*|)\z
506 /xms
507 );
508 1 ▶}
Subroutine __extract_license: called CC=4 SCAR=14.3
509 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $license_text = shift() or return 1 0 1
510 1 sub __extract_license {
511 my $license_text = shift or return;
512 my @phrases = (
513 '(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1,
514 '(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1,
515 'Artistic and GPL' => 'perl', 1,
516 'GNU general public license' => 'gpl', 1,
517 'GNU public license' => 'gpl', 1,
518 'GNU lesser general public license' => 'lgpl', 1,
519 'GNU lesser public license' => 'lgpl', 1,
520 'GNU library general public license' => 'lgpl', 1,
521 'GNU library public license' => 'lgpl', 1,
522 'GNU Free Documentation license' => 'unrestricted', 1,
523 'GNU Affero General Public License' => 'open_source', 1,
524 '(?:Free)?BSD license' => 'bsd', 1,
525 'Artistic license 2\.0' => 'artistic_2', 1,
526 'Artistic license' => 'artistic', 1,
527 'Apache (?:Software )?license' => 'apache', 1,
528 'GPL' => 'gpl', 1,
529 'LGPL' => 'lgpl', 1,
530 'BSD' => 'bsd', 1,
531 'Artistic' => 'artistic', 1,
532 'MIT' => 'mit', 1,
533 'Mozilla Public License' => 'mozilla', 1,
534 'Q Public License' => 'open_source', 1,
535 'OpenSSL License' => 'unrestricted', 1,
536 'SSLeay License' => 'unrestricted', 1,
537 'zlib License' => 'open_source', 1,
538 1 ▶ 'proprietary' => 'proprietary', 0,
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@phrases, 0, 3)) 26 1 27
539 26 );
540 26 ▶ while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($license_text =~ /\b$pattern\b/i) 0 26 26
541 0 $pattern =~ s#\s+#\\s+#gs;
542 if ( $license_text =~ /\b$pattern\b/i ) {
543 return $license;
544 1 }
545 }
546 return '';
547 0 ▶}
Subroutine license_from: not called CC=2 SCAR=17.9
Pod undocumented
548 0  
549 0 ▶sub license_from {
Branch: 1 branch
BranchTrueFalseTotal
if (my $license = _extract_license(Module::Install::_read($_[0]))) { } 0 0 0
550 0 my $self = shift;
551 if (my $license=_extract_license(Module::Install::_read($_[0]))) {
552 0 $self->license($license);
553 0 } else {
554 warn "Cannot determine license info from $_[0]\n";
555 return 'unknown';
556 }
557 0 ▶}
Subroutine _extract_bugtracker: not called CC=1 SCAR=6.9
558 0  
559 sub _extract_bugtracker {
560 my @links = $_[0] =~ m#L<(
561 https?\Q://rt.cpan.org/\E[^>]+|
562 https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
563 0 https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
564 0 )>#gx;
565 0 my %links;
566 0 @links{@links}=();
567 @links=keys %links;
568 return @links;
569 0 ▶}
Subroutine bugtracker_from: not called CC=3 SCAR=24.8
Pod undocumented
570 0  
571 0 sub bugtracker_from {
572 0 my $self = shift;
573 0 ▶ my $content = Module::Install::_read($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
unless (@links) 0 0 0
574 0 my @links = _extract_bugtracker($content);
575 0 unless ( @links ) {
576 warn "Cannot determine bugtracker info from $_[0]\n";
577 0 ▶ return 0;
Branch: 1 branch
BranchTrueFalseTotal
if (@links > 1) 0 0 0
578 0 }
579 0 if ( @links > 1 ) {
580 warn "Found more than one bugtracker link in $_[0]\n";
581 return 0;
582 }
583 0  
584 0 # Set the bugtracker
585 bugtracker( $links[0] );
586 return 1;
587 0 ▶}
Subroutine requires_from: not called CC=2 SCAR=17.9
Pod undocumented
588 0  
589 0 sub requires_from {
590 0 my $self = shift;
591 0 ▶ my $content = Module::Install::_readperl($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if (@requires) 0 0 0
592 0 my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg;
593 0 while ( @requires ) {
594 0 my $module = shift @requires;
595 my $version = shift @requires;
596 $self->requires( $module => $version );
597 }
598 0 ▶}
Subroutine test_requires_from: not called CC=2 SCAR=17.9
Pod undocumented
599 0  
600 0 sub test_requires_from {
601 0 my $self = shift;
602 0 ▶ my $content = Module::Install::_readperl($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if (@requires) 0 0 0
603 0 my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
604 0 while ( @requires ) {
605 0 my $module = shift @requires;
606 my $version = shift @requires;
607 $self->test_requires( $module => $version );
608 }
609 }
610  
611 # Convert triple-part versions (eg, 5.6.1 or 5.8.9) to
612 0 ▶# numbers (eg, 5.006001 or 5.008009).
Subroutine _perl_version: not called CC=3 SCAR=24.8
613 0 # Also, convert double-part versions (eg, 5.8)
614 0 sub _perl_version {
615 0 ▶ my $v = $_[-1];
Condition0%0/2
$3 || 0
l!l
00
MC/DC0%0/1
$3 || 0
$3
Truth table0%0/2
A
A= $3
Aresult
11
00
616 0 $v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e;
617 0 $v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e;
618 0 ▶ $v =~ s/(\.\d\d\d)000$/$1/;
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v) 0 0 0
619 $v =~ s/_.+$//;
620 0 if ( ref($v) ) {
621 # Numify
622 0 $v = $v + 0;
623 }
624 return $v;
625 0 ▶}
Subroutine add_metadata: not called CC=3 SCAR=24.8
Pod undocumented
626 0  
627 0 sub add_metadata {
628 0 my $self = shift;
629 0 ▶ my %hash = @_;
Branch: 1 branch
BranchTrueFalseTotal
unless $key =~ /^x_/ 0 0 0
630 for my $key (keys %hash) {
631 0 warn "add_metadata: $key is not prefixed with 'x_'.\n" .
632 "Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/;
633 $self->{values}->{$key} = $hash{$key};
634 }
635 }
636  
637  
638 ######################################################################
639 0 ▶# MYMETA Support
Subroutine WriteMyMeta: not called CC=1 SCAR=6.9
Pod undocumented
640 0  
641 sub WriteMyMeta {
642 die "WriteMyMeta has been deprecated";
643 0 ▶}
Subroutine write_mymeta_yaml: not called CC=3 SCAR=24.8
Pod undocumented
644 0  
645 sub write_mymeta_yaml {
646 my $self = shift;
647 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require YAML::Tiny; 1 } }) 0 0 0
648 0 # We need YAML::Tiny to write the MYMETA.yml file
649 unless ( eval { require YAML::Tiny; 1; } ) {
650 return 1;
651 }
652 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $meta = $self->_write_mymeta_data or return 1 0 0 0
653 # Generate the data
654 my $meta = $self->_write_mymeta_data or return 1;
655 0  
656 0 # Save as the MYMETA.yml file
657 print "Writing MYMETA.yml\n";
658 YAML::Tiny::DumpFile('MYMETA.yml', $meta);
659 0 ▶}
Subroutine write_mymeta_json: not called CC=3 SCAR=24.8
Pod undocumented
660 0  
661 sub write_mymeta_json {
662 my $self = shift;
663 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require JSON; 1 } }) 0 0 0
664 0 # We need JSON to write the MYMETA.json file
665 unless ( eval { require JSON; 1; } ) {
666 return 1;
667 }
668 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $meta = $self->_write_mymeta_data or return 1 0 0 0
669 # Generate the data
670 my $meta = $self->_write_mymeta_data or return 1;
671 0  
672 0 # Save as the MYMETA.yml file
673 print "Writing MYMETA.json\n";
674 Module::Install::_write(
675 'MYMETA.json',
676 JSON->new->pretty(1)->canonical->encode($meta),
677 );
678 0 ▶}
Subroutine _write_mymeta_data: not called CC=10 SCAR=47.0
679 0  
680 sub _write_mymeta_data {
681 my $self = shift;
682 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless -f "META.yml" 0 0 0
683 # If there's no existing META.yml there is nothing we can do
684 return undef unless -f 'META.yml';
685 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { require Parse::CPAN::Meta; 1 } }) 0 0 0
686 0 # We need Parse::CPAN::Meta to load the file
687 unless ( eval { require Parse::CPAN::Meta; 1; } ) {
688 return undef;
689 }
690 0  
691 0 # Merge the perl version into the dependencies
692 0 ▶ my $val = $self->Meta->{values};
Branch: 1 branch
BranchTrueFalseTotal
if ($perl) 0 0 0
693 0 ▶ my $perl = delete $val->{perl_version};
Condition0%0/2
$val->{"requires"} ||= []
l!l
00
MC/DC0%0/1
$val->{"requires"} ||= []
$val->{"requires"}
Truth table0%0/2
A
A= $val->{"requires"}
Aresult
11
00
694 0 if ( $perl ) {
695 $val->{requires} ||= [];
696 my $requires = $val->{requires};
697 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if ($perl >= "5.006") 0 0 0
698 0 ▶ # Canonize to three-dot version after Perl 5.6
Condition0%0/4
$2 || 0
l!l
00
$3 || 0
l!l
00
MC/DC0%0/1
$2 || 0
$2
MC/DC0%0/1
$3 || 0
$3
Truth table0%0/2
A
A= $2
Aresult
11
00
Truth table0%0/2
A
A= $3
Aresult
11
00
699 if ( $perl >= 5.006 ) {
700 0 $perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e
701 }
702 unshift @$requires, [ perl => $perl ];
703 }
704 0  
705 0 # Load the advisory META.yml file
706 my @yaml = Parse::CPAN::Meta::LoadFile('META.yml');
707 my $meta = $yaml[0];
708 0  
709 0 # Overwrite the non-configure dependency hashes
710 0 delete $meta->{requires};
711 0 ▶ delete $meta->{build_requires};
Branch: 1 branch
BranchTrueFalseTotal
if (exists $val->{"requires"}) 0 0 0
712 0 delete $meta->{recommends};
713 if ( exists $val->{requires} ) {
714 0 ▶ $meta->{requires} = { map { @$_ } @{ $val->{requires} } };
Branch: 1 branch
BranchTrueFalseTotal
if (exists $val->{"build_requires"}) 0 0 0
715 0 }
716 if ( exists $val->{build_requires} ) {
717 $meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } };
718 0 }
719  
720 return $meta;
721 1 }
722  
723 1;
« inc/Module/Install.pm ↑ Summary inc/Module/Install/Metadata.pm »