Class: Omnibus::SemanticVersion
- Inherits:
-
Object
- Object
- Omnibus::SemanticVersion
- Defined in:
- lib/omnibus/semantic_version.rb
Instance Method Summary collapse
-
#initialize(version_string) ⇒ SemanticVersion
constructor
A new instance of SemanticVersion.
- #next_major ⇒ Object
- #next_minor ⇒ Object
- #next_patch ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(version_string) ⇒ SemanticVersion
Returns a new instance of SemanticVersion.
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/omnibus/semantic_version.rb', line 22 def initialize(version_string) @prefix = if version_string =~ /^v/ "v" else "" end @version = Mixlib::Versioning.parse(version_string.gsub(/^v/, "")) if @version.nil? raise InvalidVersion, "#{version_string} could not be parsed as a valid version" end end |
Instance Method Details
#next_major ⇒ Object
48 49 50 51 |
# File 'lib/omnibus/semantic_version.rb', line 48 def next_major s = [version.major + 1, 0, 0].join(".") self.class.new("#{prefix}#{s}") end |
#next_minor ⇒ Object
43 44 45 46 |
# File 'lib/omnibus/semantic_version.rb', line 43 def next_minor s = [version.major, version.minor + 1, 0].join(".") self.class.new("#{prefix}#{s}") end |
#next_patch ⇒ Object
38 39 40 41 |
# File 'lib/omnibus/semantic_version.rb', line 38 def next_patch s = [version.major, version.minor, version.patch + 1].join(".") self.class.new("#{prefix}#{s}") end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/omnibus/semantic_version.rb', line 34 def to_s "#{prefix}#{version}" end |