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