lib/Parse/LocalDistribution.pm

filter: Statementstmt 71.3% 164 / 230 Branchbran 45.4% 50 / 110 Conditioncond 25.3% 17 / 67 MC/DCmcdc 8.1% 3 / 37 Subroutinesub 78.5% 22 / 28 Podpod 100% 2 / 2 totaltotal 54.4% 258 / 474 CC 88 SCAR 38.0
CC
88
Cov
57%
_examine_pkg
240.0
_index_by_meta
72.0
_extract_meta
19.9
CRAP 44.9
↑ Summary
1 package Parse::LocalDistribution;
2  
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use Parse::PMFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use List::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
7 13 ▶use Parse::CPAN::Meta ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use Cwd ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 our $VERSION = '0.21';
13  
14 20 ▶sub new {
Subroutine new: called CC=4 SCAR=14.8
Pod documented
15 20 my ($class, $root, $opts) = @_;
16 20 ▶ if (ref $root eq ref {} && !$opts) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $root eq ref {} and not $opts) 20 0 20
Condition33%1/3
ref $root eq ref {} and not $opts
!ll&&!rl&&r
0020
MC/DC0%0/2
ref $root eq ref {} and not $opts
ref $root eq ref {} not $opts
Truth table33%1/3
A and not(B)
A= ref $root eq ref {}B= not $opts
ABresult
0X0
100
111
17 20 $opts = $root; $root = undef;
18 }
19 20 ▶ $opts ||= {};
Condition50%1/2
$opts ||= {}
l!l
200
MC/DC0%0/1
$opts ||= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
20 20 $opts->{DISTROOT} = $root;
21 20 bless $opts, $class;
22 }
23  
24 # adapted from PAUSE::mldistwatch#check_for_new
25 20 ▶sub parse {
Subroutine parse: called CC=3 SCAR=12.0
Pod documented
26 20 my ($self, $root) = @_;
27 20 ▶ if ($root) {
Branch: 2 branches
BranchTrueFalseTotal
if ($root) { } 20 0 20
elsif (not $self->{'DISTROOT'}) { } 0 0 0
28 20 $self->{DISTROOT} = $root;
29 } elsif (!$self->{DISTROOT}) {
30 0 $self->{DISTROOT} = Cwd::cwd();
31 }
32  
33 20 $self->{DIST} = $self->{DISTROOT};
34 20 $self->_read_dist;
35 20 $self->_extract_meta;
36 20 $self->_examine_pms;
37 }
38  
39 # from PAUSE::dist;
40 20 ▶sub _read_dist {
Subroutine _read_dist: called CC=2 SCAR=7.3
41 20 my $self = shift;
42 # TODO: support absolute path
43 20 my(@manifind) = $self->_find_files;
44 20 my $manifound = @manifind;
45 20 $self->{MANIFOUND} = \@manifind;
46 20 my $dist = $self->{DIST};
47 20 ▶ unless (@manifind){
Branch: 1 branch
BranchTrueFalseTotal
unless (@manifind) 0 20 20
48 0 $self->_verbose(1,"NO FILES! in dist $dist?");
49 0 return;
50 }
51 20 $self->_verbose(1,"Found $manifound files in dist $dist, first $manifind[0]\n");
52 }
53  
54 # from PAUSE::dist;
55 20 ▶sub _extract_meta {
Subroutine _extract_meta: called CC=12 SCAR=29.9
56 20 my $self = shift;
57  
58 20 ▶ return if $self->{META_CONTENT};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"META_CONTENT"} 0 20 20
59  
60 20 my $dist = $self->{DIST};
61 20 my @manifind = @{$self->{MANIFOUND}};
62  
63 0 ▶ my $json = List::Util::reduce { length $a < length $b ? $a : $b }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
length $a < length $b ? : 0 0 0
64 20 grep !m|/t/|, grep m|/META\.json$|, @manifind;
65 0 ▶ my $yaml = List::Util::reduce { length $a < length $b ? $a : $b }
Subroutine __ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
length $a < length $b ? : 0 0 0
66 20 grep !m|/t/|, grep m|/META\.yml$|, @manifind;
67  
68 # META.json located only in a subdirectory should not precede
69 # META.yml located in the top directory. (eg. Test::Module::Used 0.2.4)
70 20 ▶ if ($json && $yaml && length($json) > length($yaml) + 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($json and $yaml and length $json > length($yaml) + 1) 0 20 20
Condition83%5/6
$json and $yaml and length $json > length($yaml) + 1
!ll&&!rl&&r
1640
$json and $yaml
!ll&&!rl&&r
1244
MC/DC0%0/3
$json and $yaml and length $json > length($yaml) + 1
$json $yaml length $json > length($yaml) + 1
Truth table75%3/4
A and B and C
A= $jsonB= $yamlC= length $json > length($yaml) + 1
ABCresult
0XX0
10X0
1100
1111
71 0 $json = '';
72 }
73  
74 20 ▶ unless ($json || $yaml) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($json or $yaml) 12 8 20
Condition66%2/3
$json or $yaml
l!l&&r!l&&!r
8012
MC/DC50%1/2
$json or $yaml
$json $yaml
Truth table66%2/3
A or B
A= $jsonB= $yaml
ABresult
1X1
011
000
75 12 $self->{METAFILE} = "No META.yml or META.json found";
76 12 $self->_verbose(1,"No META.yml or META.json in $dist");
77 12 return;
78 }
79  
80 8 ▶ for my $metafile ($json || $yaml) {
Condition33%1/3
$json || $yaml
l!l&&r!l&&!r
800
MC/DC0%0/2
$json || $yaml
$json $yaml
Truth table33%1/3
A || B
A= $jsonB= $yaml
ABresult
1X1
011
000
81 8 my $metafile_abs = File::Spec->catfile($self->{DISTROOT}, $metafile);
82 8 $metafile_abs =~ s|\\|/|g;
83 8 ▶ if (-l $metafile_abs) {
Branch: 2 branches
BranchTrueFalseTotal
if (-l $metafile_abs) { } 0 8 8
elsif (-s $metafile_abs) { } 8 0 8
84 0 my $err = "found $metafile but it was a symlink, ignoring";
85 0 $self->{METAFILE} = $err;
86 } elsif (-s $metafile_abs) {
87 8 $self->{METAFILE} = $metafile;
88 8 my $ok = eval {
89 8 $self->{META_CONTENT} = Parse::CPAN::Meta->load_file($metafile_abs); 1
90 };
91 8 ▶ unless ($ok) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($ok) 0 8 8
92 0 $self->_verbose(1,"Error while parsing $metafile: $@");
93 0 $self->{META_CONTENT} = {};
94 0 $self->{METAFILE} = "$metafile found but error "
95 . "encountered while loading: $@";
96 }
97 } else {
98 0 $self->{METAFILE} = "Empty $metafile found, ignoring\n";
99 }
100 }
101 }
102  
103 # from PAUSE::dist;
104 20 ▶sub _examine_pms {
Subroutine _examine_pms: called CC=7 SCAR=26.8
105 20 my $self = shift;
106  
107 20 my $dist = $self->{DIST};
108  
109 20 my $pmfiles = $self->_filter_pms;
110 20 my($meta, $provides, $indexing_method);
111 20 ▶ if (my $version_from_meta_ok = $self->_version_from_meta_ok) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $version_from_meta_ok = $self->_version_from_meta_ok) 0 20 20
112 0 $meta = $self->{META_CONTENT};
113 0 $provides = $meta->{provides};
114 0 ▶ if ($provides && "HASH" eq ref $provides) {
Branch: 1 branch
BranchTrueFalseTotal
if ($provides and "HASH" eq ref $provides) 0 0 0
Condition0%0/3
$provides and "HASH" eq ref $provides
!ll&&!rl&&r
000
MC/DC0%0/2
$provides and "HASH" eq ref $provides
$provides "HASH" eq ref $provides
Truth table0%0/3
A and B
A= $providesB= "HASH" eq ref $provides
ABresult
0X0
100
111
115 0 $indexing_method = '_index_by_meta';
116 }
117 }
118 20 ▶ if (! $indexing_method && @$pmfiles) { # examine files
Branch: 1 branch
BranchTrueFalseTotal
if (not $indexing_method and @$pmfiles) 20 0 20
Condition33%1/3
not $indexing_method and @$pmfiles
!ll&&!rl&&r
0020
MC/DC0%0/2
not $indexing_method and @$pmfiles
not $indexing_method @$pmfiles
Truth table33%1/3
not(A) and B
A= not $indexing_methodB= @$pmfiles
ABresult
0X0
100
111
119 20 $indexing_method = '_index_by_files';
120 }
121  
122 20 ▶ if ($indexing_method) {
Branch: 1 branch
BranchTrueFalseTotal
if ($indexing_method) 20 0 20
123 20 return $self->$indexing_method($pmfiles, $provides);
124 }
125 0 return {};
126 }
127  
128 # from PAUSE::dist
129 20 ▶sub _index_by_files {
Subroutine _index_by_files: called CC=10 SCAR=28.6
130 20 my ($self, $pmfiles, $provides) = @_;
131 20 my $dist = $self->{DIST};
132  
133 20 my %result;
134 20 my $parser = Parse::PMFile->new($self->{META_CONTENT}, $self);
135 20 for my $pmfile (@$pmfiles) {
136 20 my $pmfile_abs = File::Spec->catfile($self->{DISTROOT}, $pmfile);
137 20 $pmfile_abs =~ s|\\|/|g;
138 20 ▶ if ($pmfile_abs =~ m|/blib/|) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pmfile_abs =~ m[/blib/]) 0 20 20
139 0 $self->_verbose(1,"Still a blib directory detected:
140 dist[$dist]pmfile[$pmfile]
141 ");
142 0 next;
143 }
144  
145 20 my ($info, $errs) = $parser->parse($pmfile_abs);
146  
147 15 for my $package (keys %$info) {
148 15 ▶ if (!defined $result{$package} or $info->{$package}{simile}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $result{$package} or $info->{$package}{"simile"}) 15 0 15
Condition33%1/3
not defined $result{$package} or $info->{$package}{"simile"}
l!l&&r!l&&!r
1500
MC/DC0%0/2
not defined $result{$package} or $info->{$package}{"simile"}
not defined $result{$package} $info->{$package}{"simile"}
Truth table33%1/3
not(A) or B
A= not defined $result{$package}B= $info->{$package}{"simile"}
ABresult
1X1
011
000
149 15 $result{$package} = $info->{$package};
150 }
151 }
152 15 ▶ if ($errs) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errs) 0 15 15
153 0 for my $package (keys %$errs) {
154 0 for (keys %{$errs->{$package}}) {
155 0 ▶ $result{$package}{$_ =~ /infile|warning/ ? $_ : $_.'_error'} = $errs->{$package}{$_};
Branch: 1 branch
BranchTrueFalseTotal
$_ =~ /infile|warning/ ? : 0 0 0
156 }
157 }
158 }
159 }
160 15 return \%result;
161 }
162  
163 # from PAUSE::dist
164 0 ▶sub _index_by_meta {
Subroutine _index_by_meta: not called CC=8 SCAR=42.8
165 0 my ($self, $pmfiles, $provides) = @_;
166 0 my $dist = $self->{DIST};
167  
168 0 my %result;
169 0 ▶ while (my($k,$v) = each %$provides) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %$provides) 0 0 0
170 0 ▶ next if ref $v ne ref {};
Branch: 1 branch
BranchTrueFalseTotal
if ref $v ne ref {} 0 0 0
171 0 ▶ next if !defined $v->{file} or $v->{file} eq '';
Branch: 1 branch
BranchTrueFalseTotal
if not defined $v->{"file"} or $v->{"file"} eq "" 0 0 0
Condition0%0/3
not defined $v->{"file"} or $v->{"file"} eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $v->{"file"} or $v->{"file"} eq ""
not defined $v->{"file"} $v->{"file"} eq ""
Truth table0%0/3
not(A) or B
A= not defined $v->{"file"}B= $v->{"file"} eq ""
ABresult
1X1
011
000
172 0 $v->{infile} = "$v->{file}";
173 0 my @stat = stat File::Spec->catfile($self->{DISTROOT}, $v->{file});
174 0 ▶ if (@stat) {
Branch: 1 branch
BranchTrueFalseTotal
if (@stat) { } 0 0 0
175 0 $v->{filemtime} = $stat[9];
176 } else {
177 0 $v->{filemtime} = 0;
178 }
179 0 ▶ unless (defined $v->{version}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v->{"version"}) 0 0 0
180 # 2009-09-23 get a bugreport due to
181 # RKITOVER/MooseX-Types-0.20.tar.gz not
182 # setting version for MooseX::Types::Util
183 0 $v->{version} = "undef";
184 }
185 # going from a distro object to a package object
186 # is only possible via a file object
187  
188 0 ▶ $self->_examine_pkg({package => $k, pp => $v}) or next;
Branch: 1 branch
BranchTrueFalseTotal
$self->_examine_pkg({"package", $k, "pp", $v}) or next 0 0 0
189  
190 0 $result{$k} = $v;
191 }
192 0 return \%result;
193 }
194  
195 # from PAUSE::package;
196 0 ▶sub _examine_pkg {
Subroutine _examine_pkg: not called CC=15 SCAR=54.8
197 0 my ($self, $args) = @_;
198 0 my $package = $args->{package};
199 0 my $pp = $args->{pp};
200  
201 # should they be cought earlier? Maybe.
202 # but as an ultimate sanity check suggested by Richard Soderberg
203 # XXX should be in a separate sub and be tested
204 0 ▶ if ($package !~ /^\w[\w\:\']*\w?\z/
Branch: 1 branch
BranchTrueFalseTotal
if (not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/) 0 0 0
Condition0%0/15
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/
l!l&&r!l&&!r
000
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/
l!l&&r!l&&!r
000
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/
l!l&&r!l&&!r
000
$package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/
!ll&&!rl&&r
000
$package =~ /:/ and not $package =~ /::/
!ll&&!rl&&r
000
MC/DC0%0/6
not $package =~ /^\w[\w\:\']*\w?\z/ && $package =~ /\w\z/ or $package =~ /:/ and not $package =~ /::/ or $package =~ /\w:\w/ or $package =~ /:::/
$package =~ /^\w[\w\:\']*\w?\z/ $package =~ /\w\z/ $package =~ /:/ not $package =~ /::/ $package =~ /\w:\w/ $package =~ /:::/
Truth table0%0/9
not(A && B) or C and not(D) or E or F
A= $package =~ /^\w[\w\:\']*\w?\z/B= $package =~ /\w\z/C= $package =~ /:/D= not $package =~ /::/E= $package =~ /\w:\w/F= $package =~ /:::/
ABCDEFresult
0XXXXX1
10XXXX1
1111XX1
110X1X1
11101X1
110X011
1110011
110X000
1110000
205 ||
206 $package !~ /\w\z/
207 ||
208 $package =~ /:/ && $package !~ /::/
209 ||
210 $package =~ /\w:\w/
211 ||
212 $package =~ /:::/
213 ){
214 0 $self->_verbose(1,"Package[$package] did not pass the ultimate sanity check");
215 0 return;
216 }
217  
218 0 ▶ if ($self->{USERID} && $self->{PERMISSIONS} && !$self->_perm_check($package)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)) 0 0 0
Condition0%0/6
$self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)
!ll&&!rl&&r
000
$self->{"USERID"} and $self->{"PERMISSIONS"}
!ll&&!rl&&r
000
MC/DC0%0/3
$self->{"USERID"} and $self->{"PERMISSIONS"} and not $self->_perm_check($package)
$self->{"USERID"} $self->{"PERMISSIONS"} not $self->_perm_check($package)
Truth table0%0/4
A and B and not(C)
A= $self->{"USERID"}B= $self->{"PERMISSIONS"}C= not $self->_perm_check($package)
ABCresult
0XX0
10X0
1100
1111
219 0 return;
220 }
221  
222 # No parser problem should be found
223 # (only used for META provides in this module)
224  
225 # Sanity checks
226  
227 0 for (
228 $package,
229 $pp->{version},
230 ) {
231 0 ▶ if (!defined || /^\s*$/ || /\s/){ # for whatever reason I come here
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_ or /^\s*$/ or /\s/) 0 0 0
Condition0%0/6
not defined $_ or /^\s*$/ or /\s/
l!l&&r!l&&!r
000
not defined $_ or /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $_ or /^\s*$/ or /\s/
not defined $_ /^\s*$/ /\s/
Truth table0%0/4
not(A) or B or C
A= not defined $_B= /^\s*$/C= /\s/
ABCresult
1XX1
01X1
0011
0000
232 0 return; # don't screw up 02packages
233 }
234 }
235 0 ▶ return unless $self->_version_ok($pp);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_version_ok($pp) 0 0 0
236  
237 0 $pp;
238 }
239  
240 0 ▶sub _version_ok {
Subroutine _version_ok: not called CC=3 SCAR=24.8
241 0 my ($self, $pp) = @_;
242 0 ▶ return if length($pp->{version} || 0) > 16;
Branch: 1 branch
BranchTrueFalseTotal
if length($pp->{"version"} || 0) > 16 0 0 0
Condition0%0/2
$pp->{'version'} || 0
l!l
00
MC/DC0%0/1
$pp->{'version'} || 0
$pp->{'version'}
Truth table0%0/2
A
A= $pp->{'version'}
Aresult
11
00
243 0 return 1
244 }
245  
246 # from PAUSE::dist;
247 20 ▶sub _filter_pms {
Subroutine _filter_pms: called CC=13 SCAR=28.3
248 20 my($self) = @_;
249 20 my @pmfile;
250  
251 # very similar code is in PAUSE::package::filter_ppps
252 20 MANI: for my $mf ( @{$self->{MANIFOUND}} ) {
253 104 ▶ next unless $mf =~ /\.pm(?:\.PL)?$/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $mf =~ /\.pm(?:\.PL)?$/i 80 24 104
254 24 my($inmf) = $mf =~ m!^[^/]+/(.+)!; # go one directory down
255  
256 # skip "t" - libraries in ./t are test libraries!
257 # skip "xt" - libraries in ./xt are author test libraries!
258 # skip "inc" - libraries in ./inc are usually install libraries
259 # skip "local" - somebody shipped his carton setup!
260 # skip 'perl5" - somebody shipped her local::lib!
261 # skip 'fatlib" - somebody shipped their fatpack lib!
262 # skip 'examples', 'example', 'ex', 'eg', 'demo' - example usage
263 24 ▶ next if $inmf =~ m!^(?:x?t|inc|local|perl5|fatlib|examples?|ex|eg|demo)/!;
Branch: 1 branch
BranchTrueFalseTotal
if $inmf =~ m[^(?:x?t|inc|local|perl5|fatlib|examples?|ex|eg|demo)/] 4 20 24
264  
265 20 ▶ if ($self->{META_CONTENT}){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'META_CONTENT'}) { } 8 12 20
266 my $no_index = $self->{META_CONTENT}{no_index}
267 8 ▶ || $self->{META_CONTENT}{private}; # backward compat
Condition33%1/3
$self->{'META_CONTENT'}{'no_index'} || $self->{'META_CONTENT'}{'private'}
l!l&&r!l&&!r
800
MC/DC0%0/2
$self->{'META_CONTENT'}{'no_index'} || $self->{'META_CONTENT'}{'private'}
$self->{'META_CONTENT'}{'no_index'} $self->{'META_CONTENT'}{'private'}
Truth table33%1/3
A || B
A= $self->{'META_CONTENT'}{'no_index'}B= $self->{'META_CONTENT'}{'private'}
ABresult
1X1
011
000
268 8 ▶ if (ref($no_index) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $no_index eq 'HASH') { } 8 0 8
269 8 my %map = (
270 file => qr{\z},
271 directory => qr{/},
272 );
273 8 for my $k (qw(file directory)) {
274 16 ▶ next unless my $v = $no_index->{$k};
Branch: 1 branch
BranchTrueFalseTotal
unless my $v = $no_index->{$k} 8 8 16
275 8 my $rest = $map{$k};
276 8 ▶ if (ref $v eq "ARRAY") {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 8 0 8
277 8 for my $ve (@$v) {
278 16 $ve =~ s|\\|/|g; # Class-InsideOut-0.90_01
279 16 $ve =~ s|/+$||;
280 16 ▶ if ($inmf =~ /^$ve$rest/){
Branch: 1 branch
BranchTrueFalseTotal
if ($inmf =~ /^$ve$rest/) { } 0 16 16
281 0 $self->_verbose(1,"Skipping inmf[$inmf] due to ve[$ve]");
282 0 next MANI;
283 } else {
284 16 $self->_verbose(1,"NOT skipping inmf[$inmf] due to ve[$ve]");
285 }
286 }
287 } else {
288 0 $v =~ s|/+$||;
289 0 ▶ if ($inmf =~ /^$v$rest/){
Branch: 1 branch
BranchTrueFalseTotal
if ($inmf =~ /^$v$rest/) { } 0 0 0
290 0 $self->_verbose(1,"Skipping inmf[$inmf] due to v[$v]");
291 0 next MANI;
292 } else {
293 0 $self->_verbose(1,"NOT skipping inmf[$inmf] due to v[$v]");
294 }
295 }
296 }
297 } else {
298 # noisy:
299 # $self->_verbose(1,"no keyword 'no_index' or 'private' in META_CONTENT");
300 }
301 } else {
302 # $self->_verbose(1,"no META_CONTENT"); # too noisy
303 }
304 20 push @pmfile, $mf;
305 }
306 20 $self->_verbose(1,"Finished with pmfile[@pmfile]\n");
307 20 \@pmfile;
308 }
309  
310 20 ▶sub _version_from_meta_ok { Parse::PMFile::_version_from_meta_ok(@_) }
Subroutine _version_from_meta_ok: called CC=1 SCAR=0.0
311 68 ▶sub _verbose { Parse::PMFile::_verbose(@_) }
Subroutine _verbose: called CC=1 SCAR=0.0
312 0 ▶sub _perm_check { Parse::PMFile::_perm_check(@_) }
Subroutine _perm_check: not called CC=1 SCAR=6.9
313  
314 # instead of ExtUtils::Manifest::manifind()
315 # which only looks for files under the current directory.
316 # We also need to look at MANIFEST/MANIFEST.SKIP here because
317 # unwanted files are not excluded yet.
318 # If we have MANIFEST, assume it's up-to-date and lists everything
319 # we need. If we have only MANIFEST.SKIP, then look for files
320 # and discard the matched.
321 20 ▶sub _find_files {
Subroutine _find_files: called CC=2 SCAR=6.9
322 20 my $self = shift;
323  
324 20 my @files = $self->_find_files_from_manifest;
325 20 ▶ return sort @files if @files;
Branch: 1 branch
BranchTrueFalseTotal
if @files 8 12 20
326  
327 12 my $skip = $self->_prepare_skip;
328  
329 12 my $root = $self->{DISTROOT};
330 56 ▶ my $wanted = sub {
Subroutine __ANON__: called CC=5 SCAR=16.1
331 56 my $name = $File::Find::name;
332 56 ▶ return if -d $_;
Branch: 1 branch
BranchTrueFalseTotal
if -d $_ 28 28 56
333 28 ▶ return if $name =~ m!/(?:\.(?:svn|git)|blib)/!; # too common
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ m[/(?:\.(?:svn|git)|blib)/] 0 28 28
334 28 my $rel = File::Spec->abs2rel($name, $root);
335 28 $rel =~ s|\\|/|g;
336 28 ▶ return if $skip && $skip->($rel);
Branch: 1 branch
BranchTrueFalseTotal
if $skip and &$skip($rel) 4 24 28
Condition100%3/3
$skip and &$skip($rel)
!ll&&!rl&&r
1684
MC/DC100%2/2
$skip and &$skip($rel)
$skip &$skip($rel)
Truth table100%3/3
A and B
A= $skipB= &$skip($rel)
ABresult
0X0
100
111
337 24 push @files, "./$rel";
338 12 };
339  
340 12 File::Find::find(
341 {wanted => $wanted, follow => 0, no_chdir => 1}, $root
342 );
343  
344 12 return sort @files;
345 }
346  
347 # adapted from ExtUtils::Manifest::maniread
348 20 ▶sub _find_files_from_manifest {
Subroutine _find_files_from_manifest: called CC=7 SCAR=19.8
349 20 my $self = shift;
350 20 my $root = $self->{DISTROOT};
351 20 my $manifile = "$root/MANIFEST";
352 20 ▶ return unless -f $manifile;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $manifile 12 8 20
353  
354 8 my %files;
355 8 ▶ open my $fh, '<', $manifile or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $manifile or return 8 0 8
356 8 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 80 8 88
357 80 ▶ next if /^\s*#/;
Branch: 1 branch
BranchTrueFalseTotal
if /^\s*#/ 0 80 80
358 80 chomp;
359 80 my ($file, $comment);
360 80 ▶ if (($file, $comment) = /^'(\\[\\']|.+)+'\s*(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = /^'(\\[\\']|.+)+'\s*(.*)/) { } 0 80 80
361 0 $file =~ s/\\([\\'])/$1/g;
362 }
363 else {
364 80 ($file, $comment) = /^(\S+)\s*(.*)/;
365 }
366 80 ▶ next unless $file;
Branch: 1 branch
BranchTrueFalseTotal
unless $file 0 80 80
367 80 $files{"./$file"} = $comment;
368 }
369 8 sort keys %files;
370 }
371  
372 # adapted from ExtUtils::Manifest::maniskip
373 12 ▶sub _prepare_skip {
Subroutine _prepare_skip: called CC=8 SCAR=21.7
374 12 my $self = shift;
375 12 my $root = $self->{DISTROOT};
376 12 my $skipfile = "$root/MANIFEST.SKIP";
377 12 ▶ return unless -f $skipfile;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $skipfile 8 4 12
378  
379 4 my @skip;
380 4 ▶ open my $fh, '<', $skipfile or return;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $skipfile or return 4 0 4
381 4 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 4 4 8
382 4 chomp;
383 4 s/\r//;
384 4 m{^\s*(?:(?:'([^\\']*(?:\\.[^\\']*)*)')|([^#\s]\S*))?(?:(?:\s*)|(?:\s+(.*?)\s*))$};
385 4 my $filename = $2;
386 4 ▶ if ( defined($1) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $1) 0 4 4
387 0 $filename = $1;
388 0 $filename =~ s/\\(['\\])/$1/g;
389 }
390 4 ▶ next if not defined($filename) or not $filename;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $filename and $filename 0 4 4
Condition33%1/3
defined $filename and $filename
!ll&&!rl&&r
004
MC/DC0%0/2
defined $filename and $filename
defined $filename $filename
Truth table33%1/3
A and B
A= defined $filenameB= $filename
ABresult
0X0
100
111
391 4 push @skip, $filename;
392 }
393 4 ▶ return unless @skip;
Branch: 1 branch
BranchTrueFalseTotal
unless @skip 0 4 4
394 4 my $re = join '|', map "(?:$_)", @skip;
395  
396 4 ▶ return sub {$_[0] =~ /$re/};
Subroutine __ANON__: called CC=1 SCAR=0.0
397 }
398  
399 13 1;
400  
401 __END__
↑ Summary