URI::V...straint(3pm)

πŸ“¦
version 2.25 Β· 2 versions
, in ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

URI::VersionRange::Constraint β€” the version constraint for a Version Range Specification. Like, it's the little guy that holds ONE comparator + version pair so the bigger vers picture can make sense. bestie it's giving tiny but mighty ✨


πŸŽ€ SYNOPSIS πŸŽ€

use URI::VersionRange::Constraint;

# OO-interface

$constraint = URI::VersionRange::Constraint->new(
  comparator => '>',
  version    => '2.00'
);

say $constraint; # >2.00

# Parse "vers" string
$constraint = URI::VersionRange::Constraint->from_string('>2.00');

okay so look at that. three lines of setup and you're already stringifying constraints. slay πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

So a version range specifier (aka a "vers") is a URI string that uses the vers URI-scheme, and the syntax goes like this:

vers:<versioning-scheme>/<version-constraint>|<version-constraint>|...

vers is the URI-scheme, and ngl it's literally an acronym for "VErsion Range Specifier". iykyk 🌈

The pipe | is just a simple separator between each version-constraint. And every version-constraint in that pipe-separated list carries a comparator and a version, like so:

<comparator:version>

This whole list of version-constraint items? They're like signposts in the version timeline of a package, marking out version intervals. no cap πŸ“

A version satisfies a version range specifier if it's contained within any of the intervals those version-constraint items define.

<https://github.com/package-url/purl-spec>


✨ OBJECT-ORIENTED INTERFACE ✨

πŸ’œ new

$constraint = URI::VersionRange::Constraint->new( comparator => STRING, version => STRING )

Creates a fresh new URI::VersionRange::Constraint instance. main character energy, honestly πŸ‘‘

πŸ’œ comparator

$constraint->comparator

Returns the comparator. that's it, that's the whole job 🫢

πŸ’œ version

$constraint->version

Returns the version string.

πŸ’œ to_string

$vers->to_string

Stringifies the vers components. turning your object into a little string, iconic behaviour ✨

πŸ’œ to_human_string

$vers->to_human_string

Converts the constraint into a human-readable format. so you can, like, actually read it:

$constraint = URI::VersionRange::Constraint->new(
    comparator => '>=',
    version    => '2.10'
);

say $constraint->to_human_string; # greater than or equal 2.10

see? adorable. "greater than or equal 2.10" πŸ₯Ί

πŸ’œ TO_JSON

$vers->TO_JSON

Helper method for JSON modules β€” like JSON, JSON::PP, JSON::XS, Mojo::JSON, etc. all of them. the whole friend group πŸ’–

use Mojo::JSON qw(encode_json);

say encode_json($constraint);  # {"comparator":">","version":"2.00"}

πŸ’œ from_string

$vers = URI::VersionRange::Constraint->from_string($vers_string);

Converts the given constraint string into a URI::VersionRange::Constraint object.

⚠️ Heads up bestie: it croaks on error. no graceful little whisper, it CROAKS. so wrap it up if you're not about that πŸ’€

🌸 SUPPORT 🌸

πŸ› Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at <https://github.com/giterlizzi/perl-URI-PackageURL/issues>. You'll get notified automatically of any progress on your issue. we love updates πŸ’Œ

🧚 Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license. come hang out 🫢

<https://github.com/giterlizzi/perl-URI-PackageURL>

git clone https://github.com/giterlizzi/perl-URI-PackageURL.git

πŸ‘‘ AUTHOR πŸ‘‘

  • Giuseppe Di Terlizzi <gdt@cpan.org>

This software is copyright (c) 2022-2026 by Giuseppe Di Terlizzi.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. fr fr, do what you want with it 🌈


okay that's the whole page bestie, and here's the lil sign-off: this was URI::V...straint(3pm), from perl v5.40.1, dated 2026-01-31, part of the User Contributed Perl Documentation πŸ’–

πŸ“¦ where this page comes from