blib/lib/Dist/Zilla/Plugin/Manifest/Read.pm

filter: Statementstmt 98.5% 138 / 140 Branchbran 91.6% 22 / 24 Conditioncond 60.0% 15 / 25 MC/DCmcdc 16.6% 2 / 12 Subroutinesub 100% 21 / 21 Podpod 100% 3 / 3 totaltotal 89.3% 201 / 225 CC 24 SCAR 16.4
CC
24
Cov
93%
_build_manifest_bulk
10.3
_parse_lines
9.0
__ANON__
3.8
CRAP 5.2
↑ Summary
1 # ---------------------------------------------------------------------- copyright and license ---
2 #
3 # file: lib/Dist/Zilla/Plugin/Manifest/Read.pm
4 #
5 # Copyright © 2015, 2016 Van de Bugger.
6 #
7 # This file is part of perl-Dist-Zilla-Plugin-Manifest-Read.
8 #
9 # perl-Dist-Zilla-Plugin-Manifest-Read is free software: you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by the Free Software Foundation,
11 # either version 3 of the License, or (at your option) any later version.
12 #
13 # perl-Dist-Zilla-Plugin-Manifest-Read is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
15 # PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License along with
18 # perl-Dist-Zilla-Plugin-Manifest-Read. If not, see <http://www.gnu.org/licenses/>.
19 #
20 # ---------------------------------------------------------------------- copyright and license ---
21  
22 #pod =for :this This is C<Dist::Zilla::Plugin::Manifest::Read> module documentation. Read this if you are going to hack or
23 #pod extend C<Manifest::Read>, or use it programmatically.
24 #pod
25 #pod =for :those If you want to have annotated source manifest, read the L<user manual|Dist::Zilla::Plugin::Manifest::Read::Manual>.
26 #pod General topics like getting source, building, installing, bug reporting and some others are covered
27 #pod in the F<README>.
28 #pod
29 #pod =for test_synopsis my $self;
30 #pod
31 #pod =head1 SYNOPSIS
32 #pod
33 #pod In your plugin:
34 #pod
35 #pod # Iterate through the distribution files listed in MANIFEST:
36 #pod my $finder = $self->zilla->plugin_named( 'Manifest::Read/:AllFiles' );
37 #pod for my $file ( @{ $finder->find_files() } ) {
38 #pod ...
39 #pod };
40 #pod
41 #pod =head1 DESCRIPTION
42 #pod
43 #pod This class consumes L<Dist::Zilla::Role::FileGatherer> and C<Dist::Zilla::Role::FileFinder> roles.
44 #pod In order to fulfill requirements, the class implements C<gather_files> and C<find_files> methods.
45 #pod Other methods are supporting.
46 #pod
47 #pod The class also consumes L<Dist::Zilla::Role::ErrorLogger> role. It allows the class not to stop
48 #pod at the first problem but continue and report multiple errors to user.
49 #pod
50 #pod =cut
51  
52 # --------------------------------------------------------------------------------------------------
53  
54 package Dist::Zilla::Plugin::Manifest::Read;
55  
56 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 2 ▶use version 0.77;
Subroutine BEGIN: called CC=1 SCAR=0.0
59  
60 # ABSTRACT: Read annotated source manifest
61 2 our $VERSION = 'v0.5.0'; # VERSION
62  
63 2 with 'Dist::Zilla::Role::FileGatherer';
64 2 with 'Dist::Zilla::Role::FileFinder';
65 2 with 'Dist::Zilla::Role::ErrorLogger' => { -version => 0.006 }; # need log_errors_in_file
66  
67 2 ▶use Dist::Zilla::File::OnDisk;
Subroutine BEGIN: called CC=1 SCAR=0.0
68 2 ▶use List::Util qw{ min max };
Subroutine BEGIN: called CC=1 SCAR=0.0
69 2 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
70 2 ▶use Set::Object qw{ set };
Subroutine BEGIN: called CC=1 SCAR=0.0
71 2 ▶use Try::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
72  
73 # --------------------------------------------------------------------------------------------------
74  
75 #pod =attr manifest_name
76 #pod
77 #pod Name of manifest file to read.
78 #pod
79 #pod C<Str>, read-only, default value is C<MANIFEST>, C<init_arg> is C<manifest>.
80 #pod
81 #pod =cut
82  
83 2 has manifest_name => (
84 isa => 'Str',
85 is => 'ro',
86 default => 'MANIFEST',
87 init_arg => 'manifest',
88 );
89  
90 # --------------------------------------------------------------------------------------------------
91  
92 #pod =attr manifest_file
93 #pod
94 #pod Manifest file as a C<Dist::Zilla> file object (C<Dist::Zilla::File::OnDisk>).
95 #pod
96 #pod C<Object>, read-only.
97 #pod
98 #pod =cut
99  
100 2 has manifest_file => (
101 isa => 'Dist::Zilla::File::OnDisk',
102 is => 'ro',
103 lazy => 1,
104 builder => '_build_manifest_file',
105 init_arg => undef,
106 );
107  
108 7 ▶sub _build_manifest_file {
Subroutine _build_manifest_file: called CC=1 SCAR=0.0
109 7 my ( $self ) = @_;
110 # Straightforward appoach
111 # path( $self->manifest_name )
112 # is incorrect: it works only if the root directory is the current one, which is not always
113 # true. Following expression for manifest path is correct, but gives absolute (and often too
114 # long) name:
115 # path( $self->zilla->root )->child( $self->manifest )
116 # Let's try to shorten it. Hope this works:
117 # path( $self->zilla->root )->child( $self->manifest )->relative
118 # ...until someone changes the current directory...
119 7 return Dist::Zilla::File::OnDisk->new( {
120 name => path( $self->zilla->root )->child( $self->manifest_name )->relative . '',
121 } );
122 };
123  
124 # --------------------------------------------------------------------------------------------------
125  
126 #pod =method BUILD
127 #pod
128 #pod This method creates bunch of file finders: C<Manifest::Read/:AllFiles>, C<Manifest::Read/:ExecFiles>, C<Manifest::Read/:ExtraTestFiles>, C<Manifest::Read/:IncModules>, C<Manifest::Read/:InstallModules>, C<Manifest::Read/:NoFiles>, C<Manifest::Read/:PerlExecFiles>, C<Manifest::Read/:ShareFiles>, C<Manifest::Read/:TestFiles>.
129 #pod
130 #pod =cut
131  
132 7 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=7.0
Pod documented
133 7 my ( $self ) = @_;
134 7 require Dist::Zilla::Plugin::FinderCode;
135 7 my $parent = $self;
136 7 my $zilla = $self->zilla;
137 7 my @finders = qw{ :AllFiles :ExecFiles :ExtraTestFiles :IncModules :InstallModules :NoFiles :PerlExecFiles :ShareFiles :TestFiles };
138 7 for my $name ( @finders ) {
139 my $finder = Dist::Zilla::Plugin::FinderCode->new( {
140 plugin_name => $parent->plugin_name . '/' . $name,
141 zilla => $zilla,
142 style => 'list',
143 11 ▶ code => sub {
Subroutine __ANON__: called CC=3 SCAR=11.6
144 11 my ( $self ) = @_;
145 11 my $plugin = $self->zilla->plugin_named( $name );
146 11 ▶ if ( not defined( $plugin ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $plugin) 0 11 11
147 0 $parent->abort( [ "Can't find plugin %s", $name ] );
148 };
149 11 ▶ my $files = $parent->_incl_file_set * set( @{ $plugin->find_files() // [] } );
Condition50%1/2
$plugin->find_files // []
l!l
110
MC/DC0%0/1
$plugin->find_files // []
$plugin->find_files
Truth table50%1/2
A
A= $plugin->find_files
Aresult
11
00
150 # `:NoFiles` in `Dist::Zilla` 6.008 returns `undef`, not `[]`. ^^^^^
151 11 return [ $files->members ];
152 },
153 63 } );
154 # Let's provide old finder names for compatibility:
155 # TODO: Drop it in one or two releases.
156 my $compat = Dist::Zilla::Plugin::FinderCode->new( {
157 63 plugin_name => do { $_ = $finder->plugin_name; $_ =~ s{/:}{/}x; $_ },
158 zilla => $finder->zilla,
159 style => $finder->style,
160 code => $finder->code,
161 } );
162 63 push( @{ $zilla->plugins }, $finder, $compat );
163 };
164 7 return;
165 };
166  
167 # --------------------------------------------------------------------------------------------------
168  
169 #pod =method gather_files
170 #pod
171 #pod This method fulfills L<Dist::Zilla::Role::FileGatherer> role requirement. It adds files listed in
172 #pod manifest to distribution. Files marked to exclude from distribution and directories are not added.
173 #pod
174 #pod =cut
175  
176 7 ▶sub gather_files {
Subroutine gather_files: called CC=2 SCAR=6.9
Pod documented
177 7 my ( $self ) = @_;
178 7 for my $file ( $self->_incl_file_set->members ) {
179 47 $self->add_file( $file );
180 };
181 4 return;
182 };
183  
184 # --------------------------------------------------------------------------------------------------
185  
186 #pod =method find_files
187 #pod
188 #pod This method fulfills L<Dist::Zilla::Role::FileFinder> role requirement. It returns the I<complete>
189 #pod list (strictly speaking, arrayref) of files read from the manifest, in order of appearance.
190 #pod
191 #pod Note: The list includes files which are I<not> added to the distribution.
192 #pod
193 #pod Note: The method always returns the same list of files. Plugins which remove files from
194 #pod distribution (i. e. plugins which do C<Dist::Zilla::Role::FilePruner> role) do not affect result of
195 #pod the method.
196 #pod
197 #pod If you are interested in distribution files, have look to file finders generated by C<BUILD>.
198 #pod
199 #pod =cut
200  
201 2 has _complete_file_list => (
202 isa => 'ArrayRef',
203 is => 'ro',
204 lazy => 1,
205 builder => '_build_complete_file_list',
206 );
207  
208 4 ▶sub _build_complete_file_list {
Subroutine _build_complete_file_list: called CC=1 SCAR=0.0
209 4 my ( $self ) = @_;
210 return [
211 map(
212 53 { $_->{ file } }
213 sort(
214 172 { $a->{ line } <=> $b->{ line } }
215 4 values( %{ $self->_manifest_bulk } )
216 )
217 )
218 ];
219 };
220  
221 4 ▶sub find_files {
Subroutine find_files: called CC=1 SCAR=0.0
Pod documented
222 4 my ( $self ) = @_;
223 4 return [ @{ $self->_complete_file_list } ];
224 };
225  
226 # --------------------------------------------------------------------------------------------------
227  
228 #pod =attr _incl_file_set
229 #pod
230 #pod Set of files (object which do C<Dist::Zilla::Role::File> role) listed in the manifest I<and> marked
231 #pod for inclusion to the distribution.
232 #pod
233 #pod =cut
234  
235 2 has _incl_file_set => (
236 isa => 'Set::Object',
237 is => 'ro',
238 lazy => 1,
239 builder => '_build_incl_file_set',
240 init_arg => undef,
241 );
242  
243 7 ▶sub _build_incl_file_set {
Subroutine _build_incl_file_set: called CC=1 SCAR=0.0
244 7 my ( $self ) = @_;
245 7 my $m = $self->_manifest_bulk;
246 4 return set( map( { $_->{ file } } grep( { $_->{ mark } ne '-' } values( %$m ) ) ));
247 };
248  
249 # --------------------------------------------------------------------------------------------------
250  
251 #pod =attr _manifest_bulk
252 #pod
253 #pod Parsed manifest. HashRef. Keys are file names, values are HashRefs to inner hashes. Each inner hash
254 #pod has keys and associated values:
255 #pod
256 #pod =for :list
257 #pod = name
258 #pod Parsed filename (single-quoted filenames are unquoted, escape sequences are evaluated, if any).
259 #pod = file
260 #pod Object which does C<Dist::Zilla::Role::File> role.
261 #pod = mark
262 #pod Mark.
263 #pod = comment
264 #pod File comment, leading and trailing whitespaces are stripped.
265 #pod = line
266 #pod Number of manifest line the file listed in.
267 #pod
268 #pod C<HasfRef>, read-only, lazy, initialized with builder.
269 #pod
270 #pod =cut
271  
272 2 has _manifest_bulk => (
273 isa => 'HashRef[HashRef]',
274 is => 'ro',
275 lazy => 1,
276 builder => '_build_manifest_bulk',
277 init_arg => undef,
278 );
279  
280 7 ▶sub _build_manifest_bulk {
Subroutine _build_manifest_bulk: called CC=10 SCAR=23.3
281 7 my ( $self ) = @_;
282 7 my $items = {};
283 7 my @errors;
284 6 ▶ my $error = sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
285 6 my ( $item, $message ) = @_;
286 my $err = sprintf(
287 '%s %s at %s line %d.',
288 $item->{ name }, $message, $self->manifest_name, $item->{ line },
289 6 );
290 6 push( @errors, $item->{ line } => $err );
291 6 return $self->log_error( $err );
292 7 };
293 7 foreach my $item ( $self->_parse_lines() ) {
294 60 ▶ -e $item->{ name } or $error->( $item, 'does not exist' ) and next;
Branch: 1 branch
BranchTrueFalseTotal
-e $item->{"name"} or &$error($item, "does not exist") and next 56 4 60
Condition60%3/5
-e $item->{'name'} || &$error($item, 'does not exist') && (next)
l!l&&r!l&&!r
5640
&$error($item, "does not exist") and next
!ll
04
MC/DC0%0/2
-e $item->{'name'} || &$error($item, 'does not exist') && (next)
-e $item->{'name'} &$error($item, "does not exist")
Truth table66%2/3
A || B
A= -e $item->{'name'}B= &$error($item, "does not exist")
ABresult
1X1
011
000
295 56 ▶ if ( $item->{ mark } eq '/' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item->{'mark'} eq '/') { } 2 54 56
296 2 ▶ -d _ or $error->( $item, 'is not a directory' ) and next;
Branch: 1 branch
BranchTrueFalseTotal
-d _ or &$error($item, "is not a directory") and next 1 1 2
Condition60%3/5
-d _ || &$error($item, 'is not a directory') && (next)
l!l&&r!l&&!r
110
&$error($item, "is not a directory") and next
!ll
01
MC/DC0%0/2
-d _ || &$error($item, 'is not a directory') && (next)
-d _ &$error($item, "is not a directory")
Truth table66%2/3
A || B
A= -d _B= &$error($item, "is not a directory")
ABresult
1X1
011
000
297 } else {
298 54 ▶ -f _ or $error->( $item, 'is not a plain file' ) and next;
Branch: 1 branch
BranchTrueFalseTotal
-f _ or &$error($item, "is not a plain file") and next 53 1 54
Condition60%3/5
-f _ || &$error($item, 'is not a plain file') && (next)
l!l&&r!l&&!r
5310
&$error($item, "is not a plain file") and next
!ll
01
MC/DC0%0/2
-f _ || &$error($item, 'is not a plain file') && (next)
-f _ &$error($item, "is not a plain file")
Truth table66%2/3
A || B
A= -f _B= &$error($item, "is not a plain file")
ABresult
1X1
011
000
299 53 $item->{ file } = Dist::Zilla::File::OnDisk->new( { name => $item->{ name } } );
300 53 $items->{ $item->{ name } } = $item;
301 };
302 };
303 5 ▶ if ( @errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors) 1 4 5
304 1 $self->log_errors_in_file( $self->manifest_file, @errors );
305 };
306 5 $self->abort_if_error();
307 4 return $items;
308 };
309  
310 # --------------------------------------------------------------------------------------------------
311  
312 #pod =attr _manifest_lines
313 #pod
314 #pod Array of chomped manifest lines, including comments and empty lines.
315 #pod
316 #pod C<ArrayRef[Str]>, read-only, lazy, initialized with builder.
317 #pod
318 #pod =cut
319  
320 2 has _manifest_lines => (
321 isa => 'ArrayRef[Str]',
322 is => 'ro',
323 lazy => 1,
324 init_arg => undef,
325 builder => '_build_manifest_lines',
326 );
327  
328 7 ▶sub _build_manifest_lines {
Subroutine _build_manifest_lines: called CC=1 SCAR=0.2
329 7 my ( $self ) = @_;
330 7 my $lines = [];
331 7 ▶ try {
Subroutine __ANON__: called CC=1 SCAR=0.0
332 7 @$lines = split( "\n", $self->manifest_file->content );
333 1 ▶ } catch {
Subroutine __ANON__: called CC=3 SCAR=13.3
334 1 my $ex = $_;
335 1 ▶ if ( blessed( $ex ) and $ex->isa( 'Path::Tiny::Error' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($ex) and $ex->isa('Path::Tiny::Error')) { } 1 0 1
Condition33%1/3
builtin::blessed($ex) and $ex->isa("Path::Tiny::Error")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($ex) and $ex->isa("Path::Tiny::Error")
builtin::blessed($ex) $ex->isa("Path::Tiny::Error")
Truth table33%1/3
A and B
A= builtin::blessed($ex)B= $ex->isa("Path::Tiny::Error")
ABresult
0X0
100
111
336 1 $self->abort( [ '%s: %s', $ex->{ file }, $ex->{ err } ] );
337 } else {
338 0 $self->abort( "$ex" );
339 };
340 7 };
341 6 chomp( @$lines );
342 6 return $lines;
343 };
344  
345 # --------------------------------------------------------------------------------------------------
346  
347 #pod =method _parse_lines
348 #pod
349 #pod This method parses manifest lines. Each line is parsed separately (there is no line continuation).
350 #pod
351 #pod If the method fails to parse a line, error is reported by calling method C<log_error> (implemented
352 #pod in L<Dist::Zilla::Role::ErrorLogger>). This means that parsing is not stopped at the first failure,
353 #pod but entire manifest will be parsed and all the found errors will be reported.
354 #pod
355 #pod The method returns list of hashrefs, a hash per file. Each hash has following keys and values:
356 #pod
357 #pod =for :list
358 #pod = name
359 #pod Parsed filename (single-quoted filenames are unquoted, escape sequences are evaluated, if any).
360 #pod = mark
361 #pod Mark.
362 #pod = comment
363 #pod File comment, leading and trailing whitespaces are stripped.
364 #pod = line
365 #pod Number of manifest line (one-based) the file is listed in.
366 #pod
367 #pod =cut
368  
369 2 my %RE = (
370 name => qr{ ' (*PRUNE) (?: [^'\\] ++ | \\ ['\\] ?+ ) ++ ' | \S ++ }x,
371 # ^ TODO: Use Regexp::Common for quoted filename?
372 mark => qr{ [#/+-] }x,
373 comment => qr{ . *? }x,
374 );
375  
376 7 ▶sub _parse_lines {
Subroutine _parse_lines: called CC=9 SCAR=22.0
377 7 my ( $self ) = @_;
378 7 my $manifest = $self->manifest_name; # Shorter name.
379 7 my ( %files, @files );
380 7 my @errors;
381 7 my $n = 0;
382 7 for my $line ( @{ $self->_manifest_lines } ) {
383 75 ++ $n;
384 75 ▶ if ( $line =~ m{ \A \s * (?: \# | \z ) }x ) { # Comment or empty line.
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ / \A \s * (?: \# | \z ) /x) 9 66 75
385 9 next;
386 };
387 ## no critic ( ProhibitComplexRegexes )
388 $line =~ m{
389 \A
390 \s *+ # requires perl v5.10
391 ( $RE{ name } )
392 (*PRUNE) # requires perl v5.10
393 (?:
394 \s ++
395 ( $RE{ mark } )
396 (*PRUNE)
397 (?:
398 \s ++
399 ( $RE{ comment } )
400 ) ?
401 ) ?
402 \s *
403 \z
404 }x and do {
405 63 my ( $name, $mark, $comment ) = ( $1, $2, $3 );
406 63 ▶ if ( $name =~ s{ \A ' ( . * ) ' \z }{ $1 }ex ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) 15 48 63
407 15 $name =~ s{ \\ ( ['\\] ) }{ $1 }gex;
408 };
409 63 ▶ if ( exists( $files{ $name } ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $files{$name}) 2 61 63
410 2 my $f = $files{ $name };
411 2 $self->log_error( [ '%s at %s line %d', $name, $manifest, $n ] );
412 2 $self->log_error( [ ' also listed at %s line %d.', $manifest, $f->{ line } ] );
413 push( @errors,
414 $n => 'The file also listed at line ' . $f->{ line } . '.',
415 2 $f->{ line } => 'The file also listed at line ' . $n . '.',
416 );
417 2 next;
418 };
419 61 ▶ my $file = {
Condition100%2/2
$mark // "+"
l!l
4813
MC/DC100%1/1
$mark // "+"
$mark
Truth table100%2/2
A
A= $mark
Aresult
11
00
420 name => $name,
421 mark => $mark // '+', # requires perl v5.10
422 comment => $comment,
423 line => $n,
424 };
425 61 $files{ $name } = $file;
426 61 push( @files, $file );
427 61 1;
428 66 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
$line =~ / \A \s *+ # requires perl v5.10 ( $RE{"name"} ) (*PRUNE) # requires perl v5.10 (?: \s ++ ( $RE{"mark"} ) (*PRUNE) (?: \s ++ ( $RE{"comment"} ) ) ? ) ? \s * \z /x and do { () = ($1, $2, $3); if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) { $name =~ s/ \\ ( ['\\] ) /$1;/egx; } ; if (exists $files{$name}) { my $f = $files{$name}; $self->log_error(["%s at %s line %d", $name, $manifest, $n]); $self->log_error([" also listed at %s line %d.", $manifest, $f->{"line"}]); push @errors, $n, 'The file also listed at line ' . $f->{"line"} . '.', $f->{"line"}, 'The file also listed at line ' . $n . '.'; next; } ; my $file = {"name", $name, "mark", $mark // "+", "comment", $comment, "line", $n}; $files{$name} = $file; push @files, $file; 1 } or do { my $error = sprintf("Syntax error at %s line %d.", $manifest, $n); $self->log_error($error); push @errors, $n, $error; next } 61 3 64
Condition66%2/3
$line =~ / \A \s *+ # requires perl v5.10 ( $RE{"name"} ) (*PRUNE) # requires perl v5.10 (?: \s ++ ( $RE{"mark"} ) (*PRUNE) (?: \s ++ ( $RE{"comment"} ) ) ? ) ? \s * \z /x and do { () = ($1, $2, $3); if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) { $name =~ s/ \\ ( ['\\] ) /$1;/egx; } ; if (exists $files{$name}) { my $f = $files{$name}; $self->log_error(["%s at %s line %d", $name, $manifest, $n]); $self->log_error([" also listed at %s line %d.", $manifest, $f->{"line"}]); push @errors, $n, 'The file also listed at line ' . $f->{"line"} . '.', $f->{"line"}, 'The file also listed at line ' . $n . '.'; next; } ; my $file = {"name", $name, "mark", $mark // "+", "comment", $comment, "line", $n}; $files{$name} = $file; push @files, $file; 1 }
!ll&&!rl&&r
3063
MC/DC50%1/2
$line =~ / \A \s *+ # requires perl v5.10 ( $RE{"name"} ) (*PRUNE) # requires perl v5.10 (?: \s ++ ( $RE{"mark"} ) (*PRUNE) (?: \s ++ ( $RE{"comment"} ) ) ? ) ? \s * \z /x and do { () = ($1, $2, $3); if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) { $name =~ s/ \\ ( ['\\] ) /$1;/egx; } ; if (exists $files{$name}) { my $f = $files{$name}; $self->log_error(["%s at %s line %d", $name, $manifest, $n]); $self->log_error([" also listed at %s line %d.", $manifest, $f->{"line"}]); push @errors, $n, 'The file also listed at line ' . $f->{"line"} . '.', $f->{"line"}, 'The file also listed at line ' . $n . '.'; next; } ; my $file = {"name", $name, "mark", $mark // "+", "comment", $comment, "line", $n}; $files{$name} = $file; push @files, $file; 1 }
$line =~ / \A \s *+ # requires perl v5.10 ( $RE{"name"} ) (*PRUNE) # requires perl v5.10 (?: \s ++ ( $RE{"mark"} ) (*PRUNE) (?: \s ++ ( $RE{"comment"} ) ) ? ) ? \s * \z /x do { () = ($1, $2, $3); if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) { $name =~ s/ \\ ( ['\\] ) /$1;/egx; } ; if (exists $files{$name}) { my $f = $files{$name}; $self->log_error(["%s at %s line %d", $name, $manifest, $n]); $self->log_error([" also listed at %s line %d.", $manifest, $f->{"line"}]); push @errors, $n, 'The file also listed at line ' . $f->{"line"} . '.', $f->{"line"}, 'The file also listed at line ' . $n . '.'; next; } ; my $file = {"name", $name, "mark", $mark // "+", "comment", $comment, "line", $n}; $files{$name} = $file; push @files, $file; 1 }
Truth table66%2/3
A and B
A= $line =~ / \A \s *+ # requires perl v5.10 ( $RE{"name"} ) (*PRUNE) # requires perl v5.10 (?: \s ++ ( $RE{"mark"} ) (*PRUNE) (?: \s ++ ( $RE{"comment"} ) ) ? ) ? \s * \z /xB= do { () = ($1, $2, $3); if ($name =~ s/ \A ' ( . * ) ' \z /$1;/ex) { $name =~ s/ \\ ( ['\\] ) /$1;/egx; } ; if (exists $files{$name}) { my $f = $files{$name}; $self->log_error(["%s at %s line %d", $name, $manifest, $n]); $self->log_error([" also listed at %s line %d.", $manifest, $f->{"line"}]); push @errors, $n, 'The file also listed at line ' . $f->{"line"} . '.', $f->{"line"}, 'The file also listed at line ' . $n . '.'; next; } ; my $file = {"name", $name, "mark", $mark // "+", "comment", $comment, "line", $n}; $files{$name} = $file; push @files, $file; 1 }
ABresult
0X0
100
111
429 3 my $error = sprintf( 'Syntax error at %s line %d.', $manifest, $n );
430 3 $self->log_error( $error );
431 3 push( @errors, $n => $error );
432 3 next;
433 };
434 };
435 6 ▶ if ( @errors ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors) 1 5 6
436 1 $self->log_errors_in_file( $self->manifest_file, @errors );
437 1 $self->abort();
438 };
439 5 return @files;
440 };
441  
442 # --------------------------------------------------------------------------------------------------
443  
444 2 __PACKAGE__->meta->make_immutable;
445  
446 2 1;
447  
448 # --------------------------------------------------------------------------------------------------
449  
450 #pod =pod
451 #pod
452 #pod =encoding UTF-8
453 #pod
454 #pod =head1 WHAT?
455 #pod
456 #pod C<Dist-Zilla-Plugin-Manifest-Read> (or C<Manifest::Read> for brevity) is a C<Dist::Zilla> plugin. It reads
457 #pod I<annotated source> manifest, checks existence of all listed files and directories, and adds
458 #pod selected files to the distribution. C<Manifest::Read> also does C<FileFinder> role, providing the
459 #pod list of files for other plugins.
460 #pod
461 #pod =cut
462  
463  
464 #pod =head1 SEE ALSO
465 #pod
466 #pod =for :list
467 #pod = L<Dist::Zilla>
468 #pod = L<Dist::Zilla::Role::FileGatherer>
469 #pod = L<Dist::Zilla::Role::ErrorLogger>
470 #pod
471 #pod =head1 COPYRIGHT AND LICENSE
472 #pod
473 #pod Copyright (C) 2015, 2016 Van de Bugger
474 #pod
475 #pod License GPLv3+: The GNU General Public License version 3 or later
476 #pod <http://www.gnu.org/licenses/gpl-3.0.txt>.
477 #pod
478 #pod This is free software: you are free to change and redistribute it. There is
479 #pod NO WARRANTY, to the extent permitted by law.
480 #pod
481 #pod
482 #pod =cut
483  
484 # end of file #
485  
486 __END__
↑ Summary