Class: Releaser::Revision

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/releaser/revision.rb

Instance Method Summary collapse

Constructor Details

#initialize(duck) ⇒ Revision

Returns a new instance of Revision.

Raises:

  • (ArgumentError)


5
6
7
8
# File 'lib/releaser/revision.rb', line 5

def initialize(duck)
  super(duck.is_a?(String) ? parse_string(duck) : duck)
  raise ArgumentError.new("Version should at least contain major part, but given: #{duck.inspect}") unless valid?
end

Instance Method Details

#current?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/releaser/revision.rb', line 26

def current?
  build == 0
end

#next_major(codename = nil) ⇒ Object Also known as: new_major



30
31
32
# File 'lib/releaser/revision.rb', line 30

def next_major(codename = nil)
  self.class.new(@table.merge(:build => 0, :minor => 0, :codename => codename).tap {|hsh| hsh[:major] += 1})
end

#next_minorObject Also known as: new_minor



35
36
37
# File 'lib/releaser/revision.rb', line 35

def next_minor
  self.class.new(@table.merge(:build => 0).tap {|hsh| hsh[:minor] += 1})
end

#to_deploy_taglineObject



22
23
24
# File 'lib/releaser/revision.rb', line 22

def to_deploy_tagline
  version_string
end

#to_sObject



14
15
16
# File 'lib/releaser/revision.rb', line 14

def to_s
  append_codename(version_string, " ")
end

#to_taglineObject



18
19
20
# File 'lib/releaser/revision.rb', line 18

def to_tagline
  append_codename(version_string, "-")
end

#valid?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/releaser/revision.rb', line 10

def valid?
  !!major
end