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.
Defined Under Namespace
Classes: InvalidVersionError
Instance Method Summary collapse
-
#to_gem_version ⇒ String
Generates a RubyGems-compatible version string.
-
#to_version ⇒ String
Generates a standard Semver version string.
Instance Method Details
#to_gem_version ⇒ String
Generates a RubyGems-compatible 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 (.).
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/sleeping_king_studios/tools/toolbox/semantic_version.rb', line 58 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
Generates a standard Semver 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 (+).
96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/sleeping_king_studios/tools/toolbox/semantic_version.rb', line 96 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 |