dist/inc/Module/Install.pm

filter: Statementstmt 76.1% 179 / 235 Branchbran 54.8% 57 / 104 Conditioncond 26.0% 13 / 50 MC/DCmcdc 13.3% 4 / 30 Subroutinesub 88.8% 24 / 27 Podpod 0.0% 0 / 7 totaltotal 61.1% 277 / 453 CC 79 SCAR 32.2
CC
79
Cov
64%
new
120.0
import
28.3
_CLASS
20.0
CRAP 24.9
« inc/Module/Install/Can.pm ↑ Summary inc/Module/Install/AutoLicense.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 1 ▶# }
Subroutine BEGIN: called CC=1 SCAR=0.0
20 1 ▶ 
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use strict 'vars';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 use File::Find ();
25 1 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 1 ▶ 
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 1 # releases once we can make sure it won't clash with custom
34 # Module::Install extensions.
35 $VERSION = '1.17';
36 1  
37 # Storage for the pseudo-singleton
38 1 $MAIN = undef;
39 1  
40 *inc::Module::Install::VERSION = *VERSION;
41 @inc::Module::Install::ISA = __PACKAGE__;
42  
43 1 ▶}
Subroutine import: called CC=12 SCAR=33.4
44 1  
45 1 sub import {
46 1 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 1 # 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 1 1
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 1 ▶ # we shouldn't really depend on it. See RT #24194 for detail.
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "MSWin32" and $] >= "5.006" 0 1 1
Condition33%1/3
$^O eq "MSWin32" and $] >= "5.006"
!ll&&!rl&&r
100
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 1 ▶ # is unreliable on some platforms and requires write permissions)
Branch: 1 branch
BranchTrueFalseTotal
if (-f $0) 1 0 1
85 1 # for now we should catch this and refuse to run.
86 if ( -f $0 ) {
87 my $s = (stat($0))[9];
88  
89 1 # 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 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
91 my $a = $s - time;
92 if ( $a > 0 and $a < 5 ) { sleep 5 }
93 1  
94 0 ▶ # Too far in the future, throw an error.
Branch: 1 branch
BranchTrueFalseTotal
if ($s > $t) 0 1 1
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 1 1
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 1 # use inc::Module::Install
124 # ...also acts as an implicit use strict.
125 $^H |= strict::bits(qw(refs subs vars));
126  
127 1 ▶ #-------------------------------------------------------------
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $self->{"file"}) 0 1 1
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 1 }
142 1  
143 1 local $^W;
144 *{"${who}::AUTOLOAD"} = $self->autoload;
145 $self->preload;
146 1  
147 1 # 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 1  
151 # Save to the singleton
152 1 $MAIN = $self;
153  
154 return 1;
155 36 ▶}
Subroutine autoload: called CC=1 SCAR=0.2
Pod undocumented
156 36  
157 36 sub autoload {
158 36 my $self = shift;
159 36 my $who = $self->_caller;
160 42 ▶ my $cwd = Cwd::getcwd();
Subroutine __ANON__: called CC=7 SCAR=21.3
161 42 my $sym = "${who}::AUTOLOAD";
162 42 ▶ $sym->{$cwd} = sub {
Branch: 1 branch
BranchTrueFalseTotal
if (my $code = $sym->{$pwd}) 42 0 42
163 my $pwd = Cwd::getcwd();
164 42 ▶ if ( my $code = $sym->{$pwd} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless $cwd eq $pwd 0 42 42
165 # Delegate back to parent dirs
166 42 ▶ goto &$code unless $cwd eq $pwd;
Branch: 1 branch
BranchTrueFalseTotal
unless ($$sym =~ s/([^:]+)$//) 0 42 42
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 42 EOT
182 42 ▶ }
Branch: 2 branches
BranchTrueFalseTotal
if (uc $method eq $method) { } 0 42 42
elsif ($method =~ /^_/ and $self->can($method)) { } 1 82 83
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
4101
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 1 } elsif ( $method =~ /^_/ and $self->can($method) ) {
188 # Dispatch to the root M:I class
189 return $self->$method(@_);
190 }
191 41  
192 41 # Dispatch to the appropriate plugin
193 36 unshift @_, ( $self, $1 );
194 goto &{$self->can('call')};
195 };
196 1 ▶}
Subroutine preload: called CC=9 SCAR=22.0
Pod undocumented
197 1  
198 1 ▶sub preload {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"extensions"}) 1 0 1
199 1 my $self = shift;
200 unless ( $self->{extensions} ) {
201 $self->load_extensions(
202 "$self->{prefix}/$self->{path}", $self
203 );
204 1 }
205 1 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (@exts) 1 0 1
206 1 my @exts = @{$self->{extensions}};
207 unless ( @exts ) {
208 @exts = $self->{admin}->load_all_extensions;
209 1 }
210 1  
211 32 ▶ my %seen;
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{ref($obj) . '::';}) 445 32 477
212 445 ▶ foreach my $obj ( @exts ) {
Branch: 1 branch
BranchTrueFalseTotal
unless $obj->can($method) 97 348 445
213 348 ▶ while (my ($method, $glob) = each %{ref($obj) . '::'}) {
Branch: 1 branch
BranchTrueFalseTotal
if $method =~ /^_/ 16 332 348
214 332 ▶ next unless $obj->can($method);
Branch: 1 branch
BranchTrueFalseTotal
if $method eq uc $method 41 291 332
215 291 next if $method =~ /^_/;
216 next if $method eq uc($method);
217 $seen{$method}++;
218 }
219 1 }
220 1  
221 152 my $who = $self->_caller;
222 152 ▶ foreach my $name ( sort keys %seen ) {
Subroutine __ANON__: called CC=1 SCAR=0.0
223 7 local $^W;
224 7 *{"${who}::$name"} = sub {
225 152 ${"${who}::AUTOLOAD"} = "${who}::$name";
226 goto &{"${who}::AUTOLOAD"};
227 };
228 }
229 1 ▶}
Subroutine new: called CC=14 SCAR=47.9
Pod undocumented
230 1  
231 sub new {
232 1 my ($class, %args) = @_;
233  
234 delete $INC{'FindBin.pm'};
235 1 ▶ {
Subroutine __ANON__: called CC=1 SCAR=0.0
236 1 # to suppress the redefine warning
237 local $SIG{__WARN__} = sub {};
238 require FindBin;
239 }
240 1  
241 1 ▶ # ignore the prefix on extension modules built from top level.
Branch: 1 branch
BranchTrueFalseTotal
unless (Cwd::abs_path(Cwd::getcwd()) eq $base_path) 0 1 1
242 0 my $base_path = Cwd::abs_path($FindBin::Bin);
243 unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) {
244 1 ▶ delete $args{prefix};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"_self"} 1 0 1
245 }
246 0 ▶ return $args{_self} if $args{_self};
Branch: 1 branch
BranchTrueFalseTotal
if $^O eq "VMS" 0 0 0
247  
248 0 ▶ $base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS';
Condition0%0/2
$args{"dispatch"} ||= "Admin"
l!l
00
MC/DC0%0/1
$args{"dispatch"} ||= "Admin"
$args{"dispatch"}
Truth table0%0/2
A
A= $args{"dispatch"}
Aresult
11
00
249 0 ▶ 
Condition0%0/2
$args{"prefix"} ||= "inc"
l!l
00
MC/DC0%0/1
$args{"prefix"} ||= "inc"
$args{"prefix"}
Truth table0%0/2
A
A= $args{"prefix"}
Aresult
11
00
250 0 ▶ $args{dispatch} ||= 'Admin';
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'VMS' ? : 0 0 0
Condition0%0/3
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"author"} ||= $^O eq "VMS" ? "_author" : ".author"
$args{"author"} $^O eq "VMS" ? "_author" : ".author"
Truth table0%0/3
A ||= B
A= $args{"author"}B= $^O eq "VMS" ? "_author" : ".author"
ABresult
1X1
011
000
251 0 ▶ $args{prefix} ||= 'inc';
Condition0%0/2
$args{"bundle"} ||= "inc/BUNDLES"
l!l
00
MC/DC0%0/1
$args{"bundle"} ||= "inc/BUNDLES"
$args{"bundle"}
Truth table0%0/2
A
A= $args{"bundle"}
Aresult
11
00
252 0 ▶ $args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
Condition0%0/3
$args{"base"} ||= $base_path
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"base"} ||= $base_path
$args{"base"} $base_path
Truth table0%0/3
A ||= B
A= $args{"base"}B= $base_path
ABresult
1X1
011
000
253 0 $args{bundle} ||= 'inc/BUNDLES';
254 0 ▶ $args{base} ||= $base_path;
Condition0%0/3
$args{"name"} ||= $class
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"name"} ||= $class
$args{"name"} $class
Truth table0%0/3
A ||= B
A= $args{"name"}B= $class
ABresult
1X1
011
000
255 0 ▶ $class =~ s/^\Q$args{prefix}\E:://;
Condition0%0/3
$args{"version"} ||= $class->VERSION
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"version"} ||= $class->VERSION
$args{"version"} $class->VERSION
Truth table0%0/3
A ||= B
A= $args{"version"}B= $class->VERSION
ABresult
1X1
011
000
256 0 ▶ $args{name} ||= $class;
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"path"}) 0 0 0
257 0 $args{version} ||= $class->VERSION;
258 0 unless ( $args{path} ) {
259 $args{path} = $args{name};
260 0 ▶ $args{path} =~ s!::!/!g;
Condition0%0/2
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
l!l
00
MC/DC0%0/1
$args{"file"} ||= qq[$args{"base"}/$args{"prefix"}/$args{"path"}.pm]
$args{"file"}
Truth table0%0/2
A
A= $args{"file"}
Aresult
11
00
261 0 }
262 $args{file} ||= "$args{base}/$args{prefix}/$args{path}.pm";
263 0 $args{wrote} = 0;
264  
265 bless( \%args, $class );
266 41 ▶}
Subroutine call: called CC=2 SCAR=7.0
Pod undocumented
267 41  
268 41 ▶sub call {
Branch: 1 branch
BranchTrueFalseTotal
my $obj = $self->load($method) or return 41 0 41
269 41 my ($self, $method) = @_;
270 41 my $obj = $self->load($method) or return;
271 splice(@_, 0, 2, $obj);
272 goto &{$obj->can($method)};
273 44 ▶}
Subroutine load: called CC=5 SCAR=16.2
Pod undocumented
274 44  
275 sub load {
276 my ($self, $method) = @_;
277  
278 44 ▶ $self->load_extensions(
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"extensions"} 0 44 44
279 "$self->{prefix}/$self->{path}", $self
280 44 ) unless $self->{extensions};
281 91 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if $obj->can($method) 37 54 91
282 foreach my $obj (@{$self->{extensions}}) {
283 return $obj if $obj->can($method);
284 7 ▶ }
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] 7 0 7
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 7 END_DIE
290 7  
291 my $obj = $admin->load($method, 1);
292 7 push @{$self->{extensions}}, $obj;
293  
294 $obj;
295 8 ▶}
Subroutine load_extensions: called CC=9 SCAR=23.5
Pod undocumented
296 8  
297 sub load_extensions {
298 8 my ($self, $path, $top) = @_;
299 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {not ref $_ and lc $_ eq lc $self->{"prefix"};} @INC) 0 8 8
Condition66%2/3
!ref($_) && lc $_ eq lc $self->{'prefix'}
!ll&&!rl&&r
0568
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 8 }
305 40  
306 40 ▶ foreach my $rv ( $self->find_extensions($path) ) {
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"pathnames"}{$pkg} 8 32 40
307 my ($file, $pkg) = @{$rv};
308 32 next if $self->{pathnames}{$pkg};
309 32  
310 32 ▶ local $@;
Branch: 1 branch
BranchTrueFalseTotal
unless ($new) 0 32 32
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 32 ▶ }
Branch: 1 branch
BranchTrueFalseTotal
$should_reload ? : 0 32 32
316 32 $self->{pathnames}{$pkg} =
317 $should_reload ? delete $INC{$file} : $INC{$file};
318 push @{$self->{extensions}}, &{$new}($pkg, _top => $top );
319 8 ▶ }
Condition100%2/2
$self->{"extensions"} ||= []
l!l
71
MC/DC100%1/1
$self->{"extensions"} ||= []
$self->{"extensions"}
Truth table100%2/2
A
A= $self->{"extensions"}
Aresult
11
00
320  
321 $self->{extensions} ||= [];
322 8 ▶}
Subroutine find_extensions: called CC=2 SCAR=7.0
Pod undocumented
323 8  
324 sub find_extensions {
325 8 my ($self, $path) = @_;
326 49 ▶ 
Subroutine __ANON__: called CC=12 SCAR=25.7
327 49 my @found;
328 49 ▶ File::Find::find( {no_chdir => 1, wanted => sub {
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ m[^\Q$path\E/(.+)\.pm\Z]is 8 41 49
329 41 my $file = $File::Find::name;
330 41 ▶ return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
Branch: 1 branch
BranchTrueFalseTotal
if lc $subpath eq lc $self->{"dispatch"} 1 40 41
331 my $subpath = $1;
332 40 return if lc($subpath) eq lc($self->{dispatch});
333 40  
334 40 $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 40 ▶ # 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) 1 39 40
Condition66%2/3
$subpath eq lc $subpath or $subpath eq uc $subpath
l!l&&r!l&&!r
0139
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 1 # version of the package name.
341 1 if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
342 1 my $content = Module::Install::_read($File::Find::name);
343 1 ▶ my $in_pod = 0;
Branch: 1 branch
BranchTrueFalseTotal
if /^=\w/ 0 1 1
344 1 ▶ foreach ( split /\n/, $content ) {
Branch: 1 branch
BranchTrueFalseTotal
if /^=cut/ 0 1 1
345 1 ▶ $in_pod = 1 if /^=\w/;
Branch: 1 branch
BranchTrueFalseTotal
if $in_pod or /^=cut/ 0 1 1
Condition33%1/3
$in_pod or /^=cut/
l!l&&r!l&&!r
001
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 1 ▶ $in_pod = 0 if /^=cut/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*#/ 0 1 1
347 1 ▶ next if ($in_pod || /^=cut/); # skip pod text
Branch: 1 branch
BranchTrueFalseTotal
if (/^\s*package\s+($pkg)\s*;/i) 1 0 1
348 1 next if /^\s*#/; # and comments
349 1 if ( m/^\s*package\s+($pkg)\s*;/i ) {
350 $pkg = $1;
351 last;
352 }
353 }
354 40 }
355 8 ▶ 
Branch: 1 branch
BranchTrueFalseTotal
if -d $path 3 5 8
356 push @found, [ $file, $pkg ];
357 8 }}, $path ) if -d $path;
358  
359 @found;
360 }
361  
362  
363  
364  
365  
366 #####################################################################
367 38 ▶# Common Utility Functions
Subroutine _caller: called CC=2 SCAR=6.9
368 38  
369 38 sub _caller {
370 38 ▶ my $depth = 0;
Branch: 1 branch
BranchTrueFalseTotal
if ($call eq __PACKAGE__) 40 38 78
371 40 my $call = caller($depth);
372 40 while ( $call eq __PACKAGE__ ) {
373 $depth++;
374 38 $call = caller($depth);
375 }
376 return $call;
377 1 ▶}
Subroutine _read: called CC=3 SCAR=11.1
378 1  
379 1 ▶sub _read {
Branch: 1 branch
BranchTrueFalseTotal
open FH, "<", $_[0] or die "open($_[0]): $!" 1 0 1
380 1 local *FH;
381 1 open( FH, '<', $_[0] ) or die "open($_[0]): $!";
382 1 ▶ binmode FH;
Branch: 1 branch
BranchTrueFalseTotal
close FH or die "close($_[0]): $!" 1 0 1
383 1 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 1 ▶}
Subroutine _write: called CC=5 SCAR=16.8
406 1  
407 1 ▶sub _write {
Branch: 1 branch
BranchTrueFalseTotal
open FH, ">", $_[0] or die "open($_[0]): $!" 1 0 1
408 1 local *FH;
409 1 open( FH, '>', $_[0] ) or die "open($_[0]): $!";
410 1 ▶ binmode FH;
Branch: 1 branch
BranchTrueFalseTotal
print FH $_[$_] or die "print($_[0]): $!" 1 0 1
411 foreach ( 1 .. $#_ ) {
412 1 ▶ print FH $_[$_] or die "print($_[0]): $!";
Branch: 1 branch
BranchTrueFalseTotal
close FH or die "close($_[0]): $!" 1 0 1
413 }
414 close FH or die "close($_[0]): $!";
415 }
416  
417 2 ▶# _version is for processing module versions (eg, 1.03_05) not
Subroutine _version: called CC=5 SCAR=17.6
418 2 ▶# Perl versions (eg, 5.8.1).
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
419 2 sub _version {
420 2 ▶ my $s = shift || 0;
Branch: 1 branch
BranchTrueFalseTotal
if ($d >= 2) 0 2 2
421 my $d =()= $s =~ /(\.)/g;
422 0 if ( $d >= 2 ) {
423 # Normalise multipart versions
424 2 $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg;
425 2 ▶ }
Condition50%1/2
$1 || 0
l!l
20
MC/DC0%0/1
$1 || 0
$1
Truth table50%1/2
A
A= $1
Aresult
11
00
426 $s =~ s/^(\d+)\.?//;
427 2 my $l = $1 || 0;
428 my @v = map {
429 2 ▶ $_ . '0' x (3 - length $_)
Branch: 1 branch
BranchTrueFalseTotal
if @v 2 0 2
430 2 } $s =~ /(\d{1,3})\D?/g;
431 $l = $l . '.' . join '', @v if @v;
432 return $l + 0;
433 1 ▶}
Subroutine _cmp: called CC=1 SCAR=0.0
434 1  
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 1 }
449  
450 1;
451  
452 # Copyright 2008 - 2012 Adam Kennedy.
« inc/Module/Install/Can.pm ↑ Summary inc/Module/Install/AutoLicense.pm »