class Mixlib::Versioning::Format::PartialSemVer

Handles partial version strings.


“`text MAJOR MAJOR.MINOR “`

EXAMPLES


“`text 11 11.0 “`

@author Seth Chisamore (<schisamo@chef.io>) @author Christopher Maier (<cm@chef.io>) @author Ryan Hass (<rhass@chef.io>)

Constants

PARTIAL_REGEX

rubular.com/r/NmRSN8vCie

Public Instance Methods

parse(version_string) click to toggle source

@see Format#parse

# File lib/mixlib/versioning/format/partial_semver.rb, line 45
def parse(version_string)
  match = version_string.match(PARTIAL_REGEX) rescue nil

  unless match
    raise Mixlib::Versioning::ParseError, "'#{version_string}' is not a valid #{self.class} version string!"
  end

  @major, @minor = match[1..2]
  @major, @minor, @patch = [@major, @minor, @patch].map(&:to_i)

  # Partial versions do not contain these values, so we just set them to nil.
  @prerelease = nil
  @build      = nil
end