line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::AutoPrereqs 6.030; |
2
|
|
|
|
|
|
|
# ABSTRACT: automatically extract prereqs from your modules |
3
|
|
|
|
|
|
|
|
4
|
6
|
|
|
6
|
|
4973
|
use Moose; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
with( |
6
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqScanner', |
7
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource', |
8
|
|
|
|
|
|
|
'Dist::Zilla::Role::PPI', |
9
|
|
|
|
|
|
|
); |
10
|
|
|
|
|
|
|
|
11
|
6
|
|
|
6
|
|
43773
|
use Dist::Zilla::Pragmas; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
60
|
|
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
51
|
use Moose::Util::TypeConstraints 'enum'; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
73
|
|
14
|
6
|
|
|
6
|
|
2814
|
use namespace::autoclean; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
59
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod In your F<dist.ini>: |
19
|
|
|
|
|
|
|
#pod |
20
|
|
|
|
|
|
|
#pod [AutoPrereqs] |
21
|
|
|
|
|
|
|
#pod skip = ^Foo|Bar$ |
22
|
|
|
|
|
|
|
#pod skip = ^Other::Dist |
23
|
|
|
|
|
|
|
#pod |
24
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
25
|
|
|
|
|
|
|
#pod |
26
|
|
|
|
|
|
|
#pod This plugin will extract loosely your distribution prerequisites from |
27
|
|
|
|
|
|
|
#pod your files using L<Perl::PrereqScanner>. |
28
|
|
|
|
|
|
|
#pod |
29
|
|
|
|
|
|
|
#pod If some prereqs are not found, you can still add them manually with the |
30
|
|
|
|
|
|
|
#pod L<Prereqs|Dist::Zilla::Plugin::Prereqs> plugin. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod This plugin will skip the modules shipped within your dist. |
33
|
|
|
|
|
|
|
#pod |
34
|
|
|
|
|
|
|
#pod B<Note>, if you have any non-Perl files in your C<t/> directory or other |
35
|
|
|
|
|
|
|
#pod directories being scanned, be sure to mark those files' encoding as C<bytes> |
36
|
|
|
|
|
|
|
#pod with the L<Encoding|Dist::Zilla::Plugin::Encoding> plugin so they won't be |
37
|
|
|
|
|
|
|
#pod scanned: |
38
|
|
|
|
|
|
|
#pod |
39
|
|
|
|
|
|
|
#pod [Encoding] |
40
|
|
|
|
|
|
|
#pod encoding = bytes |
41
|
|
|
|
|
|
|
#pod match = ^t/data/ |
42
|
|
|
|
|
|
|
#pod |
43
|
|
|
|
|
|
|
#pod =attr finder |
44
|
|
|
|
|
|
|
#pod |
45
|
|
|
|
|
|
|
#pod This is the name of a L<FileFinder|Dist::Zilla::Role::FileFinder> |
46
|
|
|
|
|
|
|
#pod whose files will be scanned to determine runtime prerequisites. It |
47
|
|
|
|
|
|
|
#pod may be specified multiple times. The default value is |
48
|
|
|
|
|
|
|
#pod C<:InstallModules> and C<:ExecFiles>. |
49
|
|
|
|
|
|
|
#pod |
50
|
|
|
|
|
|
|
#pod =attr test_finder |
51
|
|
|
|
|
|
|
#pod |
52
|
|
|
|
|
|
|
#pod Just like C<finder>, but for test-phase prerequisites. The default |
53
|
|
|
|
|
|
|
#pod value is C<:TestFiles>. |
54
|
|
|
|
|
|
|
#pod |
55
|
|
|
|
|
|
|
#pod =attr configure_finder |
56
|
|
|
|
|
|
|
#pod |
57
|
|
|
|
|
|
|
#pod Just like C<finder>, but for configure-phase prerequisites. There is |
58
|
|
|
|
|
|
|
#pod no default value; AutoPrereqs will not determine configure-phase |
59
|
|
|
|
|
|
|
#pod prerequisites unless you set configure_finder. |
60
|
|
|
|
|
|
|
#pod |
61
|
|
|
|
|
|
|
#pod =attr develop_finder |
62
|
|
|
|
|
|
|
#pod |
63
|
|
|
|
|
|
|
#pod Just like C<finder>, but for develop-phase prerequisites. The default value |
64
|
|
|
|
|
|
|
#pod is C<:ExtraTestFiles>. |
65
|
|
|
|
|
|
|
#pod |
66
|
|
|
|
|
|
|
#pod =attr skips |
67
|
|
|
|
|
|
|
#pod |
68
|
|
|
|
|
|
|
#pod This is an arrayref of regular expressions, derived from all the 'skip' lines |
69
|
|
|
|
|
|
|
#pod in the configuration. Any module names matching any of these regexes will not |
70
|
|
|
|
|
|
|
#pod be registered as prerequisites. |
71
|
|
|
|
|
|
|
#pod |
72
|
|
|
|
|
|
|
#pod =attr relationship |
73
|
|
|
|
|
|
|
#pod |
74
|
|
|
|
|
|
|
#pod The relationship used for the registered prerequisites. The default value is |
75
|
|
|
|
|
|
|
#pod 'requires'; other options are 'recommends' and 'suggests'. |
76
|
|
|
|
|
|
|
#pod |
77
|
|
|
|
|
|
|
#pod =attr extra_scanners |
78
|
|
|
|
|
|
|
#pod |
79
|
|
|
|
|
|
|
#pod This is an arrayref of scanner names (as expected by L<Perl::PrereqScanner>). |
80
|
|
|
|
|
|
|
#pod It will be passed as the C<extra_scanners> parameter to L<Perl::PrereqScanner>. |
81
|
|
|
|
|
|
|
#pod |
82
|
|
|
|
|
|
|
#pod =attr scanners |
83
|
|
|
|
|
|
|
#pod |
84
|
|
|
|
|
|
|
#pod This is an arrayref of scanner names (as expected by L<Perl::PrereqScanner>). |
85
|
|
|
|
|
|
|
#pod If present, it will be passed as the C<scanners> parameter to |
86
|
|
|
|
|
|
|
#pod L<Perl::PrereqScanner>, which means that it will replace the default list |
87
|
|
|
|
|
|
|
#pod of scanners. |
88
|
|
|
|
|
|
|
#pod |
89
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
90
|
|
|
|
|
|
|
#pod |
91
|
|
|
|
|
|
|
#pod L<Prereqs|Dist::Zilla::Plugin::Prereqs>, L<Perl::PrereqScanner>. |
92
|
|
|
|
|
|
|
#pod |
93
|
|
|
|
|
|
|
#pod =head1 CREDITS |
94
|
|
|
|
|
|
|
#pod |
95
|
|
|
|
|
|
|
#pod This plugin was originally contributed by Jerome Quelin. |
96
|
|
|
|
|
|
|
#pod |
97
|
|
|
|
|
|
|
#pod =cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub mvp_multivalue_args { qw(extra_scanners scanners) } |
100
|
|
|
|
|
|
|
sub mvp_aliases { return { extra_scanner => 'extra_scanners', |
101
|
|
|
|
|
|
|
scanner => 'scanners', |
102
|
|
|
|
|
|
|
relationship => 'type' } } |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has extra_scanners => ( |
105
|
|
|
|
|
|
|
is => 'ro', |
106
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
107
|
|
|
|
|
|
|
default => sub { [] }, |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
has scanners => ( |
111
|
|
|
|
|
|
|
is => 'ro', |
112
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
113
|
|
|
|
|
|
|
predicate => 'has_scanners', |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
has _scanner => ( |
118
|
|
|
|
|
|
|
is => 'ro', |
119
|
|
|
|
|
|
|
lazy => 1, |
120
|
|
|
|
|
|
|
default => sub { |
121
|
|
|
|
|
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
require Perl::PrereqScanner; |
124
|
|
|
|
|
|
|
Perl::PrereqScanner->VERSION('1.016'); # don't skip "lib" |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
return Perl::PrereqScanner->new( |
127
|
|
|
|
|
|
|
($self->has_scanners ? (scanners => $self->scanners) : ()), |
128
|
|
|
|
|
|
|
extra_scanners => $self->extra_scanners, |
129
|
|
|
|
|
|
|
) |
130
|
|
|
|
|
|
|
}, |
131
|
|
|
|
|
|
|
init_arg => undef, |
132
|
|
|
|
|
|
|
); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
has type => ( |
135
|
|
|
|
|
|
|
is => 'ro', |
136
|
|
|
|
|
|
|
isa => enum([qw(requires recommends suggests)]), |
137
|
|
|
|
|
|
|
default => 'requires', |
138
|
|
|
|
|
|
|
); |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub scan_file_reqs { |
141
|
91
|
|
|
91
|
0
|
219
|
my ($self, $file) = @_; |
142
|
91
|
|
|
|
|
2845
|
return $self->_scanner->scan_ppi_document($self->ppi_document_for_file($file)) |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub register_prereqs { |
146
|
29
|
|
|
29
|
0
|
80
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
29
|
|
|
|
|
1049
|
my $type = $self->type; |
149
|
|
|
|
|
|
|
|
150
|
29
|
|
|
|
|
185
|
my $reqs_by_phase = $self->scan_prereqs; |
151
|
29
|
|
|
|
|
208
|
while (my ($phase, $reqs) = each %$reqs_by_phase) { |
152
|
116
|
|
|
|
|
3744
|
$self->zilla->register_prereqs({ phase => $phase, type => $type }, %$reqs); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
157
|
|
|
|
|
|
|
1; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=pod |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=encoding UTF-8 |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 NAME |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Dist::Zilla::Plugin::AutoPrereqs - automatically extract prereqs from your modules |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 VERSION |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
version 6.030 |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 SYNOPSIS |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
In your F<dist.ini>: |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
[AutoPrereqs] |
178
|
|
|
|
|
|
|
skip = ^Foo|Bar$ |
179
|
|
|
|
|
|
|
skip = ^Other::Dist |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 DESCRIPTION |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
This plugin will extract loosely your distribution prerequisites from |
184
|
|
|
|
|
|
|
your files using L<Perl::PrereqScanner>. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
If some prereqs are not found, you can still add them manually with the |
187
|
|
|
|
|
|
|
L<Prereqs|Dist::Zilla::Plugin::Prereqs> plugin. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This plugin will skip the modules shipped within your dist. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
B<Note>, if you have any non-Perl files in your C<t/> directory or other |
192
|
|
|
|
|
|
|
directories being scanned, be sure to mark those files' encoding as C<bytes> |
193
|
|
|
|
|
|
|
with the L<Encoding|Dist::Zilla::Plugin::Encoding> plugin so they won't be |
194
|
|
|
|
|
|
|
scanned: |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
[Encoding] |
197
|
|
|
|
|
|
|
encoding = bytes |
198
|
|
|
|
|
|
|
match = ^t/data/ |
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 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is the name of a L<FileFinder|Dist::Zilla::Role::FileFinder> |
217
|
|
|
|
|
|
|
whose files will be scanned to determine runtime prerequisites. It |
218
|
|
|
|
|
|
|
may be specified multiple times. The default value is |
219
|
|
|
|
|
|
|
C<:InstallModules> and C<:ExecFiles>. |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head2 test_finder |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
Just like C<finder>, but for test-phase prerequisites. The default |
224
|
|
|
|
|
|
|
value is C<:TestFiles>. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head2 configure_finder |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Just like C<finder>, but for configure-phase prerequisites. There is |
229
|
|
|
|
|
|
|
no default value; AutoPrereqs will not determine configure-phase |
230
|
|
|
|
|
|
|
prerequisites unless you set configure_finder. |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head2 develop_finder |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Just like C<finder>, but for develop-phase prerequisites. The default value |
235
|
|
|
|
|
|
|
is C<:ExtraTestFiles>. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head2 skips |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
This is an arrayref of regular expressions, derived from all the 'skip' lines |
240
|
|
|
|
|
|
|
in the configuration. Any module names matching any of these regexes will not |
241
|
|
|
|
|
|
|
be registered as prerequisites. |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 relationship |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
The relationship used for the registered prerequisites. The default value is |
246
|
|
|
|
|
|
|
'requires'; other options are 'recommends' and 'suggests'. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=head2 extra_scanners |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
This is an arrayref of scanner names (as expected by L<Perl::PrereqScanner>). |
251
|
|
|
|
|
|
|
It will be passed as the C<extra_scanners> parameter to L<Perl::PrereqScanner>. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=head2 scanners |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
This is an arrayref of scanner names (as expected by L<Perl::PrereqScanner>). |
256
|
|
|
|
|
|
|
If present, it will be passed as the C<scanners> parameter to |
257
|
|
|
|
|
|
|
L<Perl::PrereqScanner>, which means that it will replace the default list |
258
|
|
|
|
|
|
|
of scanners. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=head1 SEE ALSO |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
L<Prereqs|Dist::Zilla::Plugin::Prereqs>, L<Perl::PrereqScanner>. |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=head1 CREDITS |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
This plugin was originally contributed by Jerome Quelin. |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
=head1 AUTHOR |
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
This software is copyright (c) 2023 by Ricardo SIGNES. |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
277
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=cut |