t/inc1/inc/Module/Install/Metadata.pm

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