t/test/inc/Module/Install.pm

filter: Statementstmt 74.1% 166 / 224 Branchbran 43.2% 45 / 104 Conditioncond 36.1% 17 / 47 MC/DCmcdc 7.1% 2 / 28 Subroutinesub 85.1% 23 / 27 Podpod 0.0% 0 / 7 totaltotal 57.8% 253 / 437 CC 71 SCAR 28.9
CC
71
Cov
61%
_write
56.0
__ANON__
53.1
new
21.0
CRAP 17.9
« t/test/inc/Module/Install/Metadata.pm ↑ Summary t/test/inc/Module/Install/WriteAll.pm »
1 #line 1
2 package Module::Install;
3  
4 # For any maintainers:
5 # The load order for Module::Install is a bit magic.
6 # It goes something like this...
7 #
8 # IF ( host has Module::Install installed, creating author mode ) {
9 # 1. Makefile.PL calls "use inc::Module::Install"
10 # 2. $INC{inc/Module/Install.pm} set to installed version of inc::Module::Install
11 # 3. The installed version of inc::Module::Install loads
12 # 4. inc::Module::Install calls "require Module::Install"
13 # 5. The ./inc/ version of Module::Install loads
14 # } ELSE {
15 # 1. Makefile.PL calls "use inc::Module::Install"
16 # 2. $INC{inc/Module/Install.pm} set to ./inc/ version of Module::Install
17 # 3. The ./inc/ version of Module::Install loads
18 # }
19 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶use 5.005;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 use strict 'vars';
22 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use vars qw{$VERSION $MAIN};
Subroutine BEGIN: called CC=1 SCAR=0.0
24 BEGIN {
25 # All Module::Install core packages now require synchronised versions.
26 # This will be used to ensure we don't accidentally load old or
27 # different versions of modules.
28 # This is not enforced yet, but will be some time in the next few
29 # releases once we can make sure it won't clash with custom
30 1 # Module::Install extensions.
31 $VERSION = '0.91';
32  
33 1 # Storage for the pseudo-singleton
34 $MAIN = undef;
35 1  
36 1 *inc::Module::Install::VERSION = *VERSION;
37 @inc::Module::Install::ISA = __PACKAGE__;
38  
39 }
40  
41  
42  
43  
44  
45 # Whether or not inc::Module::Install is actually loaded, the
46 # $INC{inc/Module/Install.pm} is what will still get set as long as
47 # the caller loaded module this in the documented manner.
48 # If not set, the caller may NOT have loaded the bundled version, and thus
49 # they may not have a MI version that works with the Makefile.PL. This would
50 1 # result in false errors or unexpected behaviour. And we don't want that.
51 0 ▶my $file = join( '/', 'inc', split /::/, __PACKAGE__ ) . '.pm';
Branch: 1 branch
BranchTrueFalseTotal
unless ($INC{$file}) 0 1 1
52 unless ( $INC{$file} ) { die <<"END_DIE" }
53 0  
54 Please invoke ${\__PACKAGE__} with:
55 0  
56 use inc::${\__PACKAGE__};
57  
58 not:
59 0  
60 use ${\__PACKAGE__};
61  
62 END_DIE
63  
64  
65  
66  
67  
68 # If the script that is loading Module::Install is from the future,
69 # then make will detect this and cause it to re-run over and over
70 # again. This is bad. Rather than taking action to touch it (which
71 # is unreliable on some platforms and requires write permissions)
72 1 ▶# for now we should catch this and refuse to run.
Branch: 1 branch
BranchTrueFalseTotal
if (-f $0) 1 0 1
73 1 if ( -f $0 ) {
74 my $s = (stat($0))[9];
75  
76 # If the modification time is only slightly in the future,
77 1 # sleep briefly to remove the problem.
78 0 ▶ my $a = $s - time;
Branch: 1 branch
BranchTrueFalseTotal
if ($a > 0 and $a < 5) 0 1 1
Condition33%1/3
$a > 0 and $a < 5
!ll&&!rl&&r
100
MC/DC0%0/2
$a > 0 and $a < 5
$a > 0 $a < 5
Truth table33%1/3
A and B
A= $a > 0B= $a < 5
ABresult
0X0
100
111
79 if ( $a > 0 and $a < 5 ) { sleep 5 }
80  
81 1 # Too far in the future, throw an error.
82 0 ▶ my $t = time;
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $t) 0 1 1
83 if ( $s > $t ) { die <<"END_DIE" }
84  
85 Your installer $0 has a modification time in the future ($s > $t).
86  
87 This is known to create infinite loops in make.
88  
89 Please correct this, then run $0 again.
90  
91 END_DIE
92 }
93  
94  
95  
96  
97  
98 # Build.PL was formerly supported, but no longer is due to excessive
99 0 ▶# difficulty in implementing every single feature twice.
Branch: 1 branch
BranchTrueFalseTotal
if ($0 =~ /Build.PL$/i) 0 1 1
100 if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" }
101  
102 Module::Install no longer supports Build.PL.
103  
104 It was impossible to maintain duel backends, and has been deprecated.
105  
106 Please remove all Build.PL files and only use the Makefile.PL installer.
107  
108 END_DIE
109  
110  
111  
112  
113  
114 # To save some more typing in Module::Install installers, every...
115 # use inc::Module::Install
116 1 # ...also acts as an implicit use strict.
117 $^H |= strict::bits(qw(refs subs vars));
118  
119  
120  
121  
122 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
123 1 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
124 1 ▶use File::Find ();
Subroutine BEGIN: called CC=1 SCAR=0.0
125 1 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
126 use FindBin;
127 35 ▶ 
Subroutine autoload: called CC=1 SCAR=0.1
Pod undocumented
128 35 sub autoload {
129 35 my $self = shift;
130 35 my $who = $self->_caller;
131 35 my $cwd = Cwd::cwd();
132 39 ▶ my $sym = "${who}::AUTOLOAD";
Subroutine __ANON__: called CC=7 SCAR=20.5
133 39 $sym->{$cwd} = sub {
134 39 ▶ my $pwd = Cwd::cwd();
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $sym->{$pwd}) 39 0 39
135 if ( my $code = $sym->{$pwd} ) {
136 39 ▶ # Delegate back to parent dirs
Branch: 1 branch
BranchTrueFalseTotal
unless $cwd eq $pwd 0 39 39
137 goto &$code unless $cwd eq $pwd;
138 39 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
$$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym" 39 0 39
139 39 $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym";
140 39 ▶ my $method = $1;
Branch: 2 branches
BranchTrueFalseTotal
if (uc $method eq $method) { } 0 39 39
elsif ($method =~ /^_/ and $self->can($method)) { } 1 76 77
141 if ( uc($method) eq $method ) {
142 0 # Do nothing
143 ▶ return;
Condition66%2/3
$method =~ /^_/ and $self->can($method)
!ll&&!rl&&r
3801
MC/DC50%1/2
$method =~ /^_/ and $self->can($method)
$method =~ /^_/ $self->can($method)
Truth table66%2/3
A and B
A= $method =~ /^_/B= $self->can($method)
ABresult
0X0
100
111
144 } elsif ( $method =~ /^_/ and $self->can($method) ) {
145 1 # Dispatch to the root M:I class
146 return $self->$method(@_);
147 }
148  
149 38 # Dispatch to the appropriate plugin
150 38 unshift @_, ( $self, $1 );
151 35 goto &{$self->can('call')};
152 };
153 }
154 1 ▶ 
Subroutine import: called CC=2 SCAR=8.1
155 1 sub import {
156 1 my $class = shift;
157 1 my $self = $class->new(@_);
158 my $who = $self->_caller;
159 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->{"file"}) 0 1 1
160 0 unless ( -f $self->{file} ) {
161 0 require "$self->{path}/$self->{dispatch}.pm";
162 0 File::Path::mkpath("$self->{prefix}/$self->{author}");
163 0 $self->{admin} = "$self->{name}::$self->{dispatch}"->new( _top => $self );
164 0 $self->{admin}->init;
165 0 @_ = ($class, _self => $self);
166 goto &{"$self->{name}::import"};
167 }
168 1  
169 1 *{"${who}::AUTOLOAD"} = $self->autoload;
170 $self->preload;
171  
172 1 # Unregister loader and worker packages so subdirs can use them again
173 1 delete $INC{"$self->{file}"};
174 delete $INC{"$self->{path}.pm"};
175  
176 1 # Save to the singleton
177 $MAIN = $self;
178 1  
179 return 1;
180 }
181 1 ▶ 
Subroutine preload: called CC=9 SCAR=22.0
Pod undocumented
182 1 sub preload {
183 1 ▶ my $self = shift;
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"extensions"}) 1 0 1
184 1 unless ( $self->{extensions} ) {
185 $self->load_extensions(
186 "$self->{prefix}/$self->{path}", $self
187 );
188 }
189 1  
190 1 ▶ my @exts = @{$self->{extensions}};
Branch: 1 branch
BranchTrueFalseTotal
unless (@exts) 0 1 1
191 0 unless ( @exts ) {
192 @exts = $self->{admin}->load_all_extensions;
193 }
194 1  
195 1 my %seen;
196 7 ▶ foreach my $obj ( @exts ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{ref($obj) . '::';}) 165 7 172
197 165 ▶ while (my ($method, $glob) = each %{ref($obj) . '::'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless $obj->can($method) 26 139 165
198 139 ▶ next unless $obj->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ /^_/ 12 127 139
199 127 ▶ next if $method =~ /^_/;
Branch: 1 branch
BranchTrueFalseTotal
if $method eq uc $method 9 118 127
200 118 next if $method eq uc($method);
201 $seen{$method}++;
202 }
203 }
204 1  
205 1 my $who = $self->_caller;
206 93 ▶ foreach my $name ( sort keys %seen ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
207 5 *{"${who}::$name"} = sub {
208 5 ${"${who}::AUTOLOAD"} = "${who}::$name";
209 93 goto &{"${who}::AUTOLOAD"};
210 };
211 }
212 }
213 1 ▶ 
Subroutine new: called CC=13 SCAR=30.4
Pod undocumented
214 1 sub new {
215 my ($class, %args) = @_;
216  
217 1 # ignore the prefix on extension modules built from top level.
218 1 ▶ my $base_path = Cwd::abs_path($FindBin::Bin);
Branch: 1 branch
BranchTrueFalseTotal
unless (Cwd::abs_path(Cwd::cwd()) eq $base_path) 0 1 1
219 0 unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
220 delete $args{prefix};
221 }
222 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $args{"_self"} 0 1 1
223 return $args{_self} if $args{_self};
224 1 ▶ 
Condition50%1/2
$args{"dispatch"} ||= "Admin"
l!l
01
MC/DC0%0/1
$args{"dispatch"} ||= "Admin"
$args{"dispatch"}
Truth table50%1/2
A
A= $args{"dispatch"}
Aresult
11
00
225 1 ▶ $args{dispatch} ||= 'Admin';
Condition50%1/2
$args{"prefix"} ||= "inc"
l!l
01
MC/DC0%0/1
$args{"prefix"} ||= "inc"
$args{"prefix"}
Truth table50%1/2
A
A= $args{"prefix"}
Aresult
11
00
226 1 ▶ $args{prefix} ||= 'inc';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'VMS' ? : 0 1 1
Condition33%1/3
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
$args{"author"} $^O eq "VMS" ? "_author" : ".author"
Truth table33%1/3
A ||= B
A= $args{"author"}B= $^O eq "VMS" ? "_author" : ".author"
ABresult
1X1
011
000
227 1 ▶ $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
Condition50%1/2
$args{"bundle"} ||= "inc/BUNDLES"
l!l
01
MC/DC0%0/1
$args{"bundle"} ||= "inc/BUNDLES"
$args{"bundle"}
Truth table50%1/2
A
A= $args{"bundle"}
Aresult
11
00
228 1 ▶ $args{bundle} ||= 'inc/BUNDLES';
Condition33%1/3
$args{"base"} ||= $base_path
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{"base"} ||= $base_path
$args{"base"} $base_path
Truth table33%1/3
A ||= B
A= $args{"base"}B= $base_path
ABresult
1X1
011
000
229 1 $args{base} ||= $base_path;
230 1 ▶ $class =~ s/^\Q$args{prefix}\E:://;
Condition33%1/3
$args{"name"} ||= $class
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{"name"} ||= $class
$args{"name"} $class
Truth table33%1/3
A ||= B
A= $args{"name"}B= $class
ABresult
1X1
011
000
231 1 ▶ $args{name} ||= $class;
Condition33%1/3
$args{"version"} ||= $class->VERSION
l!l&&r!l&&!r
010
MC/DC0%0/2
$args{"version"} ||= $class->VERSION
$args{"version"} $class->VERSION
Truth table33%1/3
A ||= B
A= $args{"version"}B= $class->VERSION
ABresult
1X1
011
000
232 1 ▶ $args{version} ||= $class->VERSION;
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"path"}) 1 0 1
233 1 unless ( $args{path} ) {
234 1 $args{path} = $args{name};
235 $args{path} =~ s!::!/!g;
236 1 ▶ }
Condition50%1/2
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
l!l
01
MC/DC0%0/1
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
$args{"file"}
Truth table50%1/2
A
A= $args{"file"}
Aresult
11
00
237 1 $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
238 $args{wrote} = 0;
239 1  
240 bless( \%args, $class );
241 }
242 38 ▶ 
Subroutine call: called CC=2 SCAR=7.0
Pod undocumented
243 38 sub call {
244 38 ▶ my ($self, $method) = @_;
Branch: 1 branch
BranchTrueFalseTotal
my $obj = $self->load($method) or return 38 0 38
245 38 my $obj = $self->load($method) or return;
246 38 splice(@_, 0, 2, $obj);
247 goto &{$obj->can($method)};
248 }
249 38 ▶ 
Subroutine load: called CC=5 SCAR=20.9
Pod undocumented
250 38 sub load {
251 my ($self, $method) = @_;
252  
253 $self->load_extensions(
254 38 ▶ "$self->{prefix}/$self->{path}", $self
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"extensions"} 0 38 38
255 ) unless $self->{extensions};
256 38  
257 165 ▶ foreach my $obj (@{$self->{extensions}}) {
Branch: 1 branch
BranchTrueFalseTotal
if $obj->can($method) 38 127 165
258 return $obj if $obj->can($method);
259 }
260 0 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
my $admin = $self->{"admin"} or die qq[The '${method}' method does not exist in the '$self->{"prefix"}' path!\nPlease remove the '$self->{"prefix"}' directory and run $0 again to load it.\n] 0 0 0
261 my $admin = $self->{admin} or die <<"END_DIE";
262 The '$method' method does not exist in the '$self->{prefix}' path!
263 Please remove the '$self->{prefix}' directory and run $0 again to load it.
264 END_DIE
265 0  
266 0 my $obj = $admin->load($method, 1);
267 push @{$self->{extensions}}, $obj;
268 0  
269 $obj;
270 }
271 1 ▶ 
Subroutine load_extensions: called CC=8 SCAR=22.8
Pod undocumented
272 1 sub load_extensions {
273 my ($self, $path, $top) = @_;
274 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {not ref $_ and lc $_ eq lc $self->{"prefix"};} @INC) 1 0 1
Condition33%1/3
!ref($_) && lc $_ eq lc $self->{'prefix'}
!ll&&!rl&&r
080
MC/DC0%0/2
!ref($_) && lc $_ eq lc $self->{'prefix'}
!ref($_) lc $_ eq lc $self->{'prefix'}
Truth table33%1/3
not(A) && B
A= !ref($_)B= lc $_ eq lc $self->{'prefix'}
ABresult
0X0
100
111
275 1 unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) {
276 unshift @INC, $self->{prefix};
277 }
278 1  
279 7 foreach my $rv ( $self->find_extensions($path) ) {
280 7 ▶ my ($file, $pkg) = @{$rv};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pathnames"}{$pkg} 0 7 7
281 next if $self->{pathnames}{$pkg};
282 7  
283 7 local $@;
284 7 ▶ my $new = eval { require $file; $pkg->can('new') };
Branch: 1 branch
BranchTrueFalseTotal
unless ($new) 0 7 7
285 0 ▶ unless ( $new ) {
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
286 0 warn $@ if $@;
287 next;
288 7 }
289 7 $self->{pathnames}{$pkg} = delete $INC{$file};
290 push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
291 }
292 1 ▶ 
Condition50%1/2
$self->{"extensions"} ||= []
l!l
10
MC/DC0%0/1
$self->{"extensions"} ||= []
$self->{"extensions"}
Truth table50%1/2
A
A= $self->{"extensions"}
Aresult
11
00
293 $self->{extensions} ||= [];
294 }
295 1 ▶ 
Subroutine find_extensions: called CC=2 SCAR=10.5
Pod undocumented
296 1 sub find_extensions {
297 my ($self, $path) = @_;
298 1  
299 8 ▶ my @found;
Subroutine __ANON__: called CC=12 SCAR=39.7
300 8 File::Find::find( sub {
301 8 ▶ my $file = $File::Find::name;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ m[^\Q$path\E/(.+)\.pm\Z]is 1 7 8
302 7 return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
303 7 ▶ my $subpath = $1;
Branch: 1 branch
BranchTrueFalseTotal
if lc $subpath eq lc $self->{"dispatch"} 0 7 7
304 return if lc($subpath) eq lc($self->{dispatch});
305 7  
306 7 $file = "$self->{path}/$subpath.pm";
307 7 my $pkg = "$self->{name}::$subpath";
308 $pkg =~ s!/!::!g;
309  
310 # If we have a mixed-case package name, assume case has been preserved
311 # correctly. Otherwise, root through the file to locate the case-preserved
312 7 ▶ # version of the package name.
Branch: 1 branch
BranchTrueFalseTotal
if ($subpath eq lc $subpath or $subpath eq uc $subpath) 0 7 7
Condition33%1/3
$subpath eq lc $subpath or $subpath eq uc $subpath
l!l&&r!l&&!r
007
MC/DC0%0/2
$subpath eq lc $subpath or $subpath eq uc $subpath
$subpath eq lc $subpath $subpath eq uc $subpath
Truth table33%1/3
A or B
A= $subpath eq lc $subpathB= $subpath eq uc $subpath
ABresult
1X1
011
000
313 0 if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
314 0 my $content = Module::Install::_read($subpath . '.pm');
315 0 my $in_pod = 0;
316 0 ▶ foreach ( split //, $content ) {
Branch: 1 branch
BranchTrueFalseTotal
if /^=\w/ 0 0 0
317 0 ▶ $in_pod = 1 if /^=\w/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=cut/ 0 0 0
318 0 ▶ $in_pod = 0 if /^=cut/;
Branch: 1 branch
BranchTrueFalseTotal
if $in_pod or /^=cut/ 0 0 0
Condition0%0/3
$in_pod or /^=cut/
l!l&&r!l&&!r
000
MC/DC0%0/2
$in_pod or /^=cut/
$in_pod /^=cut/
Truth table0%0/3
A or B
A= $in_podB= /^=cut/
ABresult
1X1
011
000
319 0 ▶ next if ($in_pod || /^=cut/); # skip pod text
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*#/ 0 0 0
320 0 ▶ next if /^\s*#/; # and comments
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*package\s+($pkg)\s*;/i) 0 0 0
321 0 if ( m/^\s*package\s+($pkg)\s*;/i ) {
322 0 $pkg = $1;
323 last;
324 }
325 }
326 }
327 7  
328 1 ▶ push @found, [ $file, $pkg ];
Branch: 1 branch
BranchTrueFalseTotal
if -d $path 1 0 1
329 }, $path ) if -d $path;
330 1  
331 @found;
332 }
333  
334  
335  
336  
337  
338 #####################################################################
339 # Common Utility Functions
340 37 ▶ 
Subroutine _caller: called CC=2 SCAR=6.9
341 37 sub _caller {
342 37 my $depth = 0;
343 37 ▶ my $call = caller($depth);
Branch: 1 branch
BranchTrueFalseTotal
if ($call eq __PACKAGE__) 39 37 76
344 39 while ( $call eq __PACKAGE__ ) {
345 39 $depth++;
346 $call = caller($depth);
347 37 }
348 return $call;
349 }
350 4 ▶ 
Subroutine _read: called CC=5 SCAR=18.1
351 4 sub _read {
352 4 ▶ local *FH;
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.006) { } 4 0 4
353 4 ▶ if ( $] >= 5.006 ) {
Branch: 1 branch
BranchTrueFalseTotal
open FH, "<", $_[0] or die "open($_[0]): $!" 4 0 4
354 open( FH, '<', $_[0] ) or die "open($_[0]): $!";
355 0 ▶ } else {
Branch: 1 branch
BranchTrueFalseTotal
open FH, "< $_[0]" or die "open($_[0]): $!" 0 0 0
356 open( FH, "< $_[0]" ) or die "open($_[0]): $!";
357 4 }
358 4 ▶ my $string = do { local $/; <FH> };
Branch: 1 branch
BranchTrueFalseTotal
close FH or die "close($_[0]): $!" 4 0 4
359 4 close FH or die "close($_[0]): $!";
360 return $string;
361 }
362 0 ▶ 
Subroutine _readperl: not called CC=1 SCAR=6.9
363 0 sub _readperl {
364 0 my $string = Module::Install::_read($_[0]);
365 0 $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
366 0 $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s;
367 0 $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg;
368 return $string;
369 }
370 0 ▶ 
Subroutine _readpod: not called CC=2 SCAR=17.9
371 0 sub _readpod {
372 0 my $string = Module::Install::_read($_[0]);
373 0 ▶ $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg;
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ /\.pod\z/ 0 0 0
374 0 return $string if $_[0] =~ /\.pod\z/;
375 0 $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg;
376 0 $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg;
377 0 $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg;
378 0 $string =~ s/^\n+//s;
379 return $string;
380 }
381 0 ▶ 
Subroutine _write: not called CC=7 SCAR=40.3
382 0 sub _write {
383 0 ▶ local *FH;
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= 5.006) { } 0 0 0
384 0 ▶ if ( $] >= 5.006 ) {
Branch: 1 branch
BranchTrueFalseTotal
open FH, ">", $_[0] or die "open($_[0]): $!" 0 0 0
385 open( FH, '>', $_[0] ) or die "open($_[0]): $!";
386 0 ▶ } else {
Branch: 1 branch
BranchTrueFalseTotal
open FH, "> $_[0]" or die "open($_[0]): $!" 0 0 0
387 open( FH, "> $_[0]" ) or die "open($_[0]): $!";
388 0 }
389 0 ▶ foreach ( 1 .. $#_ ) {
Branch: 1 branch
BranchTrueFalseTotal
print FH $_[$_] or die "print($_[0]): $!" 0 0 0
390 print FH $_[$_] or die "print($_[0]): $!";
391 0 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
close FH or die "close($_[0]): $!" 0 0 0
392 close FH or die "close($_[0]): $!";
393 }
394  
395 # _version is for processing module versions (eg, 1.03_05) not
396 2 ▶# Perl versions (eg, 5.8.1).
Subroutine _version: called CC=5 SCAR=17.0
397 2 ▶sub _version ($) {
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
398 2 my $s = shift || 0;
399 2 ▶ my $d =()= $s =~ /(\.)/g;
Branch: 1 branch
BranchTrueFalseTotal
if ($d >= 2) 0 2 2
400 if ( $d >= 2 ) {
401 0 # Normalise multipart versions
402 $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg;
403 2 }
404 2 ▶ $s =~ s/^(\d+)\.?//;
Condition100%2/2
$1 || 0
l!l
11
MC/DC100%1/1
$1 || 0
$1
Truth table100%2/2
A
A= $1
Aresult
11
00
405 my $l = $1 || 0;
406 2 my @v = map {
407 $_ . '0' x (3 - length $_)
408 2 ▶ } $s =~ /(\d{1,3})\D?/g;
Branch: 1 branch
BranchTrueFalseTotal
if @v 2 0 2
409 2 $l = $l . '.' . join '', @v if @v;
410 return $l + 0;
411 }
412 1 ▶ 
Subroutine _cmp: called CC=1 SCAR=0.0
413 1 sub _cmp ($$) {
414 _version($_[0]) <=> _version($_[1]);
415 }
416  
417 0 ▶# Cloned from Params::Util::_CLASS
Subroutine _CLASS: not called CC=4 SCAR=30.0
418 sub _CLASS ($) {
419 0 ▶ (
Branch: 1 branch
BranchTrueFalseTotal
defined $_[0] && !ref($_[0]) && $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s ? : 0 0 0
Condition0%0/6
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
!ll&&!rl&&r
000
defined $_[0] and not ref $_[0]
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[0] and not ref $_[0] and $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
defined $_[0] not ref $_[0] $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
Truth table0%0/4
A and not(B) and C
A= defined $_[0]B= not ref $_[0]C= $_[0] =~ /^[^\W\d]\w*(?:::\w+)*\z/s
ABCresult
0XX0
10X0
1100
1111
420 defined $_[0]
421 and
422 ! ref $_[0]
423 and
424 $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s
425 ) ? $_[0] : undef;
426 }
427 1  
428 1;
429  
430 # Copyright 2008 - 2009 Adam Kennedy.
« t/test/inc/Module/Install/Metadata.pm ↑ Summary t/test/inc/Module/Install/WriteAll.pm »