dist/t9vPd3GCmf/inc/Module/Install.pm

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