From f840e5b454dca7ec6d3929d2296396215e04b327 Mon Sep 17 00:00:00 2001 From: Daniel Azuma Date: Sun, 8 Nov 2009 14:53:59 -0800 Subject: [PATCH] Changes for 0.2.1 --- History.rdoc | 6 ++++++ README.rdoc | 4 +++- Rakefile | 2 +- lib/versionomy.rb | 7 +------ lib/versionomy/interface.rb | 24 ++++++++++++++++++++++++ lib/versionomy/version.rb | 6 +----- tests/tc_custom_format.rb | 1 + tests/tc_readme_examples.rb | 1 + tests/tc_rubygems_basic.rb | 1 + tests/tc_rubygems_conversions.rb | 1 + tests/tc_standard_basic.rb | 1 + tests/tc_standard_bump.rb | 1 + tests/tc_standard_change.rb | 1 + tests/tc_standard_comparison.rb | 1 + tests/tc_standard_misc.rb | 1 + tests/tc_standard_parse.rb | 1 + 16 files changed, 46 insertions(+), 13 deletions(-) diff --git a/History.rdoc b/History.rdoc index a78578c..407b4e0 100644 --- a/History.rdoc +++ b/History.rdoc @@ -1,3 +1,9 @@ +=== 0.2.1 / 2009-11-08 + +* Added Versionomy#version_of. +* Now lets Blockenspiel set its own VERSION instead of reaching into + Blockenspiel's namespace. + === 0.2.0 / 2009-11-05 * API CHANGE: Slight change to value comparison semantics. Value#eql? returns true only if the schemas are the same, whereas Value#== and the greater than and less than comparisons attempt to compare the semantic value, and thus may perform automatic schema conversion on the RHS. diff --git a/README.rdoc b/README.rdoc index d5ea4b9..0334fa4 100644 --- a/README.rdoc +++ b/README.rdoc @@ -138,7 +138,7 @@ provides a schema and formatter/parser matching Gem::Version. * Ruby 1.8.6 or later (1.8.7 recommended), Ruby 1.9.1 or later, or JRuby 1.4 or later. -* blockenspiel 0.3 or later. +* blockenspiel 0.3.1 or later. === Installation @@ -149,6 +149,8 @@ provides a schema and formatter/parser matching Gem::Version. * Test coverage is still a little skimpy. It is focused on the "standard" version number format and schema, but doesn't fully exercise all the capabilities of custom formats. +* The standard format parser requires that "prerelease" versions have a + prerelease number. e.g. it accepts "1.9.2dev1" but not "1.9.2dev". === Development and support diff --git a/Rakefile b/Rakefile index 580708b..c8d7f8d 100644 --- a/Rakefile +++ b/Rakefile @@ -89,7 +89,7 @@ gemspec_ = Gem::Specification.new do |s_| s_.has_rdoc = true s_.test_files = FileList['tests/tc_*.rb'] s_.platform = Gem::Platform::RUBY - s_.add_dependency('blockenspiel', '>= 0.3.0') + s_.add_dependency('blockenspiel', '>= 0.3.1') end Rake::GemPackageTask.new(gemspec_) do |task_| task_.need_zip = false diff --git a/lib/versionomy.rb b/lib/versionomy.rb index 25e9759..5be76eb 100644 --- a/lib/versionomy.rb +++ b/lib/versionomy.rb @@ -34,12 +34,7 @@ ; -begin - require 'blockenspiel' -rescue ::LoadError - require 'rubygems' - require 'blockenspiel' -end +require 'blockenspiel' dir_ = ::File.expand_path('versionomy', ::File.dirname(__FILE__)) diff --git a/lib/versionomy/interface.rb b/lib/versionomy/interface.rb index 7d028ef..9a1efde 100644 --- a/lib/versionomy/interface.rb +++ b/lib/versionomy/interface.rb @@ -130,6 +130,30 @@ def parse(str_, format_=nil, parse_params_=nil) format_.parse(str_, parse_params_) end + + # Get the version of the given module as a Versionomy::Value. + # Attempts to find the version by querying the constants VERSION and + # VERSION_STRING. If a string is found, an attempt is made to parse it. + # Returns the version number, or nil if it wasn't found or wasn't + # parseable. + + def version_of(mod_) + if mod_.const_defined?(:VERSION) + version_ = mod_.const_get(:VERSION) + elsif mod_.const_defined?(:VERSION_STRING) + version_ = mod_.const_get(:VERSION_STRING) + else + version_ = nil + end + if version_.kind_of?(::String) + version_ = parse(version_, :standard) rescue nil + elsif !version_.kind_of?(Value) + version_ = nil + end + version_ + end + + end end diff --git a/lib/versionomy/version.rb b/lib/versionomy/version.rb index 710caa5..0b2d5da 100644 --- a/lib/versionomy/version.rb +++ b/lib/versionomy/version.rb @@ -37,13 +37,9 @@ module Versionomy # Current gem version, as a frozen string. - VERSION_STRING = '0.2.0'.freeze + VERSION_STRING = '0.2.1'.freeze # Current gem version, as a Versionomy::Value. VERSION = ::Versionomy.parse(VERSION_STRING, :standard) end - - -::Blockenspiel.const_set(:VERSION, - ::Versionomy.parse(::Blockenspiel::VERSION_STRING, :standard)) diff --git a/tests/tc_custom_format.rb b/tests/tc_custom_format.rb index 13b6d9a..8652a86 100644 --- a/tests/tc_custom_format.rb +++ b/tests/tc_custom_format.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_readme_examples.rb b/tests/tc_readme_examples.rb index 4546730..9885194 100644 --- a/tests/tc_readme_examples.rb +++ b/tests/tc_readme_examples.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_rubygems_basic.rb b/tests/tc_rubygems_basic.rb index 6fd7f15..9ee93c4 100644 --- a/tests/tc_rubygems_basic.rb +++ b/tests/tc_rubygems_basic.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_rubygems_conversions.rb b/tests/tc_rubygems_conversions.rb index fd8be1b..f1d67df 100644 --- a/tests/tc_rubygems_conversions.rb +++ b/tests/tc_rubygems_conversions.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_basic.rb b/tests/tc_standard_basic.rb index e207c3c..d5cb0f4 100644 --- a/tests/tc_standard_basic.rb +++ b/tests/tc_standard_basic.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_bump.rb b/tests/tc_standard_bump.rb index 023fa97..4895bbb 100644 --- a/tests/tc_standard_bump.rb +++ b/tests/tc_standard_bump.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_change.rb b/tests/tc_standard_change.rb index 233031b..e464ac3 100644 --- a/tests/tc_standard_change.rb +++ b/tests/tc_standard_change.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_comparison.rb b/tests/tc_standard_comparison.rb index 1232f1b..7f773e1 100644 --- a/tests/tc_standard_comparison.rb +++ b/tests/tc_standard_comparison.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_misc.rb b/tests/tc_standard_misc.rb index a1e85a6..d6d5c0e 100644 --- a/tests/tc_standard_misc.rb +++ b/tests/tc_standard_misc.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb") diff --git a/tests/tc_standard_parse.rb b/tests/tc_standard_parse.rb index 07027ff..165088f 100644 --- a/tests/tc_standard_parse.rb +++ b/tests/tc_standard_parse.rb @@ -35,6 +35,7 @@ # ----------------------------------------------------------------------------- +require 'rubygems' require 'test/unit' require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")