Class: Releaser::Revision
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Releaser::Revision
- Defined in:
- lib/releaser/revision.rb
Instance Method Summary collapse
- #current? ⇒ Boolean
-
#initialize(duck) ⇒ Revision
constructor
A new instance of Revision.
- #next_major(codename = nil) ⇒ Object (also: #new_major)
- #next_minor ⇒ Object (also: #new_minor)
- #to_deploy_tagline ⇒ Object
- #to_s ⇒ Object
- #to_tagline ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(duck) ⇒ Revision
Returns a new instance of Revision.
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
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_minor ⇒ Object 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_tagline ⇒ Object
22 23 24 |
# File 'lib/releaser/revision.rb', line 22 def to_deploy_tagline version_string end |
#to_s ⇒ Object
14 15 16 |
# File 'lib/releaser/revision.rb', line 14 def to_s append_codename(version_string, " ") end |
#to_tagline ⇒ Object
18 19 20 |
# File 'lib/releaser/revision.rb', line 18 def to_tagline append_codename(version_string, "-") end |
#valid? ⇒ Boolean
10 11 12 |
# File 'lib/releaser/revision.rb', line 10 def valid? !!major end |