/usr/share/perl5/Dist/Zilla/Role/FileFinderUser.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 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | package Dist::Zilla::Role::FileFinderUser;
# ABSTRACT: something that uses FileFinder plugins
$Dist::Zilla::Role::FileFinderUser::VERSION = '5.043';
use MooseX::Role::Parameterized 1.01;
use namespace::autoclean;
#pod =head1 DESCRIPTION
#pod
#pod This role enables you to search for files in the dist. This makes it easy to find specific
#pod files and have the code factored out to common methods.
#pod
#pod Here's an example of a finder: ( taken from AutoPrereqs )
#pod
#pod with 'Dist::Zilla::Role::FileFinderUser' => {
#pod default_finders => [ ':InstallModules', ':ExecFiles' ],
#pod };
#pod
#pod Then you use it in your code like this:
#pod
#pod foreach my $file ( $self->found_files ) {
#pod # $file is an object! Look at L<Dist::Zilla::Role::File>
#pod }
#pod
#pod =cut
#pod =attr finder_arg_names
#pod
#pod Define the name of the attribute which will hold this finder. Be sure to specify different names
#pod if you have multiple finders!
#pod
#pod This is an ArrayRef.
#pod
#pod Default: [ qw( finder ) ]
#pod
#pod =cut
parameter finder_arg_names => (
isa => 'ArrayRef',
default => sub { [ 'finder' ] },
);
#pod =attr default_finders
#pod
#pod This attribute is an arrayref of plugin names for the default plugins the
#pod consuming plugin will use as finders.
#pod
#pod Example: C<< [ qw( :InstallModules :ExecFiles ) ] >>
#pod
#pod The default finders are:
#pod
#pod =begin :list
#pod
#pod = :InstallModules
#pod
#pod Searches your lib/ directory for pm/pod files
#pod
#pod = :IncModules
#pod
#pod Searches your inc/ directory for pm files
#pod
#pod = :MainModule
#pod
#pod Finds the C<main_module> of your dist
#pod
#pod = :TestFiles
#pod
#pod Searches your t/ directory and lists the files in it.
#pod
#pod = :ExtraTestFiles
#pod
#pod Searches your xt/ directory and lists the files in it.
#pod
#pod = :ExecFiles
#pod
#pod Searches your distribution for executable files. Hint: Use the
#pod L<Dist::Zilla::Plugin::ExecDir> plugin to mark those files as executables.
#pod
#pod = :PerlExecFiles
#pod
#pod A subset of C<:ExecFiles> limited just to perl scripts (those ending with
#pod F<.pl>, or with a recognizable perl shebang).
#pod
#pod = :ShareFiles
#pod
#pod Searches your ShareDir directory and lists the files in it.
#pod Hint: Use the L<Dist::Zilla::Plugin::ShareDir> plugin to set up the sharedir.
#pod
#pod = :AllFiles
#pod
#pod Returns all files in the distribution.
#pod
#pod = :NoFiles
#pod
#pod Returns nothing.
#pod
#pod =end :list
#pod
#pod =cut
parameter default_finders => (
isa => 'ArrayRef',
required => 1,
);
#pod =attr method
#pod
#pod This will be the name of the subroutine installed in your package for this
#pod finder. Be sure to specify different names if you have multiple finders!
#pod
#pod Default: found_files
#pod
#pod =cut
parameter method => (
isa => 'Str',
default => 'found_files',
);
role {
my ($p) = @_;
my ($finder_arg, @finder_arg_aliases) = @{ $p->finder_arg_names };
confess "no finder arg names given!" unless $finder_arg;
around mvp_multivalue_args => sub {
my ($orig, $self) = @_;
my @start = $self->$orig;
return (@start, $finder_arg);
};
if (@finder_arg_aliases) {
around mvp_aliases => sub {
my ($orig, $self) = @_;
my $start = $self->$orig;
for my $alias (@finder_arg_aliases) {
confess "$alias is already an alias to $start->{$alias}"
if exists $start->{$alias} and $orig->{$alias} ne $finder_arg;
$start->{ $alias } = $finder_arg;
}
return $start;
};
}
has $finder_arg => (
is => 'ro',
isa => 'ArrayRef[Str]',
default => sub { [ @{ $p->default_finders } ] },
);
method $p->method => sub {
my ($self) = @_;
my @filesets = map {; $self->zilla->find_files($_) }
@{ $self->$finder_arg };
my %by_name = map {; $_->name, $_ } map { @$_ } @filesets;
return [ map {; $by_name{$_} } sort keys %by_name ];
};
};
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Dist::Zilla::Role::FileFinderUser - something that uses FileFinder plugins
=head1 VERSION
version 5.043
=head1 DESCRIPTION
This role enables you to search for files in the dist. This makes it easy to find specific
files and have the code factored out to common methods.
Here's an example of a finder: ( taken from AutoPrereqs )
with 'Dist::Zilla::Role::FileFinderUser' => {
default_finders => [ ':InstallModules', ':ExecFiles' ],
};
Then you use it in your code like this:
foreach my $file ( $self->found_files ) {
# $file is an object! Look at L<Dist::Zilla::Role::File>
}
=head1 ATTRIBUTES
=head2 finder_arg_names
Define the name of the attribute which will hold this finder. Be sure to specify different names
if you have multiple finders!
This is an ArrayRef.
Default: [ qw( finder ) ]
=head2 default_finders
This attribute is an arrayref of plugin names for the default plugins the
consuming plugin will use as finders.
Example: C<< [ qw( :InstallModules :ExecFiles ) ] >>
The default finders are:
=over 4
=item :InstallModules
Searches your lib/ directory for pm/pod files
=item :IncModules
Searches your inc/ directory for pm files
=item :MainModule
Finds the C<main_module> of your dist
=item :TestFiles
Searches your t/ directory and lists the files in it.
=item :ExtraTestFiles
Searches your xt/ directory and lists the files in it.
=item :ExecFiles
Searches your distribution for executable files. Hint: Use the
L<Dist::Zilla::Plugin::ExecDir> plugin to mark those files as executables.
=item :PerlExecFiles
A subset of C<:ExecFiles> limited just to perl scripts (those ending with
F<.pl>, or with a recognizable perl shebang).
=item :ShareFiles
Searches your ShareDir directory and lists the files in it.
Hint: Use the L<Dist::Zilla::Plugin::ShareDir> plugin to set up the sharedir.
=item :AllFiles
Returns all files in the distribution.
=item :NoFiles
Returns nothing.
=back
=head2 method
This will be the name of the subroutine installed in your package for this
finder. Be sure to specify different names if you have multiple finders!
Default: found_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
|