Rand Stats

Version::Nginx

zef:lizmat

Actions Status Actions Status Actions Status

NAME

Version::Nginx - Implement Nginx version logic

SYNOPSIS

use Version::Nginx;

my $left  = Version::Nginx.new("1.0");
my $right = Version::Nginx.new("1.1");

say $left.cmp($right);  # Less
say $left."<"($right);  # True

DESCRIPTION

The Version::Nginx distribution provides a Version::Nginx class that is a sub-class of Version::Raku, but with some slight semantic changes to accommodate the Nginx version logic.

INSTANTIATION

my $v = Version::Nginx.new("1.0");

The basic instantion of a Version::Nginx object is done with the new method, taking the version string as a positional argument.

CLASS METHODS

as-generic-range

say Version::Nginx.as-generic-range('1.2');      # (== v1.2)
say Version::Nginx.as-generic-range('1.2+');     # (>= v1.2)
say Version::Nginx.as-generic-range('1.2-1.4');  # (>= v1.2 < v1.4)

Convert an Nginx version specification to a generic range specification, consisting of a Slip with a string representing a comparator ("==", ">=", "<") and a Version::Nginx object, possibly repeated.

COMPARATOR METHODS

cmp

my $left  = Version::Nginx.new("1.0");
my $right = Version::Nginx.new("1.1");

say $left.cmp($left);   # Same
say $left.cmp($right);  # Less
say $right.cmp($left);  # More

The cmp method returns the Order of a comparison of the invocant and the positional argument, which is either Less, Same, or More.

eqv

my $left  = Version::Nginx.new("1.01");
my $right = Version::Nginx.new("1.1");

say $left.eqv($right);  # True

The eqv method returns whether the internal state of two Version::Nginx objects are identical.

== != < <= > >= ~~

my $left  = Version::Nginx.new("1.0");
my $right = Version::Nginx.new("1.1");

say $left."=="($right);  # False
say $left."<"($right);   # True

These oddly named methods provide the same functionality as their infix counterparts. Please note that you must use the "xx"() syntax, because otherwise the Raku compiler will assume you've made a syntax error.

AUTHOR

Elizabeth Mattijsen liz@raku.rocks

Source can be located at: https://github.com/lizmat/Version-Raku . Comments and Pull Requests are welcome.

If you like this module, or what I’m doing more generally, committing to a small sponsorship would mean a great deal to me!

COPYRIGHT AND LICENSE

Copyright 2025 Elizabeth Mattijsen

This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.