Class: Mixlib::Versioning::Format::OpscodeSemVer

Inherits:
SemVer show all
Defined in:
lib/mixlib/versioning/format/opscode_semver.rb

Overview

Defines the format of the semantic version scheme used for Opscode projects. They are SemVer-2.0.0-rc.1 compliant, but we further constrain the allowable strings for prerelease and build signifiers for our own internal standards.

SUPPORTED FORMATS


“`text MAJOR.MINOR.PATCH MAJOR.MINOR.PATCH-alpha.INDEX MAJOR.MINOR.PATCH-beta.INDEX MAJOR.MINOR.PATCH-rc.INDEX MAJOR.MINOR.PATCH-alpha.INDEX+YYYYMMDDHHMMSS MAJOR.MINOR.PATCH-beta.INDEX+YYYYMMDDHHMMSS MAJOR.MINOR.PATCH-rc.INDEX+YYYYMMDDHHMMSS MAJOR.MINOR.PATCH-alpha.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1 MAJOR.MINOR.PATCH-beta.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1 MAJOR.MINOR.PATCH-rc.INDEX+YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1 “`

EXAMPLES


“`text 11.0.0 11.0.0-alpha.1 11.0.0-alpha1+20121218164140 11.0.0-alpha1+20121218164140.git.207.694b062 “`

Author:

Constant Summary collapse

OPSCODE_BUILD_REGEX =

The pattern is: `YYYYMMDDHHMMSS.git.COMMITS_SINCE.SHA1`

/^\d{14}(\.git\.\d+\.[a-f0-9]{7})?$/
OPSCODE_PRERELEASE_REGEX =

Allows the following:

“`text alpha, alpha.0, alpha.1, alpha.2, etc. beta, beta.0, beta.1, beta.2, etc. rc, rc.0, rc.1, rc.2, etc. “`

/^(alpha|beta|rc)(\.\d+)?$/

Constants inherited from SemVer

SemVer::SEMVER_REGEX

Instance Attribute Summary

Attributes inherited from Mixlib::Versioning::Format

#build, #input, #iteration, #major, #minor, #patch, #prerelease

Instance Method Summary collapse

Methods inherited from Mixlib::Versioning::Format

#<=>, #build?, #eql?, for, #hash, #in_same_prerelease_line?, #in_same_release_line?, #initialize, #inspect, #prerelease?, #prerelease_build?, #release?, #release_build?, #to_rubygems_string, #to_s, #to_semver_string

Constructor Details

This class inherits a constructor from Mixlib::Versioning::Format

Instance Method Details

#parse(version_string) ⇒ Object


71
72
73
74
75
76
# File 'lib/mixlib/versioning/format/opscode_semver.rb', line 71

def parse(version_string)
  super(version_string)

  raise Mixlib::Versioning::ParseError, "'#{@prerelease}' is not a valid Opscode pre-release signifier!" unless @prerelease.nil? || @prerelease.match(OPSCODE_PRERELEASE_REGEX)
  raise Mixlib::Versioning::ParseError, "'#{@build}' is not a valid Opscode build signifier!" unless @build.nil? || @build.match(OPSCODE_BUILD_REGEX)
end