1Version::Requirements(3U)ser Contributed Perl DocumentatiVoenrsion::Requirements(3)
2
3
4

NAME

6       Version::Requirements - a set of version requirements for a CPAN dist
7

VERSION

9       version 0.101023
10

SYNOPSIS

12         use Version::Requirements;
13
14         my $build_requires = Version::Requirements->new;
15
16         $build_requires->add_minimum('Library::Foo' => 1.208);
17
18         $build_requires->add_minimum('Library::Foo' => 2.602);
19
20         $build_requires->add_minimum('Module::Bar'  => 'v1.2.3');
21
22         $METAyml->{build_requires} = $build_requires->as_string_hash;
23

DESCRIPTION

25       A Version::Requirements object models a set of version constraints like
26       those specified in the META.yml or META.json files in CPAN
27       distributions.  It can be built up by adding more and more constraints,
28       and it will reduce them to the simplest representation.
29
30       Logically impossible constraints will be identified immediately by
31       thrown exceptions.
32

METHODS

34   new
35         my $req = Version::Requirements->new;
36
37       This returns a new Version::Requirements object.  It ignores any
38       arguments given.
39
40   add_minimum
41         $req->add_minimum( $module => $version );
42
43       This adds a new minimum version requirement.  If the new requirement is
44       redundant to the existing specification, this has no effect.
45
46       Minimum requirements are inclusive.  $version is required, along with
47       any greater version number.
48
49       This method returns the requirements object.
50
51   add_maximum
52         $req->add_maximum( $module => $version );
53
54       This adds a new maximum version requirement.  If the new requirement is
55       redundant to the existing specification, this has no effect.
56
57       Maximum requirements are inclusive.  No version strictly greater than
58       the given version is allowed.
59
60       This method returns the requirements object.
61
62   add_exclusion
63         $req->add_exclusion( $module => $version );
64
65       This adds a new excluded version.  For example, you might use these
66       three method calls:
67
68         $req->add_minimum( $module => '1.00' );
69         $req->add_maximum( $module => '1.82' );
70
71         $req->add_exclusion( $module => '1.75' );
72
73       Any version between 1.00 and 1.82 inclusive would be acceptable, except
74       for 1.75.
75
76       This method returns the requirements object.
77
78   exact_version
79         $req->exact_version( $module => $version );
80
81       This sets the version required for the given module to exactly the
82       given version.  No other version would be considered acceptable.
83
84       This method returns the requirements object.
85
86   add_requirements
87         $req->add_requirements( $another_req_object );
88
89       This method adds all the requirements in the given
90       Version::Requirements object to the requirements object on which it was
91       called.  If there are any conflicts, an exception is thrown.
92
93       This method returns the requirements object.
94
95   accepts_module
96         my $bool = $req->accepts_modules($module => $version);
97
98       Given an module and version, this method returns true if the version
99       specification for the module accepts the provided version.  In other
100       words, given:
101
102         Module => '>= 1.00, < 2.00'
103
104       We will accept 1.00 and 1.75 but not 0.50 or 2.00.
105
106       For modules that do not appear in the requirements, this method will
107       return true.
108
109   clear_requirement
110         $req->clear_requirement( $module );
111
112       This removes the requirement for a given module from the object.
113
114       This method returns the requirements object.
115
116   required_modules
117       This method returns a list of all the modules for which requirements
118       have been specified.
119
120   clone
121         $req->clone;
122
123       This method returns a clone of the invocant.  The clone and the
124       original object can then be changed independent of one another.
125
126   is_simple
127       This method returns true if and only if all requirements are inclusive
128       minimums -- that is, if their string expression is just the version
129       number.
130
131   is_finalized
132       This method returns true if the requirements have been finalized by
133       having the "finalize" method called on them.
134
135   finalize
136       This method marks the requirements finalized.  Subsequent attempts to
137       change the requirements will be fatal, if they would result in a
138       change.  If they would not alter the requirements, they have no effect.
139
140       If a finalized set of requirements is cloned, the cloned requirements
141       are not also finalized.
142
143   as_string_hash
144       This returns a reference to a hash describing the requirements using
145       the strings in the META.yml specification.
146
147       For example after the following program:
148
149         my $req = Version::Requirements->new;
150
151         $req->add_minimum('Version::Requirements' => 0.102);
152
153         $req->add_minimum('Library::Foo' => 1.208);
154
155         $req->add_maximum('Library::Foo' => 2.602);
156
157         $req->add_minimum('Module::Bar'  => 'v1.2.3');
158
159         $req->add_exclusion('Module::Bar'  => 'v1.2.8');
160
161         $req->exact_version('Xyzzy'  => '6.01');
162
163         my $hashref = $req->as_string_hash;
164
165       $hashref would contain:
166
167         {
168           'Version::Requirements' => '0.102',
169           'Library::Foo' => '>= 1.208, <= 2.206',
170           'Module::Bar'  => '>= v1.2.3, != v1.2.8',
171           'Xyzzy'        => '== 6.01',
172         }
173
174   from_string_hash
175         my $req = Version::Requirements->from_string_hash( \%hash );
176
177       This is an alternate constructor for a Version::Requirements object.
178       It takes a hash of module names and version requirement strings and
179       returns a new Version::Requirements object.
180

AUTHOR

182       Ricardo Signes <rjbs@cpan.org>
183

CONTRIBUTOR

185       Karen Etheridge <ether@cpan.org>
186
188       This software is copyright (c) 2010 by Ricardo Signes.
189
190       This is free software; you can redistribute it and/or modify it under
191       the same terms as the Perl 5 programming language system itself.
192
193
194
195perl v5.28.1                      2015-03-26          Version::Requirements(3)
Impressum