Debian Codegraph @

README

raw
1 NAME
2 CPAN::Meta::Requirements - a set of version requirements for a CPAN dist
3
4 VERSION
5 version 2.145
6
7 SYNOPSIS
8 use CPAN::Meta::Requirements;
9
10 my $build_requires = CPAN::Meta::Requirements->new;
11
12 $build_requires->add_minimum('Library::Foo' => 1.208);
13
14 $build_requires->add_minimum('Library::Foo' => 2.602);
15
16 $build_requires->add_minimum('Module::Bar' => 'v1.2.3');
17
18 $METAyml->{build_requires} = $build_requires->as_string_hash;
19
20 DESCRIPTION
21 A CPAN::Meta::Requirements object models a set of version constraints
22 like those specified in the META.yml or META.json files in CPAN
23 distributions, and as defined by CPAN::Meta::Spec. It can be built up by
24 adding more and more constraints, and it will reduce them to the
25 simplest representation.
26
27 Logically impossible constraints will be identified immediately by
28 thrown exceptions.
29
30 METHODS
31 new
32 my $req = CPAN::Meta::Requirements->new;
33
34 This returns a new CPAN::Meta::Requirements object. It takes an optional
35 hash reference argument. Currently, only one key is supported:
36
37 * "bad_version_hook" -- if provided, when a version cannot be parsed
38 into a version object, this code reference will be called with the
39 invalid version string as first argument, and the module name as
40 second argument. It must return a valid version object.
41
42 All other keys are ignored.
43
44 add_minimum
45 $req->add_minimum( $module => $version );
46
47 This adds a new minimum version requirement. If the new requirement is
48 redundant to the existing specification, this has no effect.
49
50 Minimum requirements are inclusive. $version is required, along with any
51 greater version number.
52
53 This method returns the requirements object.
54
55 add_maximum
56 $req->add_maximum( $module => $version );
57
58 This adds a new maximum version requirement. If the new requirement is
59 redundant to the existing specification, this has no effect.
60
61 Maximum requirements are inclusive. No version strictly greater than the
62 given version is allowed.
63
64 This method returns the requirements object.
65
66 add_exclusion
67 $req->add_exclusion( $module => $version );
68
69 This adds a new excluded version. For example, you might use these three
70 method calls:
71
72 $req->add_minimum( $module => '1.00' );
73 $req->add_maximum( $module => '1.82' );
74
75 $req->add_exclusion( $module => '1.75' );
76
77 Any version between 1.00 and 1.82 inclusive would be acceptable, except
78 for 1.75.
79
80 This method returns the requirements object.
81
82 exact_version
83 $req->exact_version( $module => $version );
84
85 This sets the version required for the given module to *exactly* the
86 given version. No other version would be considered acceptable.
87
88 This method returns the requirements object.
89
90 version_range_for_module
91 $req->version_range_for_module( $another_req_object );
92
93 add_requirements
94 $req->add_requirements( $another_req_object );
95
96 This method adds all the requirements in the given
97 CPAN::Meta::Requirements object to the requirements object on which it
98 was called. If there are any conflicts, an exception is thrown.
99
100 This method returns the requirements object.
101
102 accepts_module
103 my $bool = $req->accepts_module($module => $version);
104
105 Given an module and version, this method returns true if the version
106 specification for the module accepts the provided version. In other
107 words, given:
108
109 Module => '>= 1.00, < 2.00'
110
111 We will accept 1.00 and 1.75 but not 0.50 or 2.00.
112
113 For modules that do not appear in the requirements, this method will
114 return true.
115
116 clear_requirement
117 $req->clear_requirement( $module );
118
119 This removes the requirement for a given module from the object.
120
121 This method returns the requirements object.
122
123 requirements_for_module
124 $req->requirements_for_module( $module );
125
126 This returns a string containing the version requirements for a given
127 module in the format described in CPAN::Meta::Spec or undef if the given
128 module has no requirements. This should only be used for informational
129 purposes such as error messages and should not be interpreted or used
130 for comparison (see "accepts_module" instead).
131
132 structured_requirements_for_module
133 $req->structured_requirements_for_module( $module );
134
135 This returns a data structure containing the version requirements for a
136 given module or undef if the given module has no requirements. This
137 should not be used for version checks (see "accepts_module" instead).
138
139 Added in version 2.134.
140
141 required_modules
142 This method returns a list of all the modules for which requirements
143 have been specified.
144
145 clone
146 $req->clone;
147
148 This method returns a clone of the invocant. The clone and the original
149 object can then be changed independent of one another.
150
151 is_simple
152 This method returns true if and only if all requirements are inclusive
153 minimums -- that is, if their string expression is just the version
154 number.
155
156 is_finalized
157 This method returns true if the requirements have been finalized by
158 having the "finalize" method called on them.
159
160 finalize
161 This method marks the requirements finalized. Subsequent attempts to
162 change the requirements will be fatal, *if* they would result in a
163 change. If they would not alter the requirements, they have no effect.
164
165 If a finalized set of requirements is cloned, the cloned requirements
166 are not also finalized.
167
168 as_string_hash
169 This returns a reference to a hash describing the requirements using the
170 strings in the CPAN::Meta::Spec specification.
171
172 For example after the following program:
173
174 my $req = CPAN::Meta::Requirements->new;
175
176 $req->add_minimum('CPAN::Meta::Requirements' => 0.102);
177
178 $req->add_minimum('Library::Foo' => 1.208);
179
180 $req->add_maximum('Library::Foo' => 2.602);
181
182 $req->add_minimum('Module::Bar' => 'v1.2.3');
183
184 $req->add_exclusion('Module::Bar' => 'v1.2.8');
185
186 $req->exact_version('Xyzzy' => '6.01');
187
188 my $hashref = $req->as_string_hash;
189
190 $hashref would contain:
191
192 {
193 'CPAN::Meta::Requirements' => '0.102',
194 'Library::Foo' => '>= 1.208, <= 2.206',
195 'Module::Bar' => '>= v1.2.3, != v1.2.8',
196 'Xyzzy' => '== 6.01',
197 }
198
199 add_string_requirement
200 $req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206');
201 $req->add_string_requirement('Library::Foo' => v1.208);
202
203 This method parses the passed in string and adds the appropriate
204 requirement for the given module. A version can be a Perl "v-string". It
205 understands version ranges as described in the "Version Ranges" in
206 CPAN::Meta::Spec. For example:
207
208 1.3
209 >= 1.3
210 <= 1.3
211 == 1.3
212 != 1.3
213 > 1.3
214 < 1.3
215 >= 1.3, != 1.5, <= 2.0
216 A version number without an operator is equivalent to specifying a
217 minimum (">="). Extra whitespace is allowed.
218
219 from_string_hash
220 my $req = CPAN::Meta::Requirements->from_string_hash( \%hash );
221 my $req = CPAN::Meta::Requirements->from_string_hash( \%hash, \%opts );
222
223 This is an alternate constructor for a CPAN::Meta::Requirements object.
224 It takes a hash of module names and version requirement strings and
225 returns a new CPAN::Meta::Requirements object. As with
226 add_string_requirement, a version can be a Perl "v-string". Optionally,
227 you can supply a hash-reference of options, exactly as with the "new"
228 method.
229
230 SUPPORT
231 Bugs / Feature Requests
232 Please report any bugs or feature requests through the issue tracker at
233 <https://github.com/Perl-Toolchain-Gang/CPAN-Meta-Requirements/issues>.
234 You will be notified automatically of any progress on your issue.
235
236 Source Code
237 This is open source software. The code repository is available for
238 public review and contribution under the terms of the license.
239
240 <https://github.com/Perl-Toolchain-Gang/CPAN-Meta-Requirements>
241
242 git clone https://github.com/Perl-Toolchain-Gang/CPAN-Meta-Requirements.git
243
244 AUTHORS
245 * David Golden <[email protected]>
246
247 * Ricardo Signes <[email protected]>
248
249 CONTRIBUTORS
250 * Ed J <[email protected]>
251
252 * Graham Knop <[email protected]>
253
254 * Karen Etheridge <[email protected]>
255
256 * Leon Timmermans <[email protected]>
257
258 * Paul Howarth <[email protected]>
259
260 * Philippe Bruhat (BooK) <[email protected]>
261
262 * Ricardo Signes <[email protected]>
263
264 * robario <[email protected]>
265
266 * Tatsuhiko Miyagawa <[email protected]>
267
268 COPYRIGHT AND LICENSE
269 This software is copyright (c) 2010 by David Golden and Ricardo Signes.
270
271 This is free software; you can redistribute it and/or modify it under
272 the same terms as the Perl 5 programming language system itself.
273