Class: ReleaseCeremony::Semver
- Inherits:
-
Object
- Object
- ReleaseCeremony::Semver
- Includes:
- Comparable
- Defined in:
- lib/release_ceremony/semver.rb
Overview
A strict X.Y.Z release version: no prereleases, no leading zeroes.
Constant Summary collapse
- PATTERN =
/\A(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\z/- ERROR_MESSAGE =
'Version must use the X.Y.Z format'
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
-
#initialize(value) ⇒ Semver
constructor
A new instance of Semver.
- #tag ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(value) ⇒ Semver
Returns a new instance of Semver.
23 24 25 26 |
# File 'lib/release_ceremony/semver.rb', line 23 def initialize(value) @value = value @gem_version = Gem::Version.new(value) end |
Class Method Details
.parse(value) ⇒ Object
14 15 16 17 18 |
# File 'lib/release_ceremony/semver.rb', line 14 def parse(value) raise Error, ERROR_MESSAGE unless value.is_a?(String) && PATTERN.match?(value) new(value) end |
Instance Method Details
#<=>(other) ⇒ Object
28 29 30 31 32 |
# File 'lib/release_ceremony/semver.rb', line 28 def <=>(other) return unless other.is_a?(self.class) gem_version <=> other.gem_version end |
#tag ⇒ Object
38 39 40 |
# File 'lib/release_ceremony/semver.rb', line 38 def tag "v#{value}" end |
#to_s ⇒ Object
34 35 36 |
# File 'lib/release_ceremony/semver.rb', line 34 def to_s value end |