line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: something that uses FileFinder plugins |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use MooseX::Role::Parameterized 1.01; |
4
|
18
|
|
|
34
|
|
11433
|
|
|
18
|
|
|
|
|
64424
|
|
|
18
|
|
|
|
|
162
|
|
5
|
|
|
|
|
|
|
use Dist::Zilla::Pragmas; |
6
|
18
|
|
|
18
|
|
190931
|
|
|
18
|
|
|
|
|
54
|
|
|
18
|
|
|
|
|
176
|
|
7
|
|
|
|
|
|
|
use namespace::autoclean; |
8
|
18
|
|
|
18
|
|
141
|
|
|
18
|
|
|
|
|
47
|
|
|
18
|
|
|
|
|
153
|
|
9
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
10
|
|
|
|
|
|
|
#pod |
11
|
|
|
|
|
|
|
#pod This role enables you to search for files in the dist. This makes it easy to find specific |
12
|
|
|
|
|
|
|
#pod files and have the code factored out to common methods. |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod Here's an example of a finder: ( taken from AutoPrereqs ) |
15
|
|
|
|
|
|
|
#pod |
16
|
|
|
|
|
|
|
#pod with 'Dist::Zilla::Role::FileFinderUser' => { |
17
|
|
|
|
|
|
|
#pod default_finders => [ ':InstallModules', ':ExecFiles' ], |
18
|
|
|
|
|
|
|
#pod }; |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod Then you use it in your code like this: |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod foreach my $file ( @{ $self->found_files }) { |
23
|
|
|
|
|
|
|
#pod # $file is an object! Look at L<Dist::Zilla::Role::File> |
24
|
|
|
|
|
|
|
#pod } |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod =cut |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#pod =attr finder_arg_names |
29
|
|
|
|
|
|
|
#pod |
30
|
|
|
|
|
|
|
#pod Define the name of the attribute which will hold this finder. Be sure to specify different names |
31
|
|
|
|
|
|
|
#pod if you have multiple finders! |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod This is an ArrayRef. |
34
|
|
|
|
|
|
|
#pod |
35
|
|
|
|
|
|
|
#pod Default: [ qw( finder ) ] |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod =cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
parameter finder_arg_names => ( |
40
|
|
|
|
|
|
|
isa => 'ArrayRef', |
41
|
|
|
|
|
|
|
default => sub { [ 'finder' ] }, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#pod =attr default_finders |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod This attribute is an arrayref of plugin names for the default plugins the |
47
|
|
|
|
|
|
|
#pod consuming plugin will use as finders. |
48
|
|
|
|
|
|
|
#pod |
49
|
|
|
|
|
|
|
#pod Example: C<< [ qw( :InstallModules :ExecFiles ) ] >> |
50
|
|
|
|
|
|
|
#pod |
51
|
|
|
|
|
|
|
#pod The default finders are: |
52
|
|
|
|
|
|
|
#pod |
53
|
|
|
|
|
|
|
#pod =begin :list |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod = :InstallModules |
56
|
|
|
|
|
|
|
#pod |
57
|
|
|
|
|
|
|
#pod Searches your lib/ directory for pm/pod files |
58
|
|
|
|
|
|
|
#pod |
59
|
|
|
|
|
|
|
#pod = :IncModules |
60
|
|
|
|
|
|
|
#pod |
61
|
|
|
|
|
|
|
#pod Searches your inc/ directory for pm files |
62
|
|
|
|
|
|
|
#pod |
63
|
|
|
|
|
|
|
#pod = :MainModule |
64
|
|
|
|
|
|
|
#pod |
65
|
|
|
|
|
|
|
#pod Finds the C<main_module> of your dist |
66
|
|
|
|
|
|
|
#pod |
67
|
|
|
|
|
|
|
#pod = :TestFiles |
68
|
|
|
|
|
|
|
#pod |
69
|
|
|
|
|
|
|
#pod Searches your t/ directory and lists the files in it. |
70
|
|
|
|
|
|
|
#pod |
71
|
|
|
|
|
|
|
#pod = :ExtraTestFiles |
72
|
|
|
|
|
|
|
#pod |
73
|
|
|
|
|
|
|
#pod Searches your xt/ directory and lists the files in it. |
74
|
|
|
|
|
|
|
#pod |
75
|
|
|
|
|
|
|
#pod = :ExecFiles |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod Searches your distribution for executable files. Hint: Use the |
78
|
|
|
|
|
|
|
#pod L<Dist::Zilla::Plugin::ExecDir> plugin to mark those files as executables. |
79
|
|
|
|
|
|
|
#pod |
80
|
|
|
|
|
|
|
#pod = :PerlExecFiles |
81
|
|
|
|
|
|
|
#pod |
82
|
|
|
|
|
|
|
#pod A subset of C<:ExecFiles> limited just to perl scripts (those ending with |
83
|
|
|
|
|
|
|
#pod F<.pl>, or with a recognizable perl shebang). |
84
|
|
|
|
|
|
|
#pod |
85
|
|
|
|
|
|
|
#pod = :ShareFiles |
86
|
|
|
|
|
|
|
#pod |
87
|
|
|
|
|
|
|
#pod Searches your ShareDir directory and lists the files in it. |
88
|
|
|
|
|
|
|
#pod Hint: Use the L<Dist::Zilla::Plugin::ShareDir> plugin to set up the sharedir. |
89
|
|
|
|
|
|
|
#pod |
90
|
|
|
|
|
|
|
#pod = :AllFiles |
91
|
|
|
|
|
|
|
#pod |
92
|
|
|
|
|
|
|
#pod Returns all files in the distribution. |
93
|
|
|
|
|
|
|
#pod |
94
|
|
|
|
|
|
|
#pod = :NoFiles |
95
|
|
|
|
|
|
|
#pod |
96
|
|
|
|
|
|
|
#pod Returns nothing. |
97
|
|
|
|
|
|
|
#pod |
98
|
|
|
|
|
|
|
#pod =end :list |
99
|
|
|
|
|
|
|
#pod |
100
|
|
|
|
|
|
|
#pod =cut |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
parameter default_finders => ( |
103
|
|
|
|
|
|
|
isa => 'ArrayRef', |
104
|
|
|
|
|
|
|
required => 1, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
#pod =attr method |
108
|
|
|
|
|
|
|
#pod |
109
|
|
|
|
|
|
|
#pod This will be the name of the subroutine installed in your package for this |
110
|
|
|
|
|
|
|
#pod finder. Be sure to specify different names if you have multiple finders! |
111
|
|
|
|
|
|
|
#pod |
112
|
|
|
|
|
|
|
#pod Default: found_files |
113
|
|
|
|
|
|
|
#pod |
114
|
|
|
|
|
|
|
#pod =cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
parameter method => ( |
117
|
|
|
|
|
|
|
isa => 'Str', |
118
|
|
|
|
|
|
|
default => 'found_files', |
119
|
|
|
|
|
|
|
); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
role { |
122
|
|
|
|
|
|
|
my ($p) = @_; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my ($finder_arg, @finder_arg_aliases) = @{ $p->finder_arg_names }; |
125
|
|
|
|
|
|
|
confess "no finder arg names given!" unless $finder_arg; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
around mvp_multivalue_args => sub { |
128
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
my @start = $self->$orig; |
131
|
|
|
|
|
|
|
return (@start, $finder_arg); |
132
|
|
|
|
|
|
|
}; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
if (@finder_arg_aliases) { |
135
|
|
|
|
|
|
|
around mvp_aliases => sub { |
136
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $start = $self->$orig; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
for my $alias (@finder_arg_aliases) { |
141
|
|
|
|
|
|
|
confess "$alias is already an alias to $start->{$alias}" |
142
|
|
|
|
|
|
|
if exists $start->{$alias} and $orig->{$alias} ne $finder_arg; |
143
|
|
|
|
|
|
|
$start->{ $alias } = $finder_arg; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
return $start; |
147
|
|
|
|
|
|
|
}; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
has $finder_arg => ( |
151
|
|
|
|
|
|
|
is => 'ro', |
152
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
153
|
|
|
|
|
|
|
default => sub { [ @{ $p->default_finders } ] }, |
154
|
|
|
|
|
|
|
); |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
method $p->method => sub { |
157
|
|
|
|
|
|
|
my ($self) = @_; |
158
|
116
|
|
|
116
|
|
322
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
116
|
|
|
|
159
|
|
|
|
|
|
|
my @filesets = map {; $self->zilla->find_files($_) } |
160
|
119
|
|
|
|
|
3498
|
@{ $self->$finder_arg }; |
161
|
116
|
|
|
|
|
228
|
|
|
116
|
|
|
|
|
4506
|
|
162
|
|
|
|
|
|
|
my %by_name = map {; $_->name, $_ } map { @$_ } @filesets; |
163
|
116
|
|
|
|
|
332
|
|
|
117
|
|
|
|
|
335
|
|
|
119
|
|
|
|
|
296
|
|
164
|
|
|
|
|
|
|
return [ map {; $by_name{$_} } sort keys %by_name ]; |
165
|
116
|
|
|
|
|
588
|
}; |
|
117
|
|
|
|
|
441
|
|
166
|
|
|
|
|
|
|
}; |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
1; |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=pod |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=encoding UTF-8 |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head1 NAME |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Dist::Zilla::Role::FileFinderUser - something that uses FileFinder plugins |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head1 VERSION |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
version 6.028 |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 DESCRIPTION |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This role enables you to search for files in the dist. This makes it easy to find specific |
186
|
|
|
|
|
|
|
files and have the code factored out to common methods. |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
Here's an example of a finder: ( taken from AutoPrereqs ) |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
with 'Dist::Zilla::Role::FileFinderUser' => { |
191
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles' ], |
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
Then you use it in your code like this: |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
foreach my $file ( @{ $self->found_files }) { |
197
|
|
|
|
|
|
|
# $file is an object! Look at L<Dist::Zilla::Role::File> |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 PERL VERSION |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
203
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
204
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
205
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
208
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
209
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
210
|
|
|
|
|
|
|
the minimum required perl. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head2 finder_arg_names |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Define the name of the attribute which will hold this finder. Be sure to specify different names |
217
|
|
|
|
|
|
|
if you have multiple finders! |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
This is an ArrayRef. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
Default: [ qw( finder ) ] |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 default_finders |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This attribute is an arrayref of plugin names for the default plugins the |
226
|
|
|
|
|
|
|
consuming plugin will use as finders. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Example: C<< [ qw( :InstallModules :ExecFiles ) ] >> |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
The default finders are: |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=over 4 |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item :InstallModules |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
Searches your lib/ directory for pm/pod files |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=item :IncModules |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
Searches your inc/ directory for pm files |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=item :MainModule |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Finds the C<main_module> of your dist |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
=item :TestFiles |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
Searches your t/ directory and lists the files in it. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=item :ExtraTestFiles |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
Searches your xt/ directory and lists the files in it. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=item :ExecFiles |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
Searches your distribution for executable files. Hint: Use the |
257
|
|
|
|
|
|
|
L<Dist::Zilla::Plugin::ExecDir> plugin to mark those files as executables. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=item :PerlExecFiles |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
A subset of C<:ExecFiles> limited just to perl scripts (those ending with |
262
|
|
|
|
|
|
|
F<.pl>, or with a recognizable perl shebang). |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item :ShareFiles |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Searches your ShareDir directory and lists the files in it. |
267
|
|
|
|
|
|
|
Hint: Use the L<Dist::Zilla::Plugin::ShareDir> plugin to set up the sharedir. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item :AllFiles |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
Returns all files in the distribution. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item :NoFiles |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Returns nothing. |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=back |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=head2 method |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
This will be the name of the subroutine installed in your package for this |
282
|
|
|
|
|
|
|
finder. Be sure to specify different names if you have multiple finders! |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Default: found_files |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=head1 AUTHOR |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
295
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=cut |