A version range specifier (aka. "vers") is a URI string using the "vers" URI-scheme with this syntax:
vers:<versioning-scheme>/<version-constraint>|<version-constraint>|...
"vers" is the URI-scheme and is an acronym for "VErsion Range Specifier".
The pipe "|" is used as a simple separator between "version-constraint". Each "version-constraint" in
this pipe-separated list contains a comparator and a version:
<comparator:version>
This list of "version-constraint" are signposts in the version timeline of a package that specify version
intervals.
A "version" satisfies a version range specifier if it is contained within any of the intervals defined by
these "version-constraint".
<https://github.com/package-url/purl-spec>
FUNCTIONALINTERFACE
They are exported by default:
$vers_string = encode_vers(%params);
Converts the given "vers" components to "vers" string. Croaks on error.
This function call is functionally identical to:
$vers_string = URI::VersionRange->new(%params)->to_string;
$vers = decode_vers($vers_string);
Converts the given "vers" string to URI::VersionRange object. Croaks on error.
This function call is functionally identical to:
$vers = URI::VersionRange->from_string($vers_string);
OBJECT-ORIENTEDINTERFACE
$vers = URI::VersionRange->new( scheme => STRING, constraints => ARRAY )
Create new URI::VersionRange instance using provided "vers" components (scheme, constraints).
$vers->scheme
By convention the versioning scheme should be the same as the URI::PackageURL package "type" for a
given package ecosystem.
$vers->constraints
"constraints" is ARRAY of URI::VersionRange::Constraint object.
$vers->contains($version)
Check if a version is contained within a range
my $vers = URI::VersionRange::from_string('vers:cpan/>2.00|<2.22');
if ($vers->contains('2.10')) {
say "The version is in range";
}
See URI::VersionRange::Version.
$vers->constraint_contains
Check if a version is contained within a specific constraint.
See URI::VersionRange::Version.
$vers->to_string
Stringify "vers" components.
$vers->TO_JSON
Helper method for JSON modules (JSON, JSON::PP, JSON::XS, Mojo::JSON, etc).
use Mojo::JSON qw(encode_json);
say encode_json($vers); # {"constraints":[{"comparator":">","version":"2.00"},{"comparator":"<","version":"2.22"}],"scheme":"cpan"}
$vers = URI::VersionRange->from_string($vers_string);
Converts the given "vers" string to URI::VersionRange object. Croaks on error.