File Coverage

blib/lib/Dist/Zilla/Plugin/FileFinder/Filter.pm
Criterion Covered Total %
statement 25 25 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 0 2 0.0
total 33 36 91.6


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::FileFinder::Filter 6.037;
2             # ABSTRACT: filter matches from other FileFinders
3              
4 2     2   2695 use Moose;
  2         6  
  2         20  
5             with(
6             'Dist::Zilla::Role::FileFinder',
7             'Dist::Zilla::Role::FileFinderUser' => {
8             default_finders => [],
9             },
10             );
11              
12 2     2   19865 use Dist::Zilla::Pragmas;
  2         6  
  2         22  
13              
14 2     2   18 use namespace::autoclean;
  2         7  
  2         67  
15              
16             #pod =head1 SYNOPSIS
17             #pod
18             #pod In your F<dist.ini>:
19             #pod
20             #pod [FileFinder::Filter / MyFiles]
21             #pod finder = :InstallModules ; find files from :InstallModules
22             #pod finder = :ExecFiles ; or :ExecFiles
23             #pod skip = ignore ; that don't have "ignore" in the path
24             #pod
25             #pod =head1 CREDITS
26             #pod
27             #pod This plugin was originally contributed by Christopher J. Madsen.
28             #pod
29             #pod =cut
30              
31 2     2   243 use Moose::Util::TypeConstraints;
  2         7  
  2         24  
32 2     2   5875 use MooseX::Types::Moose qw(ArrayRef RegexpRef Str);
  2         7  
  2         35  
33              
34             {
35             my $type = subtype as ArrayRef[RegexpRef];
36             coerce $type, from ArrayRef[Str], via { [map { qr/$_/ } @$_] };
37              
38             #pod =attr finder
39             #pod
40             #pod A FileFinder to supply the initial list of files.
41             #pod May occur multiple times.
42             #pod
43             #pod =attr skip
44             #pod
45             #pod The pathname must I<not> match any of these regular expressions.
46             #pod May occur multiple times.
47             #pod
48             #pod =cut
49              
50             has skips => (
51             is => 'ro',
52             isa => $type,
53             coerce => 1,
54             default => sub { [] },
55             );
56             }
57              
58 3     3 0 745 sub mvp_aliases { +{ qw(
59             skip skips
60             ) } }
61              
62             sub mvp_multivalue_args { qw(skips) }
63              
64             sub find_files {
65 3     3 0 11 my $self = shift;
66              
67 3         20 my $files = $self->found_files;
68              
69 3         13 foreach my $re (@{ $self->skips }) {
  3         128  
70 2         5 @$files = grep { $_->name !~ $re } @$files;
  16         26  
71             }
72              
73 3 50       12 $self->log_debug("No files found") unless @$files;
74 3         13 $self->log_debug("Found " . $_->name) for @$files;
75              
76 3         145 $files;
77             }
78              
79             __PACKAGE__->meta->make_immutable;
80             1;
81              
82             #pod =head1 DESCRIPTION
83             #pod
84             #pod FileFinder::Filter is a L<FileFinder|Dist::Zilla::Role::FileFinder> that
85             #pod selects files by filtering the selections of other FileFinders.
86             #pod
87             #pod You specify one or more FileFinders to generate the initial list of
88             #pod files. Any file whose pathname matches any of the C<skip> regexs is
89             #pod removed from that list.
90             #pod
91             #pod =for Pod::Coverage
92             #pod mvp_aliases
93             #pod mvp_multivalue_args
94             #pod find_files
95              
96             __END__
97              
98             =pod
99              
100             =encoding UTF-8
101              
102             =head1 NAME
103              
104             Dist::Zilla::Plugin::FileFinder::Filter - filter matches from other FileFinders
105              
106             =head1 VERSION
107              
108             version 6.037
109              
110             =head1 SYNOPSIS
111              
112             In your F<dist.ini>:
113              
114             [FileFinder::Filter / MyFiles]
115             finder = :InstallModules ; find files from :InstallModules
116             finder = :ExecFiles ; or :ExecFiles
117             skip = ignore ; that don't have "ignore" in the path
118              
119             =head1 DESCRIPTION
120              
121             FileFinder::Filter is a L<FileFinder|Dist::Zilla::Role::FileFinder> that
122             selects files by filtering the selections of other FileFinders.
123              
124             You specify one or more FileFinders to generate the initial list of
125             files. Any file whose pathname matches any of the C<skip> regexs is
126             removed from that list.
127              
128             =head1 PERL VERSION
129              
130             This module should work on any version of perl still receiving updates from
131             the Perl 5 Porters. This means it should work on any version of perl
132             released in the last two to three years. (That is, if the most recently
133             released version is v5.40, then this module should work on both v5.40 and
134             v5.38.)
135              
136             Although it may work on older versions of perl, no guarantee is made that the
137             minimum required version will not be increased. The version may be increased
138             for any reason, and there is no promise that patches will be accepted to
139             lower the minimum required perl.
140              
141             =head1 ATTRIBUTES
142              
143             =head2 finder
144              
145             A FileFinder to supply the initial list of files.
146             May occur multiple times.
147              
148             =head2 skip
149              
150             The pathname must I<not> match any of these regular expressions.
151             May occur multiple times.
152              
153             =head1 CREDITS
154              
155             This plugin was originally contributed by Christopher J. Madsen.
156              
157             =for Pod::Coverage mvp_aliases
158             mvp_multivalue_args
159             find_files
160              
161             =head1 AUTHOR
162              
163             Ricardo SIGNES 😏 <cpan@semiotic.systems>
164              
165             =head1 COPYRIGHT AND LICENSE
166              
167             This software is copyright (c) 2026 by Ricardo SIGNES.
168              
169             This is free software; you can redistribute it and/or modify it under
170             the same terms as the Perl 5 programming language system itself.
171              
172             =cut