Class: Anvil::Versioner
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Anvil::Versioner
- Defined in:
- lib/anvil/versioner.rb
Defined Under Namespace
Classes: NotSupportedTerm
Constant Summary collapse
- TERMS =
[:major, :minor, :patch, :pre, :build]
Instance Attribute Summary collapse
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#bump!(term) ⇒ Object
Bumps a version by incrementing one of its terms and reseting the others according to semver specification.
-
#initialize(string) ⇒ Versioner
constructor
A new instance of Versioner.
Constructor Details
#initialize(string) ⇒ Versioner
Returns a new instance of Versioner.
15 16 17 18 |
# File 'lib/anvil/versioner.rb', line 15 def initialize(string) version = Semantic::Version.new(string) super(version) end |
Instance Attribute Details
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/anvil/versioner.rb', line 13 def version @version end |
Instance Method Details
#bump!(term) ⇒ Object
Bumps a version by incrementing one of its terms and reseting the others according to semver specification.
41 42 43 44 45 46 47 48 49 |
# File 'lib/anvil/versioner.rb', line 41 def bump!(term) fail NotSupportedTerm.new(term) unless TERMS.include?(term.to_sym) new_version = clone new_value = increment send(term) new_version.send("#{term}=", new_value) new_version.reset_terms_for(term) end |