blib/lib/Dist/Zilla/Plugin/ManifestSkip.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 6 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 94.4% 51 / 54 CC 6 SCAR 14.7
CC
6
Cov
98%
prune_files
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.3
« blib/lib/Dist/Zilla/Plugin/Encoding.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/GatherDir.pm »
1 package Dist::Zilla::Plugin::ManifestSkip 6.040;
2 # ABSTRACT: decline to build files that appear in a MANIFEST.SKIP-like file
3  
4 10 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 with 'Dist::Zilla::Role::FilePruner';
6  
7 10 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #pod =head1 DESCRIPTION
12 #pod
13 #pod This plugin reads a MANIFEST.SKIP-like file, as used by L<ExtUtils::MakeMaker>
14 #pod and L<ExtUtils::Manifest>, and prunes any files that it declares should be
15 #pod skipped.
16 #pod
17 #pod This plugin is included in the L<@Basic|Dist::Zilla::PluginBundle::Basic>
18 #pod bundle.
19 #pod
20 #pod =attr skipfile
21 #pod
22 #pod This is the name of the file to read for MANIFEST.SKIP-like content. It
23 #pod defaults, unsurprisingly, to F<MANIFEST.SKIP>.
24 #pod
25 #pod =head1 SEE ALSO
26 #pod
27 #pod Dist::Zilla core plugins:
28 #pod L<@Basic|Dist::Zilla::PluginBundle::Basic>,
29 #pod L<PruneCruft|Dist::Zilla::Plugin::PruneCruft>,
30 #pod L<PruneFiles|Dist::Zilla::Plugin::PruneFiles>.
31 #pod
32 #pod Other modules: L<ExtUtils::Manifest>.
33 #pod
34 #pod =cut
35  
36 10 has skipfile => (is => 'ro', required => 1, default => 'MANIFEST.SKIP');
37  
38 11 ▶sub prune_files {
Subroutine prune_files: called CC=6 SCAR=17.9
Pod undocumented
39 11 my ($self) = @_;
40 11 my $files = $self->zilla->files;
41  
42 11 my $skipfile_name = $self->skipfile;
43 11 my ($skipfile) = grep { $_->name eq $skipfile_name } @$files;
44 11 ▶ unless (defined $skipfile) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $skipfile) 8 3 11
45 8 $self->log_debug([ 'file %s not found', $skipfile_name ]);
46 8 return;
47 }
48  
49 3 my $content = $skipfile->content;
50  
51 # If the content has been generated in memory or changed from disk,
52 # create a temp file with the content.
53 # (Unfortunately maniskip can't read from a string ref)
54 3 my $fh;
55 3 ▶ if (! -f $skipfile_name || (-s $skipfile_name) != length($content)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -f $skipfile_name or -s $skipfile_name != length $content) 1 2 3
Condition66%2/3
not -f $skipfile_name or -s $skipfile_name != length $content
l!l&&r!l&&!r
102
MC/DC50%1/2
not -f $skipfile_name or -s $skipfile_name != length $content
not -f $skipfile_name -s $skipfile_name != length $content
Truth table66%2/3
not(A) or B
A= not -f $skipfile_nameB= -s $skipfile_name != length $content
ABresult
1X1
011
000
56 1 $fh = File::Temp->new;
57 1 $skipfile_name = $fh->filename;
58 1 $self->log_debug([ 'create temporary %s', $skipfile_name ]);
59 1 print $fh $content;
60 1 close $fh;
61 }
62  
63 3 require ExtUtils::Manifest;
64 3 ExtUtils::Manifest->VERSION('1.54');
65  
66 3 my $skip = ExtUtils::Manifest::maniskip($skipfile_name);
67  
68 # Copy list (break reference) so we can mutate.
69 3 for my $file ((), @{ $files }) {
70 19 ▶ next unless $skip->($file->name);
Branch: 1 branch
BranchTrueFalseTotal
unless &$skip($file->name) 10 9 19
71  
72 9 $self->log_debug([ 'pruning %s', $file->name ]);
73  
74 9 $self->zilla->prune_file($file);
75 }
76  
77 3 return;
78 }
79  
80 10 __PACKAGE__->meta->make_immutable;
81 10 1;
82  
83 __END__
« blib/lib/Dist/Zilla/Plugin/Encoding.pm ↑ Summary blib/lib/Dist/Zilla/Plugin/GatherDir.pm »