diff --git a/lib/x/client_defaults.rb b/lib/x/client_defaults.rb index b55eaa6..383939e 100644 --- a/lib/x/client_defaults.rb +++ b/lib/x/client_defaults.rb @@ -8,6 +8,6 @@ module ClientDefaults DEFAULT_OBJECT_CLASS = Hash DEFAULT_OPEN_TIMEOUT = 60 # seconds DEFAULT_READ_TIMEOUT = 60 # seconds - DEFAULT_USER_AGENT = "X-Client/#{Version} Ruby/#{RUBY_VERSION}".freeze + DEFAULT_USER_AGENT = "X-Client/#{VERSION} Ruby/#{RUBY_VERSION}".freeze end end diff --git a/lib/x/version.rb b/lib/x/version.rb index c312316..32d5bf7 100644 --- a/lib/x/version.rb +++ b/lib/x/version.rb @@ -1,39 +1,5 @@ -module X - # The version of this library - module Version - module_function - - def major - 0 - end - - def minor - 4 - end - - def patch - 0 - end +require "rubygems/version" - def pre - nil - end - - def to_h - { - major: major, - minor: minor, - patch: patch, - pre: pre - } - end - - def to_a - [major, minor, patch, pre].compact - end - - def to_s - to_a.join(".") - end - end +module X + VERSION = Gem::Version.create("0.4.0") end diff --git a/test/x/test_version.rb b/test/x/test_version.rb index ab79342..a8278e0 100644 --- a/test/x/test_version.rb +++ b/test/x/test_version.rb @@ -1,32 +1,28 @@ require "test_helper" -# Tests for X::Version module +# Tests for X::VERSION module class VersionTest < Minitest::Test - def test_major_version - refute_nil X::Version.major + def test_that_it_has_a_version_number + refute_nil ::X::VERSION end - def test_minor_version - refute_nil X::Version.minor + def test_segments_array + assert_kind_of Array, X::VERSION.segments end - def test_patch_version - refute_nil X::Version.patch + def test_major_version_integer + assert_kind_of Integer, X::VERSION.segments[0] end - def test_to_h - assert_kind_of Hash, X::Version.to_h + def test_minor_version_integer + assert_kind_of Integer, X::VERSION.segments[1] end - def test_to_a - assert_kind_of Array, X::Version.to_a + def test_patch_version_integer + assert_kind_of Integer, X::VERSION.segments[2] end def test_to_s - assert_kind_of String, X::Version.to_s - end - - def test_that_it_has_a_version_number - refute_nil ::X::Version + assert_kind_of String, X::VERSION.to_s end end diff --git a/x.gemspec b/x.gemspec index ae22670..d13687a 100644 --- a/x.gemspec +++ b/x.gemspec @@ -2,7 +2,7 @@ require_relative "lib/x/version" Gem::Specification.new do |spec| spec.name = "x" - spec.version = X::Version + spec.version = X::VERSION spec.authors = ["Erik Berlin"] spec.email = ["sferik@gmail.com"]