File Coverage

blib/lib/Dist/Zilla/Plugin/ManifestSkip.pm
Criterion Covered Total %
statement 34 34 100.0
branch 6 6 100.0
condition 2 3 66.6
subroutine 4 4 100.0
pod 0 1 0.0
total 46 48 95.8


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::ManifestSkip 6.037;
2             # ABSTRACT: decline to build files that appear in a MANIFEST.SKIP-like file
3              
4 10     10   8158 use Moose;
  10         24  
  10         120  
5             with 'Dist::Zilla::Role::FilePruner';
6              
7 10     10   70148 use Dist::Zilla::Pragmas;
  10         22  
  10         93  
8              
9 10     10   67 use namespace::autoclean;
  10         20  
  10         96  
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             has skipfile => (is => 'ro', required => 1, default => 'MANIFEST.SKIP');
37              
38             sub prune_files {
39 11     11 0 40 my ($self) = @_;
40 11         494 my $files = $self->zilla->files;
41              
42 11         485 my $skipfile_name = $self->skipfile;
43 11         43 my ($skipfile) = grep { $_->name eq $skipfile_name } @$files;
  101         276  
44 11 100       49 unless (defined $skipfile) {
45 8         92 $self->log_debug([ 'file %s not found', $skipfile_name ]);
46 8         912 return;
47             }
48              
49 3         18 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         7 my $fh;
55 3 100 66     169 if (! -f $skipfile_name || (-s $skipfile_name) != length($content)) {
56 1         18 $fh = File::Temp->new;
57 1         1158 $skipfile_name = $fh->filename;
58 1         19 $self->log_debug([ 'create temporary %s', $skipfile_name ]);
59 1         57 print $fh $content;
60 1         100 close $fh;
61             }
62              
63 3         769 require ExtUtils::Manifest;
64 3         8355 ExtUtils::Manifest->VERSION('1.54');
65              
66 3         22 my $skip = ExtUtils::Manifest::maniskip($skipfile_name);
67              
68             # Copy list (break reference) so we can mutate.
69 3         792 for my $file ((), @{ $files }) {
  3         11  
70 19 100       162 next unless $skip->($file->name);
71              
72 9         304 $self->log_debug([ 'pruning %s', $file->name ]);
73              
74 9         679 $self->zilla->prune_file($file);
75             }
76              
77 3         81 return;
78             }
79              
80             __PACKAGE__->meta->make_immutable;
81             1;
82              
83             __END__
84              
85             =pod
86              
87             =encoding UTF-8
88              
89             =head1 NAME
90              
91             Dist::Zilla::Plugin::ManifestSkip - decline to build files that appear in a MANIFEST.SKIP-like file
92              
93             =head1 VERSION
94              
95             version 6.037
96              
97             =head1 DESCRIPTION
98              
99             This plugin reads a MANIFEST.SKIP-like file, as used by L<ExtUtils::MakeMaker>
100             and L<ExtUtils::Manifest>, and prunes any files that it declares should be
101             skipped.
102              
103             This plugin is included in the L<@Basic|Dist::Zilla::PluginBundle::Basic>
104             bundle.
105              
106             =head1 PERL VERSION
107              
108             This module should work on any version of perl still receiving updates from
109             the Perl 5 Porters. This means it should work on any version of perl
110             released in the last two to three years. (That is, if the most recently
111             released version is v5.40, then this module should work on both v5.40 and
112             v5.38.)
113              
114             Although it may work on older versions of perl, no guarantee is made that the
115             minimum required version will not be increased. The version may be increased
116             for any reason, and there is no promise that patches will be accepted to
117             lower the minimum required perl.
118              
119             =head1 ATTRIBUTES
120              
121             =head2 skipfile
122              
123             This is the name of the file to read for MANIFEST.SKIP-like content. It
124             defaults, unsurprisingly, to F<MANIFEST.SKIP>.
125              
126             =head1 SEE ALSO
127              
128             Dist::Zilla core plugins:
129             L<@Basic|Dist::Zilla::PluginBundle::Basic>,
130             L<PruneCruft|Dist::Zilla::Plugin::PruneCruft>,
131             L<PruneFiles|Dist::Zilla::Plugin::PruneFiles>.
132              
133             Other modules: L<ExtUtils::Manifest>.
134              
135             =head1 AUTHOR
136              
137             Ricardo SIGNES 😏 <cpan@semiotic.systems>
138              
139             =head1 COPYRIGHT AND LICENSE
140              
141             This software is copyright (c) 2026 by Ricardo SIGNES.
142              
143             This is free software; you can redistribute it and/or modify it under
144             the same terms as the Perl 5 programming language system itself.
145              
146             =cut