Class: Bosh::Common::VersionNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/common/version_number.rb

Constant Summary collapse

DEFAULT_DEV_RELEASE_SEGMENT =
SemiSemantic::VersionSegment.parse('dev.1')

Class Method Summary collapse

Class Method Details

.latest(versions) ⇒ Object

Parameters:

  • Collection (Array<#version>)

    of version strings



33
34
35
# File 'lib/common/version_number.rb', line 33

def self.latest(versions)
  versions.max
end

.parse(version) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/common/version_number.rb', line 7

def self.parse(version)
  raise ArgumentError, 'Invalid Version: nil' if version.nil?
  #raise ArgumentError, "Invalid Version Type: #{version.class}" if version.is_a?(String)
  version = version.to_s

  #discard anything after a space, including the space, to support compound bosh versions
  version = version.split(' ', 2)[0] if version =~ / /

  #convert old-style dev version suffix to new dev post-release segment
  matches = /\A(?<release>.*)(\.(?<dev>[0-9]+)-dev)\z/.match(version)
  unless matches.nil?
    version = matches[:release] + "+dev." + matches[:dev]
  end

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

  SemiSemantic::Version.parse(version)
end

.parse_list(versions) ⇒ Object

Parameters:

  • Collection (Array<#version>)

    of version strings



28
29
30
# File 'lib/common/version_number.rb', line 28

def self.parse_list(versions)
  versions.map { |v| self.parse(v) }
end