.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "SemVer 3pm" .TH SemVer 3pm "2018-07-25" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "Name" .IX Header "Name" SemVer \- Use semantic version numbers .SH "Synopsis" .IX Header "Synopsis" .Vb 1 \& use SemVer; our $VERSION = SemVer\->new(\*(Aq1.2.0\-b1\*(Aq); .Ve .SH "Description" .IX Header "Description" This module subclasses version to create semantic versions, as defined by the Semantic Versioning 2.0.0 Specification . The three salient points of the specification, for the purposes of version formatting, are: .IP "1." 4 A normal version number \s-1MUST\s0 take the form X.Y.Z where X, Y, and Z are non-negative integers, and \s-1MUST NOT\s0 contain leading zeroes. X is the major version, Y is the minor version, and Z is the patch version. Each element \s-1MUST\s0 increase numerically. For instance: \f(CW\*(C`1.9.0 \-> 1.10.0 \-> 1.11.0\*(C'\fR. .IP "2." 4 A pre-release version \s-1MAY\s0 be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version. Identifiers \s-1MUST\s0 comprise only \s-1ASCII\s0 alphanumerics and hyphen \f(CW\*(C`[0\-9A\-Za\-z\-]\*(C'\fR. Identifiers \s-1MUST NOT\s0 be empty. Numeric identifiers \s-1MUST NOT\s0 include leading zeroes. Pre-release versions have a lower precedence than the associated normal version. A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements as denoted by its associated normal version: \&\f(CW\*(C`1.0.0\-alpha, 1.0.0\-alpha.1, 1.0.0\-0.3.7, 1.0.0\-x.7.z.92\*(C'\fR .IP "3." 4 Build metadata \s-1MAY\s0 be denoted by appending a plus sign and a series of dot separated identifiers immediately following the patch or pre-release version. Identifiers \s-1MUST\s0 comprise only \s-1ASCII\s0 alphanumerics and hyphen \f(CW\*(C`[0\-9A\-Za\-z\-]\*(C'\fR. Identifiers \s-1MUST NOT\s0 be empty. Build metadata \s-1SHOULD\s0 be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: \f(CW\*(C`1.0.0\-alpha+001, 1.0.0+20130313144700, 1.0.0\-beta+exp.sha.5114f85\*(C'\fR. .SS "Usage" .IX Subsection "Usage" For strict parsing of semantic version numbers, use the \f(CW\*(C`new()\*(C'\fR constructor. If you need something more flexible, use \f(CW\*(C`declare()\*(C'\fR. And if you need something more comparable with what version expects, try \f(CW\*(C`parse()\*(C'\fR. Compare how these constructors deal with various version strings (with values shown as returned by \f(CW\*(C`normal()\*(C'\fR: .PP .Vb 10 \& Argument | new | declare | parse \& \-\-\-\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& \*(Aq1.0.0\*(Aq | 1.0.0 | 1.0.0 | 1.0.0 \& \*(Aq5.5.2\-b1\*(Aq | 5.5.2\-b1 | 5.5.2\-b1 | 5.5.2\-b1 \& \*(Aq1.05.0\*(Aq | | 1.5.0 | 1.5.0 \& \*(Aq1.0\*(Aq | | 1.0.0 | 1.0.0 \& \*(Aq 012.2.2\*(Aq | | 12.2.2 | 12.2.2 \& \*(Aq1.1\*(Aq | | 1.1.0 | 1.100.0 \& 1.1 | | 1.1.0 | 1.100.0 \& \*(Aq1.1.0b1\*(Aq | | 1.1.0\-b1 | 1.1.0\-b1 \& \*(Aq1.1\-b1\*(Aq | | 1.1.0\-b1 | 1.100.0\-b1 \& \*(Aq1.2.b1\*(Aq | | 1.2.0\-b1 | 1.2.0\-b1 \& \*(Aq9.0\-beta4\*(Aq | | 9.0.0\-beta4 | 9.0.0\-beta4 \& \*(Aq9\*(Aq | | 9.0.0 | 9.0.0 \& \*(Aq1\-b\*(Aq | | 1.0.0\-b | 1.0.0\-b \& 0 | | 0.0.0 | 0.0.0 \& \*(Aq0\-rc1\*(Aq | | 0.0.0\-rc1 | 0.0.0\-rc1 \& \*(Aq1.02_30\*(Aq | | 1.23.0 | 1.23.0 \& 1.02_30 | | 1.23.0 | 1.23.0 .Ve .PP Note that, unlike in version, the \f(CW\*(C`declare\*(C'\fR and \f(CW\*(C`parse\*(C'\fR methods ignore underscores. That is, version strings with underscores are treated as decimal numbers. Hence, the last two examples yield exactly the same semantic versions. .PP As with version objects, the comparison and stringification operators are all overloaded, so that you can compare semantic versions. You can also compare semantic versions with version objects (but not the other way around, alas). Boolean operators are also overloaded, such that all semantic version objects except for those consisting only of zeros are considered true. .SH "Interface" .IX Header "Interface" .SS "Constructors" .IX Subsection "Constructors" \fI\f(CI\*(C`new\*(C'\fI\fR .IX Subsection "new" .PP .Vb 1 \& my $semver = SemVer\->new(\*(Aq1.2.2\*(Aq); .Ve .PP Performs a validating parse of the version string and returns a new semantic version object. If the version string does not adhere to the semantic version specification an exception will be thrown. See \f(CW\*(C`declare\*(C'\fR and \f(CW\*(C`parse\*(C'\fR for more forgiving constructors. .PP \fI\f(CI\*(C`declare\*(C'\fI\fR .IX Subsection "declare" .PP .Vb 1 \& my $semver = SemVer\->declare(\*(Aq1.2\*(Aq); # 1.2.0 .Ve .PP This parser strips out any underscores from the version string and passes it to to \f(CW\*(C`version\*(C'\fR's \f(CW\*(C`declare\*(C'\fR constructor, which always creates dotted-integer version objects. This is the most flexible way to declare versions. Consider using it to normalize version strings. .PP \fI\f(CI\*(C`parse\*(C'\fI\fR .IX Subsection "parse" .PP .Vb 1 \& my $semver = SemVer\->parse(\*(Aq1.2\*(Aq); # 1.200.0 .Ve .PP This parser dispatches to \f(CW\*(C`version\*(C'\fR's \f(CW\*(C`parse\*(C'\fR constructor, which tries to be more flexible in how it converts simple decimal strings and numbers. Not really recommended, since it's treatment of decimals is quite different from the dotted-integer format of semantic version strings, and thus can lead to inconsistencies. Included only for proper compatibility with version. .SS "Instance Methods" .IX Subsection "Instance Methods" \fI\f(CI\*(C`normal\*(C'\fI\fR .IX Subsection "normal" .PP .Vb 5 \& SemVer\->declare(\*(Aqv1.2\*(Aq)\->normal; # 1.2.0 \& SemVer\->parse(\*(Aq1.2\*(Aq)\->normal; # 1.200.0 \& SemVer\->declare(\*(Aq1.02.0\-b1\*(Aq)\->normal; # 1.2.0\-b1 \& SemVer\->parse(\*(Aq1.02_30\*(Aq)\->normal # 1.230.0 \& SemVer\->parse(1.02_30)\->normal # 1.23.0 .Ve .PP Returns a normalized representation of the version. This string will always be a strictly-valid dotted-integer semantic version string suitable for passing to \f(CW\*(C`new()\*(C'\fR. Unlike version's \f(CW\*(C`normal\*(C'\fR method, there will be no leading \&\*(L"v\*(R". .PP \fI\f(CI\*(C`stringify\*(C'\fI\fR .IX Subsection "stringify" .PP .Vb 5 \& SemVer\->declare(\*(Aqv1.2\*(Aq)\->stringify; # v1.2 \& SemVer\->parse(\*(Aq1.200\*(Aq)\->stringify; # v1.200 \& SemVer\->declare(\*(Aq1.2\-r1\*(Aq)\->stringify; # v1.2\-r1 \& SemVer\->parse(1.02_30)\->stringify; # v1.0230 \& SemVer\->parse(1.02_30)\->stringify; # v1.023 .Ve .PP Returns a string that is as close to the original representation as possible. If the original representation was a numeric literal, it will be returned the way perl would normally represent it in a string. This method is used whenever a version object is interpolated into a string. .PP \fI\f(CI\*(C`numify\*(C'\fI\fR .IX Subsection "numify" .PP Throws an exception. Semantic versions cannot be numified. Just don't go there. .PP \fI\f(CI\*(C`is_alpha\*(C'\fI\fR .IX Subsection "is_alpha" .PP .Vb 1 \& my $is_alpha = $semver\->is_alpha; .Ve .PP Returns true if an \s-1ASCII\s0 string is appended to the end of the version string. This also means that the version number is a \*(L"special version\*(R", in the semantic versioning specification meaning of the phrase. .PP \fI\f(CI\*(C`vcmp\*(C'\fI\fR .IX Subsection "vcmp" .PP Compares the semantic version object to another version object or string and returns 0 if they're the same, \-1 if the invocant is smaller than the argument, and 1 if the invocant is greater than the argument. .PP Mostly you don't need to worry about this: Just use the comparison operators instead. They will use this method: .PP .Vb 3 \& if ($semver < $another_semver) { \& die "Need $another_semver or higher"; \& } .Ve .PP Note that in addition to comparing other semantic version objects, you can also compare regular version objects: .PP .Vb 3 \& if ($semver < $version) { \& die "Need $version or higher"; \& } .Ve .PP You can also pass in a version string. It will be turned into a semantic version object using \f(CW\*(C`declare\*(C'\fR. So if you're using integer versions, you may or may not get what you want: .PP .Vb 3 \& my $semver = version::Semver\->new(\*(Aq1.2.0\*(Aq); \& my $version = \*(Aq1.2\*(Aq; \& my $bool = $semver == $version; # true .Ve .PP If that's not what you want, pass the string to \f(CW\*(C`parse\*(C'\fR first: .PP .Vb 3 \& my $semver = version::Semver\->new(\*(Aq1.2.0\*(Aq); \& my $version = version::Semver\->parse(\*(Aq1.2\*(Aq); # 1.200.0 \& my $bool = $semver == $version; # false .Ve .SH "See Also" .IX Header "See Also" .IP "\(bu" 4 Semantic Versioning Specification . .IP "\(bu" 4 version .IP "\(bu" 4 version::AlphaBeta .SH "Support" .IX Header "Support" This module is managed in an open GitHub repository . Feel free to fork and contribute, or to clone and send patches! .PP Found a bug? Please post or email a report! .SH "Acknowledgements" .IX Header "Acknowledgements" Many thanks to version author John Peacock for his suggestions and debugging help. .SH "Authors" .IX Header "Authors" .IP "\(bu" 4 David E. Wheeler .IP "\(bu" 4 Johannes Kilian .SH "Copyright and License" .IX Header "Copyright and License" Copyright (c) 2010\-2018 David E. Wheeler. Some Rights Reserved. .PP This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.