example/inc/Module/Install/Metadata.pm

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