From e96a0aaf94bf4cefd361761a5735f3235bc3d543 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Wed, 5 Jul 2017 19:21:24 +0200 Subject: [PATCH] Separate the PRERELEASE version part with a dash instead of a dot --- lib/rackstash/version.rb | 12 ++++++++---- spec/rackstash/version_spec.rb | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/rackstash/version.rb b/lib/rackstash/version.rb index fe66c6f..66a9251 100644 --- a/lib/rackstash/version.rb +++ b/lib/rackstash/version.rb @@ -18,9 +18,6 @@ module Rackstash # versions like beta or RC releases. PRERELEASE = 'dev'.freeze - # A standard string representation of the version parts - STRING = [MAJOR, MINOR, PATCH, PRERELEASE].compact.join('.').freeze - # @return [Gem::Version] the version of the currently loaded Rackstash as # a `Gem::Version` def self.gem_version @@ -30,8 +27,15 @@ module Rackstash # @return [String] the Rackstash version as a semver-compliant string # @see http://semver.org/ def self.to_s - STRING + @version ||= begin + base_version = [MAJOR, MINOR, PATCH].compact.join('.') + release = [base_version, PRERELEASE].compact.join('-') + release.freeze + end end + + # A standard string representation of the version parts + STRING = to_s end # The Rackstash version as a semver-compliant string diff --git a/spec/rackstash/version_spec.rb b/spec/rackstash/version_spec.rb index 0a9d434..2917640 100644 --- a/spec/rackstash/version_spec.rb +++ b/spec/rackstash/version_spec.rb @@ -10,6 +10,7 @@ require 'rackstash/version' describe 'Rackstash::Version' do it 'has a version number' do expect(Rackstash::Version::STRING).to be_a String + expect(Rackstash::Version::STRING).to equal Rackstash::Version.to_s end it 'exposes the version as Rackstash::VERSION' do @@ -18,6 +19,7 @@ describe 'Rackstash::Version' do it 'exposes a gem_version method' do expect(Rackstash::Version.gem_version).to be_a Gem::Version - expect(Rackstash::Version.gem_version.to_s).to eql Rackstash::VERSION + expect(Rackstash::Version.gem_version.to_s.gsub('.pre.', '-')) + .to eql Rackstash::VERSION end end