Class: Bosh::Common::Version::StemcellVersion

Inherits:
SemiSemanticVersion show all
Defined in:
lib/common/version/stemcell_version.rb

Constant Summary

Constants inherited from SemiSemanticVersion

Bosh::Common::Version::SemiSemanticVersion::DEFAULT_POST_RELEASE_SEGMENT

Instance Attribute Summary

Attributes inherited from SemiSemanticVersion

#version

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SemiSemanticVersion

#<=>, #default_post_release, #increment_post_release, #increment_release, #initialize, parse_and_compare, #timestamp_release, #to_s

Constructor Details

This class inherits a constructor from Bosh::Common::Version::SemiSemanticVersion

Class Method Details

.match(str_a, str_b) ⇒ Object



17
18
19
20
# File 'lib/common/version/stemcell_version.rb', line 17

def self.match(str_a, str_b)
  version_a, version_b = parse(str_a), parse(str_b)
  version_a.matches(version_b)
end

.parse(version) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
# File 'lib/common/version/stemcell_version.rb', line 7

def self.parse(version)
  raise ArgumentError, 'Invalid Version: nil' if version.nil?
  version = version.to_s

  #replace underscores with periods to maintain reverse compatibility with stemcell versions
  version = version.gsub('_', '.')

  self.new(SemiSemantic::Version.parse(version))
end

Instance Method Details

#matches(other) ⇒ Object



22
23
24
25
26
# File 'lib/common/version/stemcell_version.rb', line 22

def matches(other)
  release_self = self.version.release
  release_other = other.version.release
  release_self.components[0] == release_other.components[0]
end