Module: SleepingKingStudios::Tools::Toolbox::SemanticVersion
- Included in:
- Version
- Defined in:
- lib/sleeping_king_studios/tools/toolbox/semantic_version.rb
Overview
Helper for generating semantic version strings with optional prerelease and build parameters.
Defined Under Namespace
Classes: InvalidVersionError
Instance Method Summary collapse
-
#to_gem_version ⇒ String
Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE and BUILD (if available) to generate a modified semantic version string compatible with Rubygems.
-
#to_version ⇒ String
Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE and BUILD (if available) to generate a semantic version string.
Instance Method Details
#to_gem_version ⇒ String
Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE and BUILD (if available) to generate a modified semantic version string compatible with Rubygems. The major, minor, patch, prerelease, and build values (if available) are separated by dots (.).
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/sleeping_king_studios/tools/toolbox/semantic_version.rb', line 49 def to_gem_version str = +"#{const_fetch :MAJOR}.#{const_fetch :MINOR}.#{const_fetch :PATCH}" prerelease = const_fetch(:PRERELEASE, nil) str << ".#{prerelease}" unless prerelease.nil? || prerelease.empty? build = const_fetch(:BUILD, nil) str << ".#{build}" unless build.nil? || build.empty? str end |
#to_version ⇒ String
Concatenates the MAJOR, MINOR, and PATCH constant values with PRERELEASE and BUILD (if available) to generate a semantic version string. The major, minor, and patch values are separated by dots (.), then the prerelease (if available) preceded by a hyphen (-), and the build (if available) preceded by a plus (+).
84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/sleeping_king_studios/tools/toolbox/semantic_version.rb', line 84 def to_version str = +"#{const_fetch :MAJOR}.#{const_fetch :MINOR}.#{const_fetch :PATCH}" prerelease = const_fetch(:PRERELEASE, nil) str << "-#{prerelease}" unless prerelease.nil? || prerelease.empty? build = const_fetch(:BUILD, nil) str << "+#{build}" unless build.nil? || build.empty? str end |