Class: SvnAuto::Version

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/svnauto/version.rb

Overview

Help deal with version numbers. Verson numbers are made up of three parts: the major, minor, and macro numbers. These numbers are separated by periods:

MAJOR.MINOR.MACRO as in 1.0.2

In SvnAuto, release branches are created for MAJOR.MINOR release numbers. Release tags are used for MAJOR.MINOR.MACRO. That means that version 1.1 is open for bug fixes and feature enhancements, but version 1.1.4 is locked and can’t be updated.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_string) ⇒ Version

create a new version object with the given version



60
61
62
# File 'lib/svnauto/version.rb', line 60

def initialize (version_string)
  parse_version(version_string)
end

Instance Attribute Details

#encodedObject (readonly)

the encoded version number for sorting



56
57
58
# File 'lib/svnauto/version.rb', line 56

def encoded
  @encoded
end

#macroObject (readonly)

macro release number



52
53
54
# File 'lib/svnauto/version.rb', line 52

def macro
  @macro
end

#majorObject (readonly)

major release number



44
45
46
# File 'lib/svnauto/version.rb', line 44

def major
  @major
end

#minorObject (readonly)

minor release number



48
49
50
# File 'lib/svnauto/version.rb', line 48

def minor
  @minor
end

Instance Method Details

#<=>(other) ⇒ Object

allow comparison



89
90
91
# File 'lib/svnauto/version.rb', line 89

def <=> (other)
  @encoded <=> other.encoded
end

#major_minorObject

give back just major.minor



74
75
76
# File 'lib/svnauto/version.rb', line 74

def major_minor
  "#{@major}.#{@minor}"
end

#to_sObject

convert back to a string



66
67
68
69
70
# File 'lib/svnauto/version.rb', line 66

def to_s
  str = "#{@major}.#{@minor}"
  str << ".#{@macro}" unless @macro.nil?
  str
end