Filename | C:/tmp64ng/perl/lib/CPAN/Meta/Requirements.pm |
Statements | Executed 2506 statements in 0s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 0s | 0s | BEGIN@1 | CPAN::Meta::Prereqs::
1 | 1 | 1 | 0s | 0s | BEGIN@2 | CPAN::Meta::Prereqs::
1 | 1 | 1 | 0s | 0s | BEGIN@209 | CPAN::Meta::Requirements::
1 | 1 | 1 | 0s | 0s | BEGIN@224 | CPAN::Meta::Requirements::
1 | 1 | 1 | 0s | 0s | BEGIN@35 | CPAN::Meta::Requirements::
1 | 1 | 1 | 0s | 0s | BEGIN@43 | CPAN::Meta::Requirements::
48 | 2 | 1 | 0s | 0s | CORE:match (opcode) | CPAN::Meta::Requirements::
39 | 1 | 1 | 0s | 0s | CORE:qr (opcode) | CPAN::Meta::Requirements::
39 | 1 | 1 | 0s | 0s | CORE:regcomp (opcode) | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | _accepts | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | _clone | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | _new | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | as_modifiers | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | as_string | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | with_exact_version | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | with_exclusion | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | with_maximum | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | with_minimum | CPAN::Meta::Requirements::_Range::Exact::
0 | 0 | 0 | 0s | 0s | _accepts | CPAN::Meta::Requirements::_Range::Range::
48 | 1 | 1 | 0s | 0s | _clone | CPAN::Meta::Requirements::_Range::Range::
0 | 0 | 0 | 0s | 0s | _self | CPAN::Meta::Requirements::_Range::Range::
48 | 1 | 1 | 0s | 0s | _simplify | CPAN::Meta::Requirements::_Range::Range::
9 | 1 | 1 | 0s | 0s | as_modifiers | CPAN::Meta::Requirements::_Range::Range::
39 | 1 | 1 | 0s | 0s | as_string | CPAN::Meta::Requirements::_Range::Range::
0 | 0 | 0 | 0s | 0s | with_exact_version | CPAN::Meta::Requirements::_Range::Range::
0 | 0 | 0 | 0s | 0s | with_exclusion | CPAN::Meta::Requirements::_Range::Range::
0 | 0 | 0 | 0s | 0s | with_maximum | CPAN::Meta::Requirements::_Range::Range::
48 | 2 | 1 | 0s | 0s | with_minimum | CPAN::Meta::Requirements::_Range::Range::
0 | 0 | 0 | 0s | 0s | __ANON__[:129] | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | __ANON__[:222] | CPAN::Meta::Requirements::
9 | 1 | 1 | 0s | 0s | __ANON__[:51] | CPAN::Meta::Requirements::
57 | 3 | 1 | 0s | 0s | __entry_for | CPAN::Meta::Requirements::
9 | 1 | 1 | 0s | 0s | __modify_entry_for | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | _blank_carp | CPAN::Meta::Requirements::
39 | 1 | 1 | 0s | 0s | _find_magic_vstring | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | _isa_version | CPAN::Meta::Requirements::
9 | 1 | 1 | 0s | 0s | _version_object | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | accepts_module | CPAN::Meta::Requirements::
48 | 2 | 1 | 0s | 0s | add_minimum | CPAN::Meta::Requirements::
9 | 1 | 1 | 0s | 0s | add_requirements | CPAN::Meta::Requirements::
39 | 2 | 2 | 0s | 0s | add_string_requirement | CPAN::Meta::Requirements::
54 | 2 | 1 | 0s | 0s | as_string_hash | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | clear_requirement | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | clone | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | finalize | CPAN::Meta::Requirements::
18 | 2 | 1 | 0s | 0s | from_string_hash | CPAN::Meta::Requirements::
48 | 2 | 1 | 0s | 0s | is_finalized | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | is_simple | CPAN::Meta::Requirements::
63 | 2 | 2 | 0s | 0s | new | CPAN::Meta::Requirements::
63 | 2 | 1 | 0s | 0s | required_modules | CPAN::Meta::Requirements::
0 | 0 | 0 | 0s | 0s | requirements_for_module | CPAN::Meta::Requirements::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::Prereqs::BEGIN@1 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 1 # spent 0s making 1 call to CPAN::Meta::Prereqs::BEGIN@1
# spent 0s making 1 call to strict::import |
2 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::Prereqs::BEGIN@2 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 2 # spent 0s making 1 call to CPAN::Meta::Prereqs::BEGIN@2
# spent 0s making 1 call to warnings::import |
3 | package CPAN::Meta::Requirements; | ||||
4 | # ABSTRACT: a set of version requirements for a CPAN dist | ||||
5 | |||||
6 | 1 | 0s | our $VERSION = '2.132'; | ||
7 | |||||
8 | #pod =head1 SYNOPSIS | ||||
9 | #pod | ||||
10 | #pod use CPAN::Meta::Requirements; | ||||
11 | #pod | ||||
12 | #pod my $build_requires = CPAN::Meta::Requirements->new; | ||||
13 | #pod | ||||
14 | #pod $build_requires->add_minimum('Library::Foo' => 1.208); | ||||
15 | #pod | ||||
16 | #pod $build_requires->add_minimum('Library::Foo' => 2.602); | ||||
17 | #pod | ||||
18 | #pod $build_requires->add_minimum('Module::Bar' => 'v1.2.3'); | ||||
19 | #pod | ||||
20 | #pod $METAyml->{build_requires} = $build_requires->as_string_hash; | ||||
21 | #pod | ||||
22 | #pod =head1 DESCRIPTION | ||||
23 | #pod | ||||
24 | #pod A CPAN::Meta::Requirements object models a set of version constraints like | ||||
25 | #pod those specified in the F<META.yml> or F<META.json> files in CPAN distributions, | ||||
26 | #pod and as defined by L<CPAN::Meta::Spec>; | ||||
27 | #pod It can be built up by adding more and more constraints, and it will reduce them | ||||
28 | #pod to the simplest representation. | ||||
29 | #pod | ||||
30 | #pod Logically impossible constraints will be identified immediately by thrown | ||||
31 | #pod exceptions. | ||||
32 | #pod | ||||
33 | #pod =cut | ||||
34 | |||||
35 | 2 | 0s | 1 | 0s | # spent 0s within CPAN::Meta::Requirements::BEGIN@35 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 35 # spent 0s making 1 call to CPAN::Meta::Requirements::BEGIN@35 |
36 | |||||
37 | # To help ExtUtils::MakeMaker bootstrap CPAN::Meta::Requirements on perls | ||||
38 | # before 5.10, we fall back to the EUMM bundled compatibility version module if | ||||
39 | # that's the only thing available. This shouldn't ever happen in a normal CPAN | ||||
40 | # install of CPAN::Meta::Requirements, as version.pm will be picked up from | ||||
41 | # prereqs and be available at runtime. | ||||
42 | |||||
43 | # spent 0s within CPAN::Meta::Requirements::BEGIN@43 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 48 | ||||
44 | 1 | 0s | eval "use version ()"; ## no critic # spent 0s executing statements in string eval # includes 0s spent executing 1 call to 1 sub defined therein. | ||
45 | 1 | 0s | if ( my $err = $@ ) { | ||
46 | eval "use ExtUtils::MakeMaker::version" or die $err; ## no critic | ||||
47 | } | ||||
48 | 1 | 0s | 1 | 0s | } # spent 0s making 1 call to CPAN::Meta::Requirements::BEGIN@43 |
49 | |||||
50 | # Perl 5.10.0 didn't have "is_qv" in version.pm | ||||
51 | 10 | 0s | 10 | 0s | # spent 0s within CPAN::Meta::Requirements::__ANON__[C:/tmp64ng/perl/lib/CPAN/Meta/Requirements.pm:51] which was called 9 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Requirements::_version_object at line 150, avg 0s/call # spent 0s making 1 call to UNIVERSAL::can
# spent 0s making 9 calls to version::is_qv, avg 0s/call |
52 | |||||
53 | # construct once, reuse many times | ||||
54 | 1 | 0s | 1 | 0s | my $V0 = version->new(0); # spent 0s making 1 call to version::vxs::new |
55 | |||||
56 | #pod =method new | ||||
57 | #pod | ||||
58 | #pod my $req = CPAN::Meta::Requirements->new; | ||||
59 | #pod | ||||
60 | #pod This returns a new CPAN::Meta::Requirements object. It takes an optional | ||||
61 | #pod hash reference argument. Currently, only one key is supported: | ||||
62 | #pod | ||||
63 | #pod =for :list | ||||
64 | #pod * C<bad_version_hook> -- if provided, when a version cannot be parsed into | ||||
65 | #pod a version object, this code reference will be called with the invalid | ||||
66 | #pod version string as first argument, and the module name as second | ||||
67 | #pod argument. It must return a valid version object. | ||||
68 | #pod | ||||
69 | #pod All other keys are ignored. | ||||
70 | #pod | ||||
71 | #pod =cut | ||||
72 | |||||
73 | 1 | 0s | my @valid_options = qw( bad_version_hook ); | ||
74 | |||||
75 | # spent 0s within CPAN::Meta::Requirements::new which was called 63 times, avg 0s/call:
# 45 times (0s+0s) by CPAN::Meta::Converter::_version_map at line 401 of CPAN/Meta/Converter.pm, avg 0s/call
# 18 times (0s+0s) by CPAN::Meta::Requirements::from_string_hash at line 565, avg 0s/call | ||||
76 | 63 | 0s | my ($class, $options) = @_; | ||
77 | 63 | 0s | $options ||= {}; | ||
78 | 63 | 0s | Carp::croak "Argument to $class\->new() must be a hash reference" | ||
79 | unless ref $options eq 'HASH'; | ||||
80 | 63 | 0s | my %self = map {; $_ => $options->{$_}} @valid_options; | ||
81 | |||||
82 | 63 | 0s | return bless \%self => $class; | ||
83 | } | ||||
84 | |||||
85 | # from version::vpp | ||||
86 | # spent 0s within CPAN::Meta::Requirements::_find_magic_vstring which was called 39 times, avg 0s/call:
# 39 times (0s+0s) by CPAN::Meta::Requirements::add_string_requirement at line 521, avg 0s/call | ||||
87 | 39 | 0s | my $value = shift; | ||
88 | 39 | 0s | my $tvalue = ''; | ||
89 | 39 | 0s | require B; | ||
90 | 39 | 0s | 39 | 0s | my $sv = B::svref_2object(\$value); # spent 0s making 39 calls to B::svref_2object, avg 0s/call |
91 | 39 | 0s | my $magic = ref($sv) eq 'B::PVMG' ? $sv->MAGIC : undef; | ||
92 | 39 | 0s | while ( $magic ) { | ||
93 | if ( $magic->TYPE eq 'V' ) { | ||||
94 | $tvalue = $magic->PTR; | ||||
95 | $tvalue =~ s/^v?(.+)$/v$1/; | ||||
96 | last; | ||||
97 | } | ||||
98 | else { | ||||
99 | $magic = $magic->MOREMAGIC; | ||||
100 | } | ||||
101 | } | ||||
102 | 39 | 0s | return $tvalue; | ||
103 | } | ||||
104 | |||||
105 | # safe if given an unblessed reference | ||||
106 | sub _isa_version { | ||||
107 | UNIVERSAL::isa( $_[0], 'UNIVERSAL' ) && $_[0]->isa('version') | ||||
108 | } | ||||
109 | |||||
110 | # spent 0s within CPAN::Meta::Requirements::_version_object which was called 9 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Requirements::add_minimum at line 241, avg 0s/call | ||||
111 | 9 | 0s | my ($self, $module, $version) = @_; | ||
112 | |||||
113 | 9 | 0s | my $vobj; | ||
114 | |||||
115 | # hack around version::vpp not handling <3 character vstring literals | ||||
116 | 9 | 0s | if ( $INC{'version/vpp.pm'} || $INC{'ExtUtils/MakeMaker/version/vpp.pm'} ) { | ||
117 | my $magic = _find_magic_vstring( $version ); | ||||
118 | $version = $magic if length $magic; | ||||
119 | } | ||||
120 | |||||
121 | 9 | 0s | eval { | ||
122 | 9 | 0s | if (not defined $version or (!ref($version) && $version eq '0')) { | ||
123 | $vobj = $V0; | ||||
124 | } | ||||
125 | elsif ( ref($version) eq 'version' || _isa_version($version) ) { | ||||
126 | $vobj = $version; | ||||
127 | } | ||||
128 | else { | ||||
129 | local $SIG{__WARN__} = sub { die "Invalid version: $_[0]" }; | ||||
130 | $vobj = version->new($version); | ||||
131 | } | ||||
132 | }; | ||||
133 | |||||
134 | 9 | 0s | if ( my $err = $@ ) { | ||
135 | my $hook = $self->{bad_version_hook}; | ||||
136 | $vobj = eval { $hook->($version, $module) } | ||||
137 | if ref $hook eq 'CODE'; | ||||
138 | unless (eval { $vobj->isa("version") }) { | ||||
139 | $err =~ s{ at .* line \d+.*$}{}; | ||||
140 | die "Can't convert '$version': $err"; | ||||
141 | } | ||||
142 | } | ||||
143 | |||||
144 | # ensure no leading '.' | ||||
145 | 9 | 0s | 18 | 0s | if ( $vobj =~ m{\A\.} ) { # spent 0s making 9 calls to CPAN::Meta::Requirements::CORE:match, avg 0s/call
# spent 0s making 9 calls to version::vxs::stringify, avg 0s/call |
146 | $vobj = version->new("0$vobj"); | ||||
147 | } | ||||
148 | |||||
149 | # ensure normal v-string form | ||||
150 | 9 | 0s | 9 | 0s | if ( _is_qv($vobj) ) { # spent 0s making 9 calls to CPAN::Meta::Requirements::__ANON__[CPAN/Meta/Requirements.pm:51], avg 0s/call |
151 | $vobj = version->new($vobj->normal); | ||||
152 | } | ||||
153 | |||||
154 | 9 | 0s | return $vobj; | ||
155 | } | ||||
156 | |||||
157 | #pod =method add_minimum | ||||
158 | #pod | ||||
159 | #pod $req->add_minimum( $module => $version ); | ||||
160 | #pod | ||||
161 | #pod This adds a new minimum version requirement. If the new requirement is | ||||
162 | #pod redundant to the existing specification, this has no effect. | ||||
163 | #pod | ||||
164 | #pod Minimum requirements are inclusive. C<$version> is required, along with any | ||||
165 | #pod greater version number. | ||||
166 | #pod | ||||
167 | #pod This method returns the requirements object. | ||||
168 | #pod | ||||
169 | #pod =method add_maximum | ||||
170 | #pod | ||||
171 | #pod $req->add_maximum( $module => $version ); | ||||
172 | #pod | ||||
173 | #pod This adds a new maximum version requirement. If the new requirement is | ||||
174 | #pod redundant to the existing specification, this has no effect. | ||||
175 | #pod | ||||
176 | #pod Maximum requirements are inclusive. No version strictly greater than the given | ||||
177 | #pod version is allowed. | ||||
178 | #pod | ||||
179 | #pod This method returns the requirements object. | ||||
180 | #pod | ||||
181 | #pod =method add_exclusion | ||||
182 | #pod | ||||
183 | #pod $req->add_exclusion( $module => $version ); | ||||
184 | #pod | ||||
185 | #pod This adds a new excluded version. For example, you might use these three | ||||
186 | #pod method calls: | ||||
187 | #pod | ||||
188 | #pod $req->add_minimum( $module => '1.00' ); | ||||
189 | #pod $req->add_maximum( $module => '1.82' ); | ||||
190 | #pod | ||||
191 | #pod $req->add_exclusion( $module => '1.75' ); | ||||
192 | #pod | ||||
193 | #pod Any version between 1.00 and 1.82 inclusive would be acceptable, except for | ||||
194 | #pod 1.75. | ||||
195 | #pod | ||||
196 | #pod This method returns the requirements object. | ||||
197 | #pod | ||||
198 | #pod =method exact_version | ||||
199 | #pod | ||||
200 | #pod $req->exact_version( $module => $version ); | ||||
201 | #pod | ||||
202 | #pod This sets the version required for the given module to I<exactly> the given | ||||
203 | #pod version. No other version would be considered acceptable. | ||||
204 | #pod | ||||
205 | #pod This method returns the requirements object. | ||||
206 | #pod | ||||
207 | #pod =cut | ||||
208 | |||||
209 | # spent 0s within CPAN::Meta::Requirements::BEGIN@209 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 227 | ||||
210 | 1 | 0s | for my $type (qw(maximum exclusion exact_version)) { | ||
211 | 3 | 0s | my $method = "with_$type"; | ||
212 | 3 | 0s | my $to_add = $type eq 'exact_version' ? $type : "add_$type"; | ||
213 | |||||
214 | my $code = sub { | ||||
215 | my ($self, $name, $version) = @_; | ||||
216 | |||||
217 | $version = $self->_version_object( $name, $version ); | ||||
218 | |||||
219 | $self->__modify_entry_for($name, $method, $version); | ||||
220 | |||||
221 | return $self; | ||||
222 | 3 | 0s | }; | ||
223 | |||||
224 | 2 | 0s | 2 | 0s | # spent 0s within CPAN::Meta::Requirements::BEGIN@224 which was called:
# once (0s+0s) by CPAN::Meta::Prereqs::BEGIN@17 at line 224 # spent 0s making 1 call to CPAN::Meta::Requirements::BEGIN@224
# spent 0s making 1 call to strict::unimport |
225 | 3 | 0s | *$to_add = $code; | ||
226 | } | ||||
227 | 1 | 0s | 1 | 0s | } # spent 0s making 1 call to CPAN::Meta::Requirements::BEGIN@209 |
228 | |||||
229 | sub add_minimum { | ||||
230 | 48 | 0s | my ($self, $name, $version) = @_; | ||
231 | |||||
232 | 48 | 0s | if (not defined $version or (!ref($version) && $version eq '0')) { | ||
233 | 39 | 0s | 39 | 0s | return $self if $self->__entry_for($name); # spent 0s making 39 calls to CPAN::Meta::Requirements::__entry_for, avg 0s/call |
234 | 39 | 0s | 39 | 0s | Carp::confess("can't add new requirements to finalized requirements") # spent 0s making 39 calls to CPAN::Meta::Requirements::is_finalized, avg 0s/call |
235 | if $self->is_finalized; | ||||
236 | |||||
237 | 39 | 0s | 39 | 0s | $self->{requirements}{ $name } = # spent 0s making 39 calls to CPAN::Meta::Requirements::_Range::Range::with_minimum, avg 0s/call |
238 | CPAN::Meta::Requirements::_Range::Range->with_minimum($V0); | ||||
239 | } | ||||
240 | else { | ||||
241 | 9 | 0s | 9 | 0s | $version = $self->_version_object( $name, $version ); # spent 0s making 9 calls to CPAN::Meta::Requirements::_version_object, avg 0s/call |
242 | |||||
243 | 9 | 0s | 9 | 0s | $self->__modify_entry_for($name, 'with_minimum', $version); # spent 0s making 9 calls to CPAN::Meta::Requirements::__modify_entry_for, avg 0s/call |
244 | } | ||||
245 | 48 | 0s | return $self; | ||
246 | } | ||||
247 | |||||
248 | #pod =method add_requirements | ||||
249 | #pod | ||||
250 | #pod $req->add_requirements( $another_req_object ); | ||||
251 | #pod | ||||
252 | #pod This method adds all the requirements in the given CPAN::Meta::Requirements object | ||||
253 | #pod to the requirements object on which it was called. If there are any conflicts, | ||||
254 | #pod an exception is thrown. | ||||
255 | #pod | ||||
256 | #pod This method returns the requirements object. | ||||
257 | #pod | ||||
258 | #pod =cut | ||||
259 | |||||
260 | # spent 0s within CPAN::Meta::Requirements::add_requirements which was called 9 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Converter::_get_build_requires at line 503 of CPAN/Meta/Converter.pm, avg 0s/call | ||||
261 | 9 | 0s | my ($self, $req) = @_; | ||
262 | |||||
263 | 9 | 0s | 9 | 0s | for my $module ($req->required_modules) { # spent 0s making 9 calls to CPAN::Meta::Requirements::required_modules, avg 0s/call |
264 | 9 | 0s | 18 | 0s | my $modifiers = $req->__entry_for($module)->as_modifiers; # spent 0s making 9 calls to CPAN::Meta::Requirements::_Range::Range::as_modifiers, avg 0s/call
# spent 0s making 9 calls to CPAN::Meta::Requirements::__entry_for, avg 0s/call |
265 | 9 | 0s | for my $modifier (@$modifiers) { | ||
266 | 9 | 0s | my ($method, @args) = @$modifier; | ||
267 | 9 | 0s | 9 | 0s | $self->$method($module => @args); # spent 0s making 9 calls to CPAN::Meta::Requirements::add_minimum, avg 0s/call |
268 | }; | ||||
269 | } | ||||
270 | |||||
271 | 9 | 0s | return $self; | ||
272 | } | ||||
273 | |||||
274 | #pod =method accepts_module | ||||
275 | #pod | ||||
276 | #pod my $bool = $req->accepts_module($module => $version); | ||||
277 | #pod | ||||
278 | #pod Given an module and version, this method returns true if the version | ||||
279 | #pod specification for the module accepts the provided version. In other words, | ||||
280 | #pod given: | ||||
281 | #pod | ||||
282 | #pod Module => '>= 1.00, < 2.00' | ||||
283 | #pod | ||||
284 | #pod We will accept 1.00 and 1.75 but not 0.50 or 2.00. | ||||
285 | #pod | ||||
286 | #pod For modules that do not appear in the requirements, this method will return | ||||
287 | #pod true. | ||||
288 | #pod | ||||
289 | #pod =cut | ||||
290 | |||||
291 | sub accepts_module { | ||||
292 | my ($self, $module, $version) = @_; | ||||
293 | |||||
294 | $version = $self->_version_object( $module, $version ); | ||||
295 | |||||
296 | return 1 unless my $range = $self->__entry_for($module); | ||||
297 | return $range->_accepts($version); | ||||
298 | } | ||||
299 | |||||
300 | #pod =method clear_requirement | ||||
301 | #pod | ||||
302 | #pod $req->clear_requirement( $module ); | ||||
303 | #pod | ||||
304 | #pod This removes the requirement for a given module from the object. | ||||
305 | #pod | ||||
306 | #pod This method returns the requirements object. | ||||
307 | #pod | ||||
308 | #pod =cut | ||||
309 | |||||
310 | sub clear_requirement { | ||||
311 | my ($self, $module) = @_; | ||||
312 | |||||
313 | return $self unless $self->__entry_for($module); | ||||
314 | |||||
315 | Carp::confess("can't clear requirements on finalized requirements") | ||||
316 | if $self->is_finalized; | ||||
317 | |||||
318 | delete $self->{requirements}{ $module }; | ||||
319 | |||||
320 | return $self; | ||||
321 | } | ||||
322 | |||||
323 | #pod =method requirements_for_module | ||||
324 | #pod | ||||
325 | #pod $req->requirements_for_module( $module ); | ||||
326 | #pod | ||||
327 | #pod This returns a string containing the version requirements for a given module in | ||||
328 | #pod the format described in L<CPAN::Meta::Spec> or undef if the given module has no | ||||
329 | #pod requirements. This should only be used for informational purposes such as error | ||||
330 | #pod messages and should not be interpreted or used for comparison (see | ||||
331 | #pod L</accepts_module> instead.) | ||||
332 | #pod | ||||
333 | #pod =cut | ||||
334 | |||||
335 | sub requirements_for_module { | ||||
336 | my ($self, $module) = @_; | ||||
337 | my $entry = $self->__entry_for($module); | ||||
338 | return unless $entry; | ||||
339 | return $entry->as_string; | ||||
340 | } | ||||
341 | |||||
342 | #pod =method required_modules | ||||
343 | #pod | ||||
344 | #pod This method returns a list of all the modules for which requirements have been | ||||
345 | #pod specified. | ||||
346 | #pod | ||||
347 | #pod =cut | ||||
348 | |||||
349 | 63 | 0s | sub required_modules { keys %{ $_[0]{requirements} } } | ||
350 | |||||
351 | #pod =method clone | ||||
352 | #pod | ||||
353 | #pod $req->clone; | ||||
354 | #pod | ||||
355 | #pod This method returns a clone of the invocant. The clone and the original object | ||||
356 | #pod can then be changed independent of one another. | ||||
357 | #pod | ||||
358 | #pod =cut | ||||
359 | |||||
360 | sub clone { | ||||
361 | my ($self) = @_; | ||||
362 | my $new = (ref $self)->new; | ||||
363 | |||||
364 | return $new->add_requirements($self); | ||||
365 | } | ||||
366 | |||||
367 | 57 | 0s | # spent 0s within CPAN::Meta::Requirements::__entry_for which was called 57 times, avg 0s/call:
# 39 times (0s+0s) by CPAN::Meta::Requirements::add_minimum at line 233, avg 0s/call
# 9 times (0s+0s) by CPAN::Meta::Requirements::add_requirements at line 264, avg 0s/call
# 9 times (0s+0s) by CPAN::Meta::Requirements::__modify_entry_for at line 373, avg 0s/call | ||
368 | |||||
369 | # spent 0s within CPAN::Meta::Requirements::__modify_entry_for which was called 9 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Requirements::add_minimum at line 243, avg 0s/call | ||||
370 | 9 | 0s | my ($self, $name, $method, $version) = @_; | ||
371 | |||||
372 | 9 | 0s | 9 | 0s | my $fin = $self->is_finalized; # spent 0s making 9 calls to CPAN::Meta::Requirements::is_finalized, avg 0s/call |
373 | 9 | 0s | 9 | 0s | my $old = $self->__entry_for($name); # spent 0s making 9 calls to CPAN::Meta::Requirements::__entry_for, avg 0s/call |
374 | |||||
375 | 9 | 0s | Carp::confess("can't add new requirements to finalized requirements") | ||
376 | if $fin and not $old; | ||||
377 | |||||
378 | 9 | 0s | 9 | 0s | my $new = ($old || 'CPAN::Meta::Requirements::_Range::Range') # spent 0s making 9 calls to CPAN::Meta::Requirements::_Range::Range::with_minimum, avg 0s/call |
379 | ->$method($version); | ||||
380 | |||||
381 | 9 | 0s | Carp::confess("can't modify finalized requirements") | ||
382 | if $fin and $old->as_string ne $new->as_string; | ||||
383 | |||||
384 | 9 | 0s | $self->{requirements}{ $name } = $new; | ||
385 | } | ||||
386 | |||||
387 | #pod =method is_simple | ||||
388 | #pod | ||||
389 | #pod This method returns true if and only if all requirements are inclusive minimums | ||||
390 | #pod -- that is, if their string expression is just the version number. | ||||
391 | #pod | ||||
392 | #pod =cut | ||||
393 | |||||
394 | sub is_simple { | ||||
395 | my ($self) = @_; | ||||
396 | for my $module ($self->required_modules) { | ||||
397 | # XXX: This is a complete hack, but also entirely correct. | ||||
398 | return if $self->__entry_for($module)->as_string =~ /\s/; | ||||
399 | } | ||||
400 | |||||
401 | return 1; | ||||
402 | } | ||||
403 | |||||
404 | #pod =method is_finalized | ||||
405 | #pod | ||||
406 | #pod This method returns true if the requirements have been finalized by having the | ||||
407 | #pod C<finalize> method called on them. | ||||
408 | #pod | ||||
409 | #pod =cut | ||||
410 | |||||
411 | 48 | 0s | sub is_finalized { $_[0]{finalized} } | ||
412 | |||||
413 | #pod =method finalize | ||||
414 | #pod | ||||
415 | #pod This method marks the requirements finalized. Subsequent attempts to change | ||||
416 | #pod the requirements will be fatal, I<if> they would result in a change. If they | ||||
417 | #pod would not alter the requirements, they have no effect. | ||||
418 | #pod | ||||
419 | #pod If a finalized set of requirements is cloned, the cloned requirements are not | ||||
420 | #pod also finalized. | ||||
421 | #pod | ||||
422 | #pod =cut | ||||
423 | |||||
424 | sub finalize { $_[0]{finalized} = 1 } | ||||
425 | |||||
426 | #pod =method as_string_hash | ||||
427 | #pod | ||||
428 | #pod This returns a reference to a hash describing the requirements using the | ||||
429 | #pod strings in the L<CPAN::Meta::Spec> specification. | ||||
430 | #pod | ||||
431 | #pod For example after the following program: | ||||
432 | #pod | ||||
433 | #pod my $req = CPAN::Meta::Requirements->new; | ||||
434 | #pod | ||||
435 | #pod $req->add_minimum('CPAN::Meta::Requirements' => 0.102); | ||||
436 | #pod | ||||
437 | #pod $req->add_minimum('Library::Foo' => 1.208); | ||||
438 | #pod | ||||
439 | #pod $req->add_maximum('Library::Foo' => 2.602); | ||||
440 | #pod | ||||
441 | #pod $req->add_minimum('Module::Bar' => 'v1.2.3'); | ||||
442 | #pod | ||||
443 | #pod $req->add_exclusion('Module::Bar' => 'v1.2.8'); | ||||
444 | #pod | ||||
445 | #pod $req->exact_version('Xyzzy' => '6.01'); | ||||
446 | #pod | ||||
447 | #pod my $hashref = $req->as_string_hash; | ||||
448 | #pod | ||||
449 | #pod C<$hashref> would contain: | ||||
450 | #pod | ||||
451 | #pod { | ||||
452 | #pod 'CPAN::Meta::Requirements' => '0.102', | ||||
453 | #pod 'Library::Foo' => '>= 1.208, <= 2.206', | ||||
454 | #pod 'Module::Bar' => '>= v1.2.3, != v1.2.8', | ||||
455 | #pod 'Xyzzy' => '== 6.01', | ||||
456 | #pod } | ||||
457 | #pod | ||||
458 | #pod =cut | ||||
459 | |||||
460 | # spent 0s within CPAN::Meta::Requirements::as_string_hash which was called 54 times, avg 0s/call:
# 45 times (0s+0s) by CPAN::Meta::Converter::_version_map at line 417 of CPAN/Meta/Converter.pm, avg 0s/call
# 9 times (0s+0s) by CPAN::Meta::Converter::_get_build_requires at line 503 of CPAN/Meta/Converter.pm, avg 0s/call | ||||
461 | 54 | 0s | my ($self) = @_; | ||
462 | |||||
463 | 54 | 0s | 93 | 0s | my %hash = map {; $_ => $self->{requirements}{$_}->as_string } # spent 0s making 39 calls to CPAN::Meta::Requirements::_Range::Range::as_string, avg 0s/call
# spent 0s making 54 calls to CPAN::Meta::Requirements::required_modules, avg 0s/call |
464 | $self->required_modules; | ||||
465 | |||||
466 | 54 | 0s | return \%hash; | ||
467 | } | ||||
468 | |||||
469 | #pod =method add_string_requirement | ||||
470 | #pod | ||||
471 | #pod $req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206'); | ||||
472 | #pod $req->add_string_requirement('Library::Foo' => v1.208); | ||||
473 | #pod | ||||
474 | #pod This method parses the passed in string and adds the appropriate requirement | ||||
475 | #pod for the given module. A version can be a Perl "v-string". It understands | ||||
476 | #pod version ranges as described in the L<CPAN::Meta::Spec/Version Ranges>. For | ||||
477 | #pod example: | ||||
478 | #pod | ||||
479 | #pod =over 4 | ||||
480 | #pod | ||||
481 | #pod =item 1.3 | ||||
482 | #pod | ||||
483 | #pod =item >= 1.3 | ||||
484 | #pod | ||||
485 | #pod =item <= 1.3 | ||||
486 | #pod | ||||
487 | #pod =item == 1.3 | ||||
488 | #pod | ||||
489 | #pod =item != 1.3 | ||||
490 | #pod | ||||
491 | #pod =item > 1.3 | ||||
492 | #pod | ||||
493 | #pod =item < 1.3 | ||||
494 | #pod | ||||
495 | #pod =item >= 1.3, != 1.5, <= 2.0 | ||||
496 | #pod | ||||
497 | #pod A version number without an operator is equivalent to specifying a minimum | ||||
498 | #pod (C<E<gt>=>). Extra whitespace is allowed. | ||||
499 | #pod | ||||
500 | #pod =back | ||||
501 | #pod | ||||
502 | #pod =cut | ||||
503 | |||||
504 | 1 | 0s | my %methods_for_op = ( | ||
505 | '==' => [ qw(exact_version) ], | ||||
506 | '!=' => [ qw(add_exclusion) ], | ||||
507 | '>=' => [ qw(add_minimum) ], | ||||
508 | '<=' => [ qw(add_maximum) ], | ||||
509 | '>' => [ qw(add_minimum add_exclusion) ], | ||||
510 | '<' => [ qw(add_maximum add_exclusion) ], | ||||
511 | ); | ||||
512 | |||||
513 | # spent 0s within CPAN::Meta::Requirements::add_string_requirement which was called 39 times, avg 0s/call:
# 30 times (0s+0s) by CPAN::Meta::Converter::_version_map at line 415 of CPAN/Meta/Converter.pm, avg 0s/call
# 9 times (0s+0s) by CPAN::Meta::Requirements::from_string_hash at line 573, avg 0s/call | ||||
514 | 39 | 0s | my ($self, $module, $req) = @_; | ||
515 | |||||
516 | 39 | 0s | unless ( defined $req && length $req ) { | ||
517 | $req = 0; | ||||
518 | $self->_blank_carp($module); | ||||
519 | } | ||||
520 | |||||
521 | 39 | 0s | 39 | 0s | my $magic = _find_magic_vstring( $req ); # spent 0s making 39 calls to CPAN::Meta::Requirements::_find_magic_vstring, avg 0s/call |
522 | 39 | 0s | if (length $magic) { | ||
523 | $self->add_minimum($module => $magic); | ||||
524 | return; | ||||
525 | } | ||||
526 | |||||
527 | 39 | 0s | 78 | 0s | my @parts = split qr{\s*,\s*}, $req; # spent 0s making 39 calls to CPAN::Meta::Requirements::CORE:qr, avg 0s/call
# spent 0s making 39 calls to CPAN::Meta::Requirements::CORE:regcomp, avg 0s/call |
528 | |||||
529 | 39 | 0s | for my $part (@parts) { | ||
530 | 39 | 0s | 39 | 0s | my ($op, $ver) = $part =~ m{\A\s*(==|>=|>|<=|<|!=)\s*(.*)\z}; # spent 0s making 39 calls to CPAN::Meta::Requirements::CORE:match, avg 0s/call |
531 | |||||
532 | 39 | 0s | 39 | 0s | if (! defined $op) { # spent 0s making 39 calls to CPAN::Meta::Requirements::add_minimum, avg 0s/call |
533 | $self->add_minimum($module => $part); | ||||
534 | } else { | ||||
535 | Carp::confess("illegal requirement string: $req") | ||||
536 | unless my $methods = $methods_for_op{ $op }; | ||||
537 | |||||
538 | $self->$_($module => $ver) for @$methods; | ||||
539 | } | ||||
540 | } | ||||
541 | } | ||||
542 | |||||
543 | #pod =method from_string_hash | ||||
544 | #pod | ||||
545 | #pod my $req = CPAN::Meta::Requirements->from_string_hash( \%hash ); | ||||
546 | #pod my $req = CPAN::Meta::Requirements->from_string_hash( \%hash, \%opts ); | ||||
547 | #pod | ||||
548 | #pod This is an alternate constructor for a CPAN::Meta::Requirements | ||||
549 | #pod object. It takes a hash of module names and version requirement | ||||
550 | #pod strings and returns a new CPAN::Meta::Requirements object. As with | ||||
551 | #pod add_string_requirement, a version can be a Perl "v-string". Optionally, | ||||
552 | #pod you can supply a hash-reference of options, exactly as with the L</new> | ||||
553 | #pod method. | ||||
554 | #pod | ||||
555 | #pod =cut | ||||
556 | |||||
557 | sub _blank_carp { | ||||
558 | my ($self, $module) = @_; | ||||
559 | Carp::carp("Undefined requirement for $module treated as '0'"); | ||||
560 | } | ||||
561 | |||||
562 | # spent 0s within CPAN::Meta::Requirements::from_string_hash which was called 18 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Converter::_get_build_requires at line 500 of CPAN/Meta/Converter.pm, avg 0s/call
# 9 times (0s+0s) by CPAN::Meta::Converter::_get_build_requires at line 501 of CPAN/Meta/Converter.pm, avg 0s/call | ||||
563 | 18 | 0s | my ($class, $hash, $options) = @_; | ||
564 | |||||
565 | 18 | 0s | 18 | 0s | my $self = $class->new($options); # spent 0s making 18 calls to CPAN::Meta::Requirements::new, avg 0s/call |
566 | |||||
567 | 18 | 0s | for my $module (keys %$hash) { | ||
568 | 9 | 0s | my $req = $hash->{$module}; | ||
569 | 9 | 0s | unless ( defined $req && length $req ) { | ||
570 | $req = 0; | ||||
571 | $class->_blank_carp($module); | ||||
572 | } | ||||
573 | 9 | 0s | 9 | 0s | $self->add_string_requirement($module, $req); # spent 0s making 9 calls to CPAN::Meta::Requirements::add_string_requirement, avg 0s/call |
574 | } | ||||
575 | |||||
576 | 18 | 0s | return $self; | ||
577 | } | ||||
578 | |||||
579 | ############################################################## | ||||
580 | |||||
581 | { | ||||
582 | 1 | 0s | package | ||
583 | CPAN::Meta::Requirements::_Range::Exact; | ||||
584 | sub _new { bless { version => $_[1] } => $_[0] } | ||||
585 | |||||
586 | sub _accepts { return $_[0]{version} == $_[1] } | ||||
587 | |||||
588 | sub as_string { return "== $_[0]{version}" } | ||||
589 | |||||
590 | sub as_modifiers { return [ [ exact_version => $_[0]{version} ] ] } | ||||
591 | |||||
592 | sub _clone { | ||||
593 | (ref $_[0])->_new( version->new( $_[0]{version} ) ) | ||||
594 | } | ||||
595 | |||||
596 | sub with_exact_version { | ||||
597 | my ($self, $version) = @_; | ||||
598 | |||||
599 | return $self->_clone if $self->_accepts($version); | ||||
600 | |||||
601 | Carp::confess("illegal requirements: unequal exact version specified"); | ||||
602 | } | ||||
603 | |||||
604 | sub with_minimum { | ||||
605 | my ($self, $minimum) = @_; | ||||
606 | return $self->_clone if $self->{version} >= $minimum; | ||||
607 | Carp::confess("illegal requirements: minimum above exact specification"); | ||||
608 | } | ||||
609 | |||||
610 | sub with_maximum { | ||||
611 | my ($self, $maximum) = @_; | ||||
612 | return $self->_clone if $self->{version} <= $maximum; | ||||
613 | Carp::confess("illegal requirements: maximum below exact specification"); | ||||
614 | } | ||||
615 | |||||
616 | sub with_exclusion { | ||||
617 | my ($self, $exclusion) = @_; | ||||
618 | return $self->_clone unless $exclusion == $self->{version}; | ||||
619 | Carp::confess("illegal requirements: excluded exact specification"); | ||||
620 | } | ||||
621 | } | ||||
622 | |||||
623 | ############################################################## | ||||
624 | |||||
625 | { | ||||
626 | 1 | 0s | package | ||
627 | CPAN::Meta::Requirements::_Range::Range; | ||||
628 | |||||
629 | sub _self { ref($_[0]) ? $_[0] : (bless { } => $_[0]) } | ||||
630 | |||||
631 | # spent 0s within CPAN::Meta::Requirements::_Range::Range::_clone which was called 48 times, avg 0s/call:
# 48 times (0s+0s) by CPAN::Meta::Requirements::_Range::Range::with_minimum at line 730, avg 0s/call | ||||
632 | 48 | 0s | return (bless { } => $_[0]) unless ref $_[0]; | ||
633 | |||||
634 | my ($s) = @_; | ||||
635 | my %guts = ( | ||||
636 | (exists $s->{minimum} ? (minimum => version->new($s->{minimum})) : ()), | ||||
637 | (exists $s->{maximum} ? (maximum => version->new($s->{maximum})) : ()), | ||||
638 | |||||
639 | (exists $s->{exclusions} | ||||
640 | ? (exclusions => [ map { version->new($_) } @{ $s->{exclusions} } ]) | ||||
641 | : ()), | ||||
642 | ); | ||||
643 | |||||
644 | bless \%guts => ref($s); | ||||
645 | } | ||||
646 | |||||
647 | # spent 0s within CPAN::Meta::Requirements::_Range::Range::as_modifiers which was called 9 times, avg 0s/call:
# 9 times (0s+0s) by CPAN::Meta::Requirements::add_requirements at line 264, avg 0s/call | ||||
648 | 9 | 0s | my ($self) = @_; | ||
649 | 9 | 0s | my @mods; | ||
650 | 9 | 0s | push @mods, [ add_minimum => $self->{minimum} ] if exists $self->{minimum}; | ||
651 | 9 | 0s | push @mods, [ add_maximum => $self->{maximum} ] if exists $self->{maximum}; | ||
652 | 9 | 0s | push @mods, map {; [ add_exclusion => $_ ] } @{$self->{exclusions} || []}; | ||
653 | 9 | 0s | return \@mods; | ||
654 | } | ||||
655 | |||||
656 | # spent 0s within CPAN::Meta::Requirements::_Range::Range::as_string which was called 39 times, avg 0s/call:
# 39 times (0s+0s) by CPAN::Meta::Requirements::as_string_hash at line 463, avg 0s/call | ||||
657 | 39 | 0s | my ($self) = @_; | ||
658 | |||||
659 | 39 | 0s | return 0 if ! keys %$self; | ||
660 | |||||
661 | 39 | 0s | 39 | 0s | return "$self->{minimum}" if (keys %$self) == 1 and exists $self->{minimum}; # spent 0s making 39 calls to version::vxs::stringify, avg 0s/call |
662 | |||||
663 | my @exclusions = @{ $self->{exclusions} || [] }; | ||||
664 | |||||
665 | my @parts; | ||||
666 | |||||
667 | for my $pair ( | ||||
668 | [ qw( >= > minimum ) ], | ||||
669 | [ qw( <= < maximum ) ], | ||||
670 | ) { | ||||
671 | my ($op, $e_op, $k) = @$pair; | ||||
672 | if (exists $self->{$k}) { | ||||
673 | my @new_exclusions = grep { $_ != $self->{ $k } } @exclusions; | ||||
674 | if (@new_exclusions == @exclusions) { | ||||
675 | push @parts, "$op $self->{ $k }"; | ||||
676 | } else { | ||||
677 | push @parts, "$e_op $self->{ $k }"; | ||||
678 | @exclusions = @new_exclusions; | ||||
679 | } | ||||
680 | } | ||||
681 | } | ||||
682 | |||||
683 | push @parts, map {; "!= $_" } @exclusions; | ||||
684 | |||||
685 | return join q{, }, @parts; | ||||
686 | } | ||||
687 | |||||
688 | sub with_exact_version { | ||||
689 | my ($self, $version) = @_; | ||||
690 | $self = $self->_clone; | ||||
691 | |||||
692 | Carp::confess("illegal requirements: exact specification outside of range") | ||||
693 | unless $self->_accepts($version); | ||||
694 | |||||
695 | return CPAN::Meta::Requirements::_Range::Exact->_new($version); | ||||
696 | } | ||||
697 | |||||
698 | # spent 0s within CPAN::Meta::Requirements::_Range::Range::_simplify which was called 48 times, avg 0s/call:
# 48 times (0s+0s) by CPAN::Meta::Requirements::_Range::Range::with_minimum at line 738, avg 0s/call | ||||
699 | 48 | 0s | my ($self) = @_; | ||
700 | |||||
701 | 48 | 0s | if (defined $self->{minimum} and defined $self->{maximum}) { | ||
702 | if ($self->{minimum} == $self->{maximum}) { | ||||
703 | Carp::confess("illegal requirements: excluded all values") | ||||
704 | if grep { $_ == $self->{minimum} } @{ $self->{exclusions} || [] }; | ||||
705 | |||||
706 | return CPAN::Meta::Requirements::_Range::Exact->_new($self->{minimum}) | ||||
707 | } | ||||
708 | |||||
709 | Carp::confess("illegal requirements: minimum exceeds maximum") | ||||
710 | if $self->{minimum} > $self->{maximum}; | ||||
711 | } | ||||
712 | |||||
713 | # eliminate irrelevant exclusions | ||||
714 | 48 | 0s | if ($self->{exclusions}) { | ||
715 | my %seen; | ||||
716 | @{ $self->{exclusions} } = grep { | ||||
717 | (! defined $self->{minimum} or $_ >= $self->{minimum}) | ||||
718 | and | ||||
719 | (! defined $self->{maximum} or $_ <= $self->{maximum}) | ||||
720 | and | ||||
721 | ! $seen{$_}++ | ||||
722 | } @{ $self->{exclusions} }; | ||||
723 | } | ||||
724 | |||||
725 | 48 | 0s | return $self; | ||
726 | } | ||||
727 | |||||
728 | sub with_minimum { | ||||
729 | 48 | 0s | my ($self, $minimum) = @_; | ||
730 | 48 | 0s | 48 | 0s | $self = $self->_clone; # spent 0s making 48 calls to CPAN::Meta::Requirements::_Range::Range::_clone, avg 0s/call |
731 | |||||
732 | 48 | 0s | if (defined (my $old_min = $self->{minimum})) { | ||
733 | $self->{minimum} = (sort { $b cmp $a } ($minimum, $old_min))[0]; | ||||
734 | } else { | ||||
735 | 48 | 0s | $self->{minimum} = $minimum; | ||
736 | } | ||||
737 | |||||
738 | 48 | 0s | 48 | 0s | return $self->_simplify; # spent 0s making 48 calls to CPAN::Meta::Requirements::_Range::Range::_simplify, avg 0s/call |
739 | } | ||||
740 | |||||
741 | sub with_maximum { | ||||
742 | my ($self, $maximum) = @_; | ||||
743 | $self = $self->_clone; | ||||
744 | |||||
745 | if (defined (my $old_max = $self->{maximum})) { | ||||
746 | $self->{maximum} = (sort { $a cmp $b } ($maximum, $old_max))[0]; | ||||
747 | } else { | ||||
748 | $self->{maximum} = $maximum; | ||||
749 | } | ||||
750 | |||||
751 | return $self->_simplify; | ||||
752 | } | ||||
753 | |||||
754 | sub with_exclusion { | ||||
755 | my ($self, $exclusion) = @_; | ||||
756 | $self = $self->_clone; | ||||
757 | |||||
758 | push @{ $self->{exclusions} ||= [] }, $exclusion; | ||||
759 | |||||
760 | return $self->_simplify; | ||||
761 | } | ||||
762 | |||||
763 | sub _accepts { | ||||
764 | my ($self, $version) = @_; | ||||
765 | |||||
766 | return if defined $self->{minimum} and $version < $self->{minimum}; | ||||
767 | return if defined $self->{maximum} and $version > $self->{maximum}; | ||||
768 | return if defined $self->{exclusions} | ||||
769 | and grep { $version == $_ } @{ $self->{exclusions} }; | ||||
770 | |||||
771 | return 1; | ||||
772 | } | ||||
773 | } | ||||
774 | |||||
775 | 1 | 0s | 1; | ||
776 | # vim: ts=2 sts=2 sw=2 et: | ||||
777 | |||||
778 | __END__ | ||||
sub CPAN::Meta::Requirements::CORE:match; # opcode | |||||
# spent 0s within CPAN::Meta::Requirements::CORE:qr which was called 39 times, avg 0s/call:
# 39 times (0s+0s) by CPAN::Meta::Requirements::add_string_requirement at line 527, avg 0s/call | |||||
# spent 0s within CPAN::Meta::Requirements::CORE:regcomp which was called 39 times, avg 0s/call:
# 39 times (0s+0s) by CPAN::Meta::Requirements::add_string_requirement at line 527, avg 0s/call |