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

filter: Statementstmt 100% 30 / 30 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 3 totaltotal 93.0% 40 / 43 CC 5 SCAR 9.8
CC
5
Cov
100%
prune_files
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« blib/lib/Dist/Zilla/App/Command/version.pm ↑ Summary blib/lib/Dist/Zilla/Role/TextTemplate.pm »
1 package Dist::Zilla::Plugin::PruneFiles 6.040;
2 # ABSTRACT: prune arbitrary files from the dist
3  
4 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 with 'Dist::Zilla::Role::FilePruner';
6  
7 2 ▶use Dist::Zilla::Pragmas;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 2 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #pod =head1 SYNOPSIS
12 #pod
13 #pod This plugin allows you to explicitly prune some files from your
14 #pod distribution. You can either specify the exact set of files (with the
15 #pod "filenames" parameter) or provide the regular expressions to
16 #pod check (using "match").
17 #pod
18 #pod This is useful if another plugin (maybe a FileGatherer) adds a
19 #pod bunch of files, and you only want a subset of them.
20 #pod
21 #pod In your F<dist.ini>:
22 #pod
23 #pod [PruneFiles]
24 #pod filename = xt/release/pod-coverage.t ; pod coverage tests are for jerks
25 #pod filename = todo-list.txt ; keep our secret plans to ourselves
26 #pod
27 #pod match = ^test_data/
28 #pod match = ^test.cvs$
29 #pod
30 #pod =cut
31  
32 3 ▶sub mvp_multivalue_args { qw(filenames matches) }
Subroutine mvp_multivalue_args: called CC=1 SCAR=0.0
Pod undocumented
33 3 ▶sub mvp_aliases { return { filename => 'filenames', match => 'matches' } }
Subroutine mvp_aliases: called CC=1 SCAR=0.0
Pod undocumented
34  
35 #pod =attr filenames
36 #pod
37 #pod This is an arrayref of filenames to be pruned from the distribution.
38 #pod
39 #pod =cut
40  
41 has filenames => (
42 is => 'ro',
43 isa => 'ArrayRef',
44 1 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
45 2 );
46  
47 #pod =attr matches
48 #pod
49 #pod This is an arrayref of regular expressions and files matching any of them,
50 #pod will be pruned from the distribution.
51 #pod
52 #pod =cut
53  
54 has matches => (
55 is => 'ro',
56 isa => 'ArrayRef',
57 2 ▶ default => sub { [] },
Subroutine __ANON__: called CC=1 SCAR=0.0
58 2 );
59  
60 3 ▶sub prune_files {
Subroutine prune_files: called CC=5 SCAR=16.1
Pod undocumented
61 3 my ($self) = @_;
62  
63 # never match (at least the filename characters)
64 3 my $matches_regex = qr/\000/;
65  
66 3 $matches_regex = qr/$matches_regex|$_/ for (@{ $self->matches });
67  
68 # \A\Q$_\E should also handle the `eq` check
69 3 $matches_regex = qr/$matches_regex|\A\Q$_\E/ for (@{ $self->filenames });
70  
71 # Copy list (break reference) so we can mutate.
72 3 for my $file ((), @{ $self->zilla->files }) {
73 9 ▶ next unless $file->name =~ $matches_regex;
Branch: 1 branch
BranchTrueFalseTotal
unless $file->name =~ /$matches_regex/u 5 4 9
74  
75 4 $self->log_debug([ 'pruning %s', $file->name ]);
76  
77 4 $self->zilla->prune_file($file);
78 }
79  
80 3 return;
81 }
82  
83 2 __PACKAGE__->meta->make_immutable;
84 2 1;
85  
86 #pod =head1 SEE ALSO
87 #pod
88 #pod Dist::Zilla plugins:
89 #pod L<PruneCruft|Dist::Zilla::Plugin::PruneCruft>,
90 #pod L<GatherDir|Dist::Zilla::Plugin::GatherDir>,
91 #pod L<ManifestSkip|Dist::Zilla::Plugin::ManifestSkip>.
92 #pod
93 #pod =cut
94  
95 __END__
« blib/lib/Dist/Zilla/App/Command/version.pm ↑ Summary blib/lib/Dist/Zilla/Role/TextTemplate.pm »