/usr/share/perl5/Dist/Zilla/Plugin/FileFinder/ByName.pm is in libdist-zilla-perl 5.043-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | package Dist::Zilla::Plugin::FileFinder::ByName;
# ABSTRACT: FileFinder matching on pathnames
$Dist::Zilla::Plugin::FileFinder::ByName::VERSION = '5.043';
use Moose;
with 'Dist::Zilla::Role::FileFinder';
use namespace::autoclean;
#pod =head1 SYNOPSIS
#pod
#pod In your F<dist.ini>:
#pod
#pod [FileFinder::ByName / MyFiles]
#pod dir = bin ; look in the bin/ directory
#pod dir = lib ; and the lib/ directory
#pod file = *.pl ; for .pl files
#pod match = \.pm$ ; and for .pm files
#pod skip = ignore ; that don't have "ignore" in the path
#pod
#pod =head1 CREDITS
#pod
#pod This plugin was originally contributed by Christopher J. Madsen.
#pod
#pod =cut
use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw(ArrayRef RegexpRef Str);
use Text::Glob 0.08 qw(glob_to_regex_string);
#pod =attr dir
#pod
#pod The file must be located in one of the specified directories (relative
#pod to the root directory of the dist).
#pod
#pod =attr file
#pod
#pod The filename must match one of the specified patterns (which are
#pod converted to regexs using L<Text::Glob> and combined with any C<match>
#pod rules).
#pod
#pod =cut
has dirs => (
is => 'ro',
isa => ArrayRef[Str],
default => sub { [] },
);
has files => (
is => 'ro',
isa => ArrayRef[Str],
default => sub { [] },
);
{
my $type = subtype as ArrayRef[RegexpRef];
coerce $type, from ArrayRef[Str], via { [map { qr/$_/ } @$_] };
#pod =attr match
#pod
#pod The pathname must match one of these regular expressions.
#pod
#pod =attr skip
#pod
#pod The pathname must I<not> match any of these regular expressions.
#pod
#pod =cut
has matches => (
is => 'ro',
isa => $type,
coerce => 1,
default => sub { [] },
);
has skips => (
is => 'ro',
isa => $type,
coerce => 1,
default => sub { [] },
);
}
sub mvp_aliases { +{ qw(
dir dirs
file files
match matches
matching matches
skip skips
except skips
) } }
sub mvp_multivalue_args { qw(dirs files matches skips) }
sub _join_re {
my $list = shift;
return undef if @$list == 0;
my $re = qr/(?:$list->[0])/;
for my $i (1 .. $#$list) {
$re = qr/$re|(?:$list->[$i])/;
}
$re;
}
sub find_files {
my $self = shift;
my $skip = _join_re($self->skips);
my $dir = _join_re([ map { qr!^\Q$_/! } @{ $self->dirs } ]);
my $match = _join_re([
(map { my $re = glob_to_regex_string($_); qr!(?:\A|/)$re\z! }
@{ $self->files }),
@{ $self->matches }
]);
my $files = $self->zilla->files;
$files = [ grep {
my $name = $_->name;
(not defined $dir or $name =~ $dir) and
(not defined $match or $name =~ $match) and
(not defined $skip or $name !~ $skip)
} @$files ];
$self->log_debug("No files found") unless @$files;
$self->log_debug("Found " . $_->name) for @$files;
$files;
}
__PACKAGE__->meta->make_immutable;
1;
#pod =head1 DESCRIPTION
#pod
#pod FileFinder::ByName is a L<FileFinder|Dist::Zilla::Role::FileFinder> that
#pod selects files by matching the criteria you specify against the pathname.
#pod
#pod There are three types of criteria you can use. C<dir> limits the
#pod search to a particular directory. C<match> is a regular expression
#pod that must match the pathname. C<skip> is a regular expression that
#pod must not match the pathname.
#pod
#pod Each key can be specified multiple times. Multiple occurrences of the
#pod same key are ORed together. Different keys are ANDed together. That
#pod means that to be selected, a file must be located in one of the
#pod C<dir>s, must match one of the C<match> regexs, and must not match any
#pod of the C<skip> regexs.
#pod
#pod Note that C<file> and C<match> are considered to be the I<same> key.
#pod They're just different ways to write a regex that the pathname must match.
#pod
#pod Omitting a particular key means that criterion will not apply to the
#pod search. Omitting all keys will select every file in your dist.
#pod
#pod Note: If you need to OR different types of criteria, then use more
#pod than one instance of FileFinder::ByName. A
#pod L<FileFinderUser|Dist::Zilla::Role::FileFinderUser> should allow you
#pod to specify more than one FileFinder to use.
#pod
#pod =for Pod::Coverage
#pod mvp_aliases
#pod mvp_multivalue_args
#pod find_files
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Plugin::FileFinder::ByName - FileFinder matching on pathnames
=head1 VERSION
version 5.043
=head1 SYNOPSIS
In your F<dist.ini>:
[FileFinder::ByName / MyFiles]
dir = bin ; look in the bin/ directory
dir = lib ; and the lib/ directory
file = *.pl ; for .pl files
match = \.pm$ ; and for .pm files
skip = ignore ; that don't have "ignore" in the path
=head1 DESCRIPTION
FileFinder::ByName is a L<FileFinder|Dist::Zilla::Role::FileFinder> that
selects files by matching the criteria you specify against the pathname.
There are three types of criteria you can use. C<dir> limits the
search to a particular directory. C<match> is a regular expression
that must match the pathname. C<skip> is a regular expression that
must not match the pathname.
Each key can be specified multiple times. Multiple occurrences of the
same key are ORed together. Different keys are ANDed together. That
means that to be selected, a file must be located in one of the
C<dir>s, must match one of the C<match> regexs, and must not match any
of the C<skip> regexs.
Note that C<file> and C<match> are considered to be the I<same> key.
They're just different ways to write a regex that the pathname must match.
Omitting a particular key means that criterion will not apply to the
search. Omitting all keys will select every file in your dist.
Note: If you need to OR different types of criteria, then use more
than one instance of FileFinder::ByName. A
L<FileFinderUser|Dist::Zilla::Role::FileFinderUser> should allow you
to specify more than one FileFinder to use.
=head1 ATTRIBUTES
=head2 dir
The file must be located in one of the specified directories (relative
to the root directory of the dist).
=head2 file
The filename must match one of the specified patterns (which are
converted to regexs using L<Text::Glob> and combined with any C<match>
rules).
=head2 match
The pathname must match one of these regular expressions.
=head2 skip
The pathname must I<not> match any of these regular expressions.
=head1 CREDITS
This plugin was originally contributed by Christopher J. Madsen.
=for Pod::Coverage mvp_aliases
mvp_multivalue_args
find_files
=head1 AUTHOR
Ricardo SIGNES <rjbs@cpan.org>
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut
|