NAME

Versioning::Scheme::Monotonic - Monotonic versioning

VERSION

This document describes version 0.011 of Versioning::Scheme::Monotonic (from Perl distribution Versioning-Scheme), released on 2020-10-01.

SYNOPSIS

use Versioning::Scheme::Monotonic;

# checking validity
Versioning::Scheme::Monotonic->is_valid_version('1.2');   # 1
Versioning::Scheme::Monotonic->is_valid_version('1.02');  # 0
Versioning::Scheme::Monotonic->is_valid_version('1.2.0'); # 1
Versioning::Scheme::Monotonic->is_valid_version('1.2.1'); # 0
Versioning::Scheme::Monotonic->is_valid_version('1.2+foo.123'); # 1

# parsing
Versioning::Scheme::Monotonic->parse_version('1.02');        # => undef
Versioning::Scheme::Monotonic->parse_version('1.2+foo.123'); # {compatibility=>1, release=>2, metadata=>'foo.123'}

# normalizing
Versioning::Scheme::Monotonic->normalize_version('1.2.0'); # => '1.2'
Versioning::Scheme::Monotonic->normalize_version('1.2.0+foo.123'); # => '1.2+foo.123'

# comparing
Versioning::Scheme::Monotonic->cmp_version('1.2', '1.2.0'); # 0
Versioning::Scheme::Monotonic->cmp_version('1.2', '1.13');  # -1
Versioning::Scheme::Monotonic->cmp_version('2.2', '1.13');  # 1
Versioning::Scheme::Monotonic->cmp_version('2.2+alpha', '2.2+beta');  # -1

# bumping
Versioning::Scheme::Monotonic->bump_version('1.2');            # => '1.3'
Versioning::Scheme::Monotonic->bump_version('1.2', {num=>2});  # => '1.4'
Versioning::Scheme::Monotonic->bump_version('1.2', {part=>0}); # => '2.3'
Versioning::Scheme::Monotonic->bump_version('2.2', {num=>-1, part=>0}); # => '1.1'

You can also mix this role into your class.

DESCRIPTION

This role implements the monotonic versioning scheme as described in [1]. A version number comprises two whole numbers:

COMPATIBILITY.RELEASE

where COMPATIBILITY starts at 0 and RELEASE starts at 1 with no zero prefix. An additional ".0" marker is allowed for compatibility with semantic versioning:

COMPATIBILITY.RELEASE.0

And an additional metadata after the RELEASE or ".0" marker in the form of "+" followed by a dot-separated series of identifiers. Identifier must comprise only of [0-9A-Za-z-] and cannot be empty.

RELEASE is always increased. COMPATIBILITY is increased whenever there's a backward-incompatibility introduced.

Normalizing just normalized COMPATIBILITY.RELEASE.0 into COMPATIBILITY.RELEASE.

Comparing is performed using this expression:

(COMPATIBILITY1 <=> COMPATIBILITY2) || (RELEASE1 <=> RELEASE2) || (METADATA1 cmp METADATA2)

Bumping by default increases RELEASE by 1. You can specify option num (e.g. 2) to bump RELEASE by that number. You can specify option part (e.g. 0) to increase COMPATIBILITY instead; but in that case RELEASE will still be bumped by 1.

METHODS

versioning_scheme

is_valid_version

parse_version

normalize_version

cmp_version

bump_version

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Versioning-Scheme.

SOURCE

Source repository is at https://github.com/perlancar/perl-Versioning-Scheme.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Versioning-Scheme

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

[1] http://blog.appliedcompscilab.com/monotonic_versioning_manifesto/

Version::Monotonic, an older incantation of this module.

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2020, 2019, 2018 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.