1CPAN::Meta::RequirementUss:e:rRaCnognet(r3i)buted Perl DCoPcAuNm:e:nMteattai:o:nRequirements::Range(3)
2
3
4
6 CPAN::Meta::Requirements::Range - a set of version requirements for a
7 CPAN dist
8
10 version 2.143
11
13 use CPAN::Meta::Requirements::Range;
14
15 my $range = CPAN::Meta::Requirements::Range->with_minimum(1);
16
17 $range = $range->with_maximum('v2.2');
18
19 my $stringified = $range->as_string;
20
22 A CPAN::Meta::Requirements::Range object models a set of version
23 constraints like those specified in the META.yml or META.json files in
24 CPAN distributions, and as defined by CPAN::Meta::Spec; It can be built
25 up by adding more and more constraints, and it will reduce them to the
26 simplest representation.
27
28 Logically impossible constraints will be identified immediately by
29 thrown exceptions.
30
32 with_string_requirement
33 $req->with_string_requirement('>= 1.208, <= 2.206');
34 $req->with_string_requirement(v1.208);
35
36 This method parses the passed in string and adds the appropriate
37 requirement. A version can be a Perl "v-string". It understands
38 version ranges as described in the "Version Ranges" in
39 CPAN::Meta::Spec. For example:
40
41 1.3
42 >= 1.3
43 <= 1.3
44 == 1.3
45 != 1.3
46 > 1.3
47 < 1.3
48 >= 1.3, != 1.5, <= 2.0
49 A version number without an operator is equivalent to specifying a
50 minimum (">="). Extra whitespace is allowed.
51
52 with_range
53 $range->with_range($other_range)
54
55 This creates a new range object that is a merge two others.
56
57 with_exact_version
58 $range->with_exact_version( $version );
59
60 This sets the version required to exactly the given version. No other
61 version would be considered acceptable.
62
63 This method returns the version range object.
64
65 with_minimum
66 $range->with_minimum( $version );
67
68 This adds a new minimum version requirement. If the new requirement is
69 redundant to the existing specification, this has no effect.
70
71 Minimum requirements are inclusive. $version is required, along with
72 any greater version number.
73
74 This method returns the version range object.
75
76 with_maximum
77 $range->with_maximum( $version );
78
79 This adds a new maximum version requirement. If the new requirement is
80 redundant to the existing specification, this has no effect.
81
82 Maximum requirements are inclusive. No version strictly greater than
83 the given version is allowed.
84
85 This method returns the version range object.
86
87 with_exclusion
88 $range->with_exclusion( $version );
89
90 This adds a new excluded version. For example, you might use these
91 three method calls:
92
93 $range->with_minimum( '1.00' );
94 $range->with_maximum( '1.82' );
95
96 $range->with_exclusion( '1.75' );
97
98 Any version between 1.00 and 1.82 inclusive would be acceptable, except
99 for 1.75.
100
101 This method returns the requirements object.
102
103 as_struct
104 $range->as_struct( $module );
105
106 This returns a data structure containing the version requirements. This
107 should not be used for version checks (see "accepts_module" instead).
108
109 as_string
110 $range->as_string;
111
112 This returns a string containing the version requirements in the format
113 described in CPAN::Meta::Spec. This should only be used for
114 informational purposes such as error messages and should not be
115 interpreted or used for comparison (see "accepts" instead).
116
117 accepts
118 my $bool = $range->accepts($version);
119
120 Given a version, this method returns true if the version specification
121 accepts the provided version. In other words, given:
122
123 '>= 1.00, < 2.00'
124
125 We will accept 1.00 and 1.75 but not 0.50 or 2.00.
126
127 is_simple
128 This method returns true if and only if the range is an inclusive
129 minimum -- that is, if their string expression is just the version
130 number.
131
133 • David Golden <dagolden@cpan.org>
134
135 • Ricardo Signes <rjbs@cpan.org>
136
138 This software is copyright (c) 2010 by David Golden and Ricardo Signes.
139
140 This is free software; you can redistribute it and/or modify it under
141 the same terms as the Perl 5 programming language system itself.
142
143
144
145perl v5.38.0 2023-07-20CPAN::Meta::Requirements::Range(3)