| 1 | package Dist::Zilla::Plugin::FileFinder::Filter 6.040; | ||||||||||
| 2 | # ABSTRACT: filter matches from other FileFinders | ||||||||||
| 3 | |||||||||||
| 4 | 2 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | with( | |||||||||
| 6 | 'Dist::Zilla::Role::FileFinder', | ||||||||||
| 7 | 'Dist::Zilla::Role::FileFinderUser' => { | ||||||||||
| 8 | default_finders => [], | ||||||||||
| 9 | }, | ||||||||||
| 10 | ); | ||||||||||
| 11 | |||||||||||
| 12 | 2 | ▶ | use Dist::Zilla::Pragmas; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | 2 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | ▶ | use Moose::Util::TypeConstraints; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 2 | ▶ | use MooseX::Types::Moose qw(ArrayRef RegexpRef Str); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 33 | |||||||||||
| 34 | { | ||||||||||
| 35 | 2 | my $type = subtype as ArrayRef[RegexpRef]; | |||||||||
| 36 | 2 | ▶ | coerce $type, from ArrayRef[Str], via { [map { qr/$_/ } @$_] }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 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 | 1 | ▶ | default => sub { [] }, | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 55 | 2 | ); | |||||||||
| 56 | } | ||||||||||
| 57 | |||||||||||
| 58 | 3 | ▶ | sub mvp_aliases { +{ qw( | ||||||||
|
Subroutine
mvp_aliases: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 59 | skip skips | ||||||||||
| 60 | ) } } | ||||||||||
| 61 | |||||||||||
| 62 | 3 | ▶ | sub mvp_multivalue_args { qw(skips) } | ||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
| |||||||||||
| 63 | |||||||||||
| 64 | 3 | ▶ | sub find_files { | ||||||||
|
Subroutine
find_files: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 65 | 3 | my $self = shift; | |||||||||
| 66 | |||||||||||
| 67 | 3 | my $files = $self->found_files; | |||||||||
| 68 | |||||||||||
| 69 | 3 | foreach my $re (@{ $self->skips }) { | |||||||||
| 70 | 2 | @$files = grep { $_->name !~ $re } @$files; | |||||||||
| 71 | } | ||||||||||
| 72 | |||||||||||
| 73 | 3 | ▶ | $self->log_debug("No files found") unless @$files; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 3 | $self->log_debug("Found " . $_->name) for @$files; | |||||||||
| 75 | |||||||||||
| 76 | 3 | $files; | |||||||||
| 77 | } | ||||||||||
| 78 | |||||||||||
| 79 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||
| 80 | 2 | 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__ | ||||||||||