line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Prereqs 6.029; |
2
|
|
|
|
|
|
|
# ABSTRACT: the prerequisites of a Dist::Zilla distribution |
3
|
|
|
|
|
|
|
|
4
|
52
|
|
|
52
|
|
457
|
use Moose; |
|
52
|
|
|
|
|
159
|
|
|
52
|
|
|
|
|
525
|
|
5
|
|
|
|
|
|
|
|
6
|
52
|
|
|
52
|
|
396553
|
use Dist::Zilla::Pragmas; |
|
52
|
|
|
|
|
159
|
|
|
52
|
|
|
|
|
495
|
|
7
|
|
|
|
|
|
|
|
8
|
52
|
|
|
52
|
|
444
|
use MooseX::Types::Moose qw(Bool HashRef); |
|
52
|
|
|
|
|
131
|
|
|
52
|
|
|
|
|
818
|
|
9
|
|
|
|
|
|
|
|
10
|
52
|
|
|
52
|
|
303903
|
use CPAN::Meta::Prereqs 2.120630; # add_string_requirement |
|
52
|
|
|
|
|
354223
|
|
|
52
|
|
|
|
|
1635
|
|
11
|
52
|
|
|
52
|
|
447
|
use String::RewritePrefix; |
|
52
|
|
|
|
|
145
|
|
|
52
|
|
|
|
|
407
|
|
12
|
52
|
|
|
52
|
|
11352
|
use CPAN::Meta::Requirements 2.121; # requirements_for_module |
|
52
|
|
|
|
|
734
|
|
|
52
|
|
|
|
|
1287
|
|
13
|
|
|
|
|
|
|
|
14
|
52
|
|
|
52
|
|
346
|
use namespace::autoclean; |
|
52
|
|
|
|
|
134
|
|
|
52
|
|
|
|
|
503
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod Dist::Zilla::Prereqs is a subcomponent of Dist::Zilla. The C<prereqs> |
19
|
|
|
|
|
|
|
#pod attribute on your Dist::Zilla object is a Dist::Zilla::Prereqs object, and is |
20
|
|
|
|
|
|
|
#pod responsible for keeping track of the distribution's prerequisites. |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod In fact, a Dist::Zilla::Prereqs object is just a thin layer over a |
23
|
|
|
|
|
|
|
#pod L<CPAN::Meta::Prereqs> object, stored in the C<cpan_meta_prereqs> attribute. |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod Almost everything this object does is proxied to the CPAN::Meta::Prereqs |
26
|
|
|
|
|
|
|
#pod object, so you should really read how I<that> works. |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod Dist::Zilla::Prereqs proxies the following methods to the CPAN::Meta::Prereqs |
29
|
|
|
|
|
|
|
#pod object: |
30
|
|
|
|
|
|
|
#pod |
31
|
|
|
|
|
|
|
#pod =for :list |
32
|
|
|
|
|
|
|
#pod * finalize |
33
|
|
|
|
|
|
|
#pod * is_finalized |
34
|
|
|
|
|
|
|
#pod * requirements_for |
35
|
|
|
|
|
|
|
#pod * as_string_hash |
36
|
|
|
|
|
|
|
#pod |
37
|
|
|
|
|
|
|
#pod =cut |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has cpan_meta_prereqs => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => 'CPAN::Meta::Prereqs', |
42
|
|
|
|
|
|
|
init_arg => undef, |
43
|
|
|
|
|
|
|
default => sub { CPAN::Meta::Prereqs->new }, |
44
|
|
|
|
|
|
|
handles => [ qw( |
45
|
|
|
|
|
|
|
finalize |
46
|
|
|
|
|
|
|
is_finalized |
47
|
|
|
|
|
|
|
requirements_for |
48
|
|
|
|
|
|
|
as_string_hash |
49
|
|
|
|
|
|
|
) ], |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# storing this is sort of gross, but MakeMaker winds up needing the same data |
53
|
|
|
|
|
|
|
# anyway. -- xdg, 2013-10-22 |
54
|
|
|
|
|
|
|
# This does *not* contain configure requires, as MakeMaker explicitly should |
55
|
|
|
|
|
|
|
# not have it in its fallback prereqs. |
56
|
|
|
|
|
|
|
has merged_requires => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => 'CPAN::Meta::Requirements', |
59
|
|
|
|
|
|
|
init_arg => undef, |
60
|
|
|
|
|
|
|
default => sub { CPAN::Meta::Requirements->new }, |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#pod =method register_prereqs |
64
|
|
|
|
|
|
|
#pod |
65
|
|
|
|
|
|
|
#pod $prereqs->register_prereqs(%prereqs); |
66
|
|
|
|
|
|
|
#pod |
67
|
|
|
|
|
|
|
#pod $prereqs->register_prereqs(\%arg, %prereqs); |
68
|
|
|
|
|
|
|
#pod |
69
|
|
|
|
|
|
|
#pod This method adds new minimums to the prereqs object. If a hashref is the first |
70
|
|
|
|
|
|
|
#pod arg, it may have entries for C<phase> and C<type> to indicate what kind of |
71
|
|
|
|
|
|
|
#pod prereqs are being registered. (For more information on phase and type, see |
72
|
|
|
|
|
|
|
#pod L<CPAN::Meta::Spec>.) For example, you might say: |
73
|
|
|
|
|
|
|
#pod |
74
|
|
|
|
|
|
|
#pod $prereqs->register_prereqs( |
75
|
|
|
|
|
|
|
#pod { phase => 'test', type => 'recommends' }, |
76
|
|
|
|
|
|
|
#pod 'Test::Foo' => '1.23', |
77
|
|
|
|
|
|
|
#pod 'XML::YZZY' => '2.01', |
78
|
|
|
|
|
|
|
#pod ); |
79
|
|
|
|
|
|
|
#pod |
80
|
|
|
|
|
|
|
#pod If not given, phase and type default to runtime and requires, respectively. |
81
|
|
|
|
|
|
|
#pod |
82
|
|
|
|
|
|
|
#pod =cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub register_prereqs { |
85
|
336
|
|
|
336
|
1
|
3691
|
my $self = shift; |
86
|
336
|
50
|
|
|
|
914
|
my $arg = ref($_[0]) ? shift(@_) : {}; |
87
|
336
|
|
|
|
|
1400
|
my %prereq = @_; |
88
|
|
|
|
|
|
|
|
89
|
336
|
|
50
|
|
|
984
|
my $phase = $arg->{phase} || 'runtime'; |
90
|
336
|
|
100
|
|
|
964
|
my $type = $arg->{type} || 'requires'; |
91
|
|
|
|
|
|
|
|
92
|
336
|
|
|
|
|
1251
|
my $req = $self->requirements_for($phase, $type); |
93
|
|
|
|
|
|
|
|
94
|
336
|
|
|
|
|
20661
|
while (my ($package, $version) = each %prereq) { |
95
|
820
|
|
100
|
|
|
43863
|
$req->add_string_requirement($package, $version || 0); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
336
|
|
|
|
|
32591
|
return; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
before 'finalize' => sub { |
102
|
|
|
|
|
|
|
my ($self) = @_; |
103
|
|
|
|
|
|
|
$self->sync_runtime_build_test_requires; |
104
|
|
|
|
|
|
|
}; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# this avoids a long-standing CPAN.pm bug that incorrectly merges runtime and |
108
|
|
|
|
|
|
|
# "build" (build+test) requirements by ensuring requirements stay unified |
109
|
|
|
|
|
|
|
# across all three phases |
110
|
|
|
|
|
|
|
sub sync_runtime_build_test_requires { |
111
|
148
|
|
|
148
|
0
|
401
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
# first pass: generated merged requirements |
114
|
148
|
|
|
|
|
544
|
for my $phase ( qw/runtime build test/ ) { |
115
|
444
|
|
|
|
|
17571
|
my $req = $self->requirements_for($phase, 'requires'); |
116
|
444
|
|
|
|
|
37520
|
$self->merged_requires->add_requirements( $req ); |
117
|
|
|
|
|
|
|
}; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# second pass: update from merged requirements |
120
|
148
|
|
|
|
|
4483
|
for my $phase ( qw/runtime build test/ ) { |
121
|
444
|
|
|
|
|
13575
|
my $req = $self->requirements_for($phase, 'requires'); |
122
|
444
|
|
|
|
|
18524
|
for my $mod ( $req->required_modules ) { |
123
|
222
|
|
|
|
|
15957
|
$req->clear_requirement( $mod ); |
124
|
222
|
|
|
|
|
9170
|
$req->add_string_requirement( |
125
|
|
|
|
|
|
|
$mod => $self->merged_requires->requirements_for_module($mod) |
126
|
|
|
|
|
|
|
); |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
148
|
|
|
|
|
4467
|
return; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
134
|
|
|
|
|
|
|
1; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
__END__ |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=pod |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=encoding UTF-8 |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 NAME |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Dist::Zilla::Prereqs - the prerequisites of a Dist::Zilla distribution |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 VERSION |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
version 6.029 |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 DESCRIPTION |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Dist::Zilla::Prereqs is a subcomponent of Dist::Zilla. The C<prereqs> |
153
|
|
|
|
|
|
|
attribute on your Dist::Zilla object is a Dist::Zilla::Prereqs object, and is |
154
|
|
|
|
|
|
|
responsible for keeping track of the distribution's prerequisites. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
In fact, a Dist::Zilla::Prereqs object is just a thin layer over a |
157
|
|
|
|
|
|
|
L<CPAN::Meta::Prereqs> object, stored in the C<cpan_meta_prereqs> attribute. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Almost everything this object does is proxied to the CPAN::Meta::Prereqs |
160
|
|
|
|
|
|
|
object, so you should really read how I<that> works. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
Dist::Zilla::Prereqs proxies the following methods to the CPAN::Meta::Prereqs |
163
|
|
|
|
|
|
|
object: |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 4 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
finalize |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
is_finalized |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
requirements_for |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
as_string_hash |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=back |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 PERL VERSION |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
This module should work on any version of perl still receiving updates from |
188
|
|
|
|
|
|
|
the Perl 5 Porters. This means it should work on any version of perl released |
189
|
|
|
|
|
|
|
in the last two to three years. (That is, if the most recently released |
190
|
|
|
|
|
|
|
version is v5.40, then this module should work on both v5.40 and v5.38.) |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Although it may work on older versions of perl, no guarantee is made that the |
193
|
|
|
|
|
|
|
minimum required version will not be increased. The version may be increased |
194
|
|
|
|
|
|
|
for any reason, and there is no promise that patches will be accepted to lower |
195
|
|
|
|
|
|
|
the minimum required perl. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 METHODS |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 register_prereqs |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
$prereqs->register_prereqs(%prereqs); |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
$prereqs->register_prereqs(\%arg, %prereqs); |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This method adds new minimums to the prereqs object. If a hashref is the first |
206
|
|
|
|
|
|
|
arg, it may have entries for C<phase> and C<type> to indicate what kind of |
207
|
|
|
|
|
|
|
prereqs are being registered. (For more information on phase and type, see |
208
|
|
|
|
|
|
|
L<CPAN::Meta::Spec>.) For example, you might say: |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
$prereqs->register_prereqs( |
211
|
|
|
|
|
|
|
{ phase => 'test', type => 'recommends' }, |
212
|
|
|
|
|
|
|
'Test::Foo' => '1.23', |
213
|
|
|
|
|
|
|
'XML::YZZY' => '2.01', |
214
|
|
|
|
|
|
|
); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
If not given, phase and type default to runtime and requires, respectively. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=head1 AUTHOR |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Ricardo SIGNES 😏 <cpan@semiotic.systems> |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Ricardo SIGNES. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
227
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=cut |