Debian Codegraph @

upstream/debian-unstable/man3/CPAN::Meta::Requirements::Range.3perl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "CPAN::Meta::Requirements::Range 3perl"
58 .TH CPAN::Meta::Requirements::Range 3perl 2025-11-16 "perl v5.40.1" "Perl Programmers Reference Guide"
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 CPAN::Meta::Requirements::Range \- a set of version requirements for a CPAN dist
65 .SH VERSION
66 .IX Header "VERSION"
67 version 2.143
68 .SH SYNOPSIS
69 .IX Header "SYNOPSIS"
70 .Vb 1
71 \& use CPAN::Meta::Requirements::Range;
72 \&
73 \& my $range = CPAN::Meta::Requirements::Range\->with_minimum(1);
74 \&
75 \& $range = $range\->with_maximum(\*(Aqv2.2\*(Aq);
76 \&
77 \& my $stringified = $range\->as_string;
78 .Ve
79 .SH DESCRIPTION
80 .IX Header "DESCRIPTION"
81 A CPAN::Meta::Requirements::Range object models a set of version constraints like
82 those specified in the \fIMETA.yml\fR or \fIMETA.json\fR files in CPAN distributions,
83 and as defined by CPAN::Meta::Spec;
84 It can be built up by adding more and more constraints, and it will reduce them
85 to the simplest representation.
86 .PP
87 Logically impossible constraints will be identified immediately by thrown
88 exceptions.
89 .SH METHODS
90 .IX Header "METHODS"
91 .SS with_string_requirement
92 .IX Subsection "with_string_requirement"
93 .Vb 2
94 \& $req\->with_string_requirement(\*(Aq>= 1.208, <= 2.206\*(Aq);
95 \& $req\->with_string_requirement(v1.208);
96 .Ve
97 .PP
98 This method parses the passed in string and adds the appropriate requirement.
99 A version can be a Perl "v\-string". It understands version ranges as described
100 in the "Version Ranges" in CPAN::Meta::Spec. For example:
101 .IP 1.3 4
102 .IX Item "1.3"
103 .PD 0
104 .IP ">= 1.3" 4
105 .IX Item ">= 1.3"
106 .IP "<= 1.3" 4
107 .IX Item "<= 1.3"
108 .IP "== 1.3" 4
109 .IX Item "== 1.3"
110 .IP "!= 1.3" 4
111 .IX Item "!= 1.3"
112 .IP "> 1.3" 4
113 .IX Item "> 1.3"
114 .IP "< 1.3" 4
115 .IX Item "< 1.3"
116 .IP ">= 1.3, != 1.5, <= 2.0" 4
117 .IX Item ">= 1.3, != 1.5, <= 2.0"
118 .PD
119 A version number without an operator is equivalent to specifying a minimum
120 (\f(CW\*(C`>=\*(C'\fR). Extra whitespace is allowed.
121 .SS with_range
122 .IX Subsection "with_range"
123 .Vb 1
124 \& $range\->with_range($other_range)
125 .Ve
126 .PP
127 This creates a new range object that is a merge two others.
128 .SS with_exact_version
129 .IX Subsection "with_exact_version"
130 .Vb 1
131 \& $range\->with_exact_version( $version );
132 .Ve
133 .PP
134 This sets the version required to \fIexactly\fR the given
135 version. No other version would be considered acceptable.
136 .PP
137 This method returns the version range object.
138 .SS with_minimum
139 .IX Subsection "with_minimum"
140 .Vb 1
141 \& $range\->with_minimum( $version );
142 .Ve
143 .PP
144 This adds a new minimum version requirement. If the new requirement is
145 redundant to the existing specification, this has no effect.
146 .PP
147 Minimum requirements are inclusive. \f(CW$version\fR is required, along with any
148 greater version number.
149 .PP
150 This method returns the version range object.
151 .SS with_maximum
152 .IX Subsection "with_maximum"
153 .Vb 1
154 \& $range\->with_maximum( $version );
155 .Ve
156 .PP
157 This adds a new maximum version requirement. If the new requirement is
158 redundant to the existing specification, this has no effect.
159 .PP
160 Maximum requirements are inclusive. No version strictly greater than the given
161 version is allowed.
162 .PP
163 This method returns the version range object.
164 .SS with_exclusion
165 .IX Subsection "with_exclusion"
166 .Vb 1
167 \& $range\->with_exclusion( $version );
168 .Ve
169 .PP
170 This adds a new excluded version. For example, you might use these three
171 method calls:
172 .PP
173 .Vb 2
174 \& $range\->with_minimum( \*(Aq1.00\*(Aq );
175 \& $range\->with_maximum( \*(Aq1.82\*(Aq );
176 \&
177 \& $range\->with_exclusion( \*(Aq1.75\*(Aq );
178 .Ve
179 .PP
180 Any version between 1.00 and 1.82 inclusive would be acceptable, except for
181 1.75.
182 .PP
183 This method returns the requirements object.
184 .SS as_struct
185 .IX Subsection "as_struct"
186 .Vb 1
187 \& $range\->as_struct( $module );
188 .Ve
189 .PP
190 This returns a data structure containing the version requirements. This should
191 not be used for version checks (see "accepts_module" instead).
192 .SS as_string
193 .IX Subsection "as_string"
194 .Vb 1
195 \& $range\->as_string;
196 .Ve
197 .PP
198 This returns a string containing the version requirements in the format
199 described in CPAN::Meta::Spec. This should only be used for informational
200 purposes such as error messages and should not be interpreted or used for
201 comparison (see "accepts" instead).
202 .SS accepts
203 .IX Subsection "accepts"
204 .Vb 1
205 \& my $bool = $range\->accepts($version);
206 .Ve
207 .PP
208 Given a version, this method returns true if the version specification
209 accepts the provided version. In other words, given:
210 .PP
211 .Vb 1
212 \& \*(Aq>= 1.00, < 2.00\*(Aq
213 .Ve
214 .PP
215 We will accept 1.00 and 1.75 but not 0.50 or 2.00.
216 .SS is_simple
217 .IX Subsection "is_simple"
218 This method returns true if and only if the range is an inclusive minimum
219 \&\-\- that is, if their string expression is just the version number.
220 .SH AUTHORS
221 .IX Header "AUTHORS"
222 .IP \(bu 4
223 David Golden <[email protected]>
224 .IP \(bu 4
225 Ricardo Signes <[email protected]>
226 .SH "COPYRIGHT AND LICENSE"
227 .IX Header "COPYRIGHT AND LICENSE"
228 This software is copyright (c) 2010 by David Golden and Ricardo Signes.
229 .PP
230 This is free software; you can redistribute it and/or modify it under
231 the same terms as the Perl 5 programming language system itself.