diff --git a/lib/rackstash/version.rb b/lib/rackstash/version.rb index 7ad774e..77338fa 100644 --- a/lib/rackstash/version.rb +++ b/lib/rackstash/version.rb @@ -4,5 +4,36 @@ # of the MIT license. See the LICENSE.txt file for details. module Rackstash - VERSION = '0.1.0' + # Version information about Rackstash. + module Version + # MAJOR version. It is incremented after incompatible API changes + MAJOR = 0 + # MINOR version. It is incremented after adding functionality in a + # backwards-compatible manner + MINOR = 1 + # PATCH version. It is incremented when making backwards-compatible + # bug-fixes. + PATCH = 0 + # PRERELEASE suffix. Set to a alphanumeric string on any pre-release + # versions like beta or RC releases. + PRERELEASE = nil + + # 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 + Gem::Version.new to_s + end + + # @return [String] the Rackstash version as a semver-compliant string + def self.to_s + STRING + end + end + + # The Rackstash version as a semver-compliant string + # @see Version::STRING + VERSION = Version::STRING end diff --git a/spec/rackstash/version_spec.rb b/spec/rackstash/version_spec.rb new file mode 100644 index 0000000..0a9d434 --- /dev/null +++ b/spec/rackstash/version_spec.rb @@ -0,0 +1,23 @@ +# Copyright 2017 Holger Just +# +# This software may be modified and distributed under the terms +# of the MIT license. See the LICENSE.txt file for details. + +require 'spec_helper' + +require 'rackstash/version' + +describe 'Rackstash::Version' do + it 'has a version number' do + expect(Rackstash::Version::STRING).to be_a String + end + + it 'exposes the version as Rackstash::VERSION' do + expect(Rackstash::VERSION).to equal Rackstash::Version::STRING + end + + 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 + end +end diff --git a/spec/rackstash_spec.rb b/spec/rackstash_spec.rb index 78fdb4d..3ffab61 100644 --- a/spec/rackstash_spec.rb +++ b/spec/rackstash_spec.rb @@ -6,11 +6,4 @@ require 'spec_helper' describe Rackstash do - it 'has a version number' do - expect(Rackstash::VERSION).not_to be nil - end - - it 'does something useful' do - expect(false).to eq(true) - end end