Versioning::Scheme::Semantic - Semantic versioning
This document describes version 0.011 of Versioning::Scheme::Semantic (from Perl distribution Versioning-Scheme), released on 2020-10-01.
use Versioning::Scheme::Semantic; # checking validity Versioning::Scheme::Semantic->is_valid_version('0.0.1'); # 1 Versioning::Scheme::Semantic->is_valid_version('0.01.1'); # 0 (zero prefix not allowed) Versioning::Scheme::Semantic->is_valid_version('0.1.1.0'); # 0 (only X.Y.Z permitted) Versioning::Scheme::Semantic->is_valid_version('0.1.1-beta1+foobar'); # 1 (pre-release identifier and metada allowed) # parsing $parsed = Versioning::Scheme::Semantic->parse_version('0.1'); # => undef $parsed = Versioning::Scheme::Semantic->parse_version('0.1.2-beta1+foobar'); # => {major=>0, minor=>1, patch=>2, prerelease=>'beta1', metadata=>'foobar'} # normalizing (currently does nothing other than checking for validity) Versioning::Scheme::Semantic->normalize_version('1.2.0'); # => '1.2.0' # comparing Versioning::Scheme::Semantic->cmp_version('1.2.3', '1.2.3'); # 0 Versioning::Scheme::Semantic->cmp_version('1.2.3', '1.2.12'); # -1 Versioning::Scheme::Semantic->cmp_version('1.3.0', '1.2.12'); # 1 Versioning::Scheme::Semantic->cmp_version('1.2.3', '1.2.3-beta1'); # -1 Versioning::Scheme::Semantic->cmp_version('1.2.3-beta1', '1.2.3-beta1'); # 0 Versioning::Scheme::Semantic->cmp_version('1.2.3-beta1', '1.2.3-beta2'); # -1 # bumping Versioning::Scheme::Semantic->bump_version('1.2.3'); # => '1.2.4' Versioning::Scheme::Semantic->bump_version('1.2.3', {num=>2}); # => '1.2.5' Versioning::Scheme::Semantic->bump_version('1.2.3', {num=>-1}); # => '1.2.2' Versioning::Scheme::Semantic->bump_version('1.2.3', {part=>-2}); # => '1.3.0' Versioning::Scheme::Semantic->bump_version('1.2.3', {part=>0}); # => '2.0.0' Versioning::Scheme::Semantic->bump_version('1.2.3', {part=>-2, reset_smaller=>0}); # => '1.3.3'
You can also mix this role into your class.
This role implements the semantic versioning scheme as described in [1]. Version number comprises of three non-negative integers X.Y.Z where zero-prefix is not allowed.
This scheme is not the same as the Perl versioning scheme implemented by version, as the latter has some Perl-specific peculiarities.
Normalizing basically does nothing except checking the validity.
Comparing: Each part is compared numerically from the biggest (leftmost) part.
Bumping: By default the smallest (rightmost) part is increased by 1. You can specify options: num, part, reset_smaller like spacified in Role::Versioning::Scheme.
num
part
reset_smaller
Please visit the project's homepage at https://metacpan.org/release/Versioning-Scheme.
Source repository is at https://github.com/perlancar/perl-Versioning-Scheme.
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.
[1] https://semver.org/
Versioning::Scheme::Dotted
perlancar <perlancar@cpan.org>
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.
To install Versioning::Scheme, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Versioning::Scheme
CPAN shell
perl -MCPAN -e shell install Versioning::Scheme
For more information on module installation, please visit the detailed CPAN module installation guide.