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

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

πŸ’– URI::VersionRange::Version β€” the lil base class that makes version schemes go brrr πŸ’–

okay bestie, so this is a 3pm Perl manual page β€” user contributed Perl docs, the whole vibe β€” for URI::VersionRange::Version, aka the version scheme helper class. Think of it as the glow-up base class that every version scheme inherits its whole personality from. ✨


🌸 NAME 🌸

URI::VersionRange::Version β€” Version scheme helper class. that's it, that's the name, no notes. πŸ’…


✨ SYNOPSIS ✨

here's the vibe in code, bestie β€” a whole scheme class built on top, then some actual usage:

package URI::VersionRange::Scheme::generic {

    use Version::libversion::XS qw(version_compare2);

    use parent 'URI::VersionRange::Version';
    use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);

    sub compare {
        my ($left, $right) = @_;
        return version_compare2($left->[0], $right->[0]);
    }

}

my $vers = URI::VersionRange->from_string('vers:generic/>v1.00|!=v2.10|<=v3.00');

if ($vers->contains('v2.50')) {
  # do stuff
}

like… the contains check is giving main character energy fr fr. πŸ”₯


πŸ¦‹ DESCRIPTION πŸ¦‹

so basically: this is a base class for the version scheme helper. that's the whole assignment. it's the parent everybody else extends. πŸ‘‘

πŸ’œ OBJECT-ORIENTED INTERFACE πŸ’œ

new

$v = URI::VersionRange::Version->new( $value )

creates a brand new URI::VersionRange::Version instance using the version value you hand it. fresh out the box, no cap. πŸŽ€

compare

$v->compare

compares the version. that's the job. βš–οΈ

from_native

$v->from_native( $native_range )

converts the scheme's native range into a VERS string. translation service, but make it versions. 🌈

load

$class = URI::VersionRange::Version->load( $scheme )

loads the scheme class. boom, loaded. ✨

🧚 HOW TO CREATE A NEW SCHEME COMPARATOR CLASS 🧚

want your own scheme? iconic, here's the recipe:

  • create a new package using the naming convention URI::VersionRange::Scheme::<scheme> by extending URI::VersionRange::Version.
  • implement the compare($left, $right) subroutine with the algorithm required by the scheme.

the $left and $right arguments of compare are ARRAY and have as their first element the value of the version to be compared. yep, arrayrefs, don't fight it. πŸ“

  • overload '<=>' and cmp operators using the compare subroutine β€” MANDATORY (not optional, not a suggestion, bestie, it is required πŸ’€).
  • implement the from_native($self, $native) subroutine to convert the native range of the scheme into a VERS string.

and here's an example that implements a comparator for the generic scheme using the Version::libversion::XS module:

package URI::VersionRange::Scheme::generic {

    use Version::libversion::XS;

    use parent 'URI::VersionRange::Version';
    use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);

    sub compare {
        my ($left, $right) = @_;
        return version_compare2($left->[0], $right->[0]);
    }

}

and here's another example, this time for the rpm scheme using the RPM4 module:

package URI::VersionRange::Scheme::rpm {

    use RPM4;

    use parent 'URI::VersionRange::Version';
    use overload ('cmp' => \&compare, '<=>' => \&compare, fallback => 1);

    sub compare {
        my ($left, $right) = @_;
        return rpmvercmp($left->[0], $right->[0]);
    }

}

two examples, two vibes, both slay. πŸ’…


🫢 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 will be notified automatically of any progress on your issue. so like, you'll know. πŸ””

πŸ“¦ Source Code πŸ“¦

this is open source software. the code repository is available for public review and contribution under the terms of the license.

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

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

clone it, bestie, go be part of history. 🌟


πŸ‘‘ 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.

free software, the same terms as Perl 5 itself β€” go wild, but responsibly. 🫢

and that's the whole page, bestie!! perl v5.40.1, dated 2026-01-31, brought to you by User Contributed Perl Documentation. mwah, go write a scheme class, i believe in you πŸ’‹πŸ’œπŸ¦‹

πŸ“¦ where this page comes from