Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support a few more syntaxes in the standard format

  • Loading branch information...
commit 424a055ee3384c95f33e24d50b43f8da750af106 1 parent 1e19833
@dazuma authored
View
5 History.rdoc
@@ -1,3 +1,8 @@
+=== 0.2.3 / 2009-11-19
+
+* Recognize "_" and "u" as patchlevel delimiters, to support Sun's Java version numbers (e.g. "1.6.0_17", "6u17").
+* Recognize "v" prefix found on some version numbers (e.g. "v1.2")
+
=== 0.2.2 / 2009-11-18
* Standard format now supports certain kinds of prereleases without a prerelease number. e.g. "1.9.2dev" is interpreted as the same number as "1.9.2dev0".
View
4 lib/versionomy/conversion/rubygems.rb
@@ -86,6 +86,10 @@ def self.create_standard_to_rubygems
# the unparsing to generate "1.9.1-243".
params_[:patchlevel_delim] = nil
+ # If the standard format version includes a "v" prefix, strip
+ # it because rubygems doesn't like it.
+ params_[:major_delim] = nil
+
params_
end
View
7 lib/versionomy/format/standard.rb
@@ -247,9 +247,10 @@ def self.create
format_ = Format::Delimiter.new(schema_) do
# All version number strings must start with the major version.
- # Unlike other fields, it is not preceded by any delimiter.
+ # Unlike other fields, it is not preceded by the usual "dot"
+ # delimiter, but it can be preceded by a "v" indicator.
field(:major) do
- recognize_number(:delimiter_regexp => '', :default_delimiter => '')
+ recognize_number(:delimiter_regexp => '(v\s?)?', :default_delimiter => '')
end
# The remainder of the core version number are represented as
@@ -369,7 +370,7 @@ def self.create
field(:patchlevel, :requires_previous_field => false,
:default_value_optional => true, :default_style => :number) do
recognize_number(:style => :number, :default_delimiter => '-',
- :delimiter_regexp => '(-|\.|\s?)p|-')
+ :delimiter_regexp => '(-|\.|\s?)(p|u)|-|_')
recognize_letter(:style => :letter, :default_delimiter => '',
:delimiter_regexp => '-|\.|\s?',
:expected_follower_regexp => '\z')
View
12 tests/tc_rubygems_conversions.rb
@@ -93,6 +93,18 @@ def test_standard_to_rubygems_beta
end
+ # Test conversion from standard to rubygems with a "v" prefix
+
+ def test_standard_to_rubygems_with_v
+ value_ = ::Versionomy.parse('v1.2b3')
+ value2_ = value_.convert(:rubygems)
+ assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)
+ value_ = ::Versionomy.parse('V 1.2b3')
+ value2_ = value_.convert(:rubygems)
+ assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)
+ end
+
+
# Test simple conversion from rubygems to standard.
def test_rubygems_to_standard_simple
View
24 tests/tc_standard_parse.rb
@@ -281,6 +281,30 @@ def test_unparse_with_custom_delimiters
end
+ # Test java version formats
+
+ def test_java_formats
+ value_ = ::Versionomy.parse('1.6.0_17')
+ assert_equal([1, 6, 0, 0, :final, 17, 0], value_.values_array)
+ assert_equal('1.6.0_17', value_.to_s)
+ value_ = ::Versionomy.parse('6u17')
+ assert_equal([6, 0, 0, 0, :final, 17, 0], value_.values_array)
+ assert_equal('6u17', value_.to_s)
+ end
+
+
+ # Test formats prefixed with "v"
+
+ def test_v_prefix
+ value_ = ::Versionomy.parse('v1.2')
+ assert_equal([1, 2, 0, 0, :final, 0, 0], value_.values_array)
+ assert_equal('v1.2', value_.to_s)
+ value_ = ::Versionomy.parse('V 2.3')
+ assert_equal([2, 3, 0, 0, :final, 0, 0], value_.values_array)
+ assert_equal('V 2.3', value_.to_s)
+ end
+
+
# Test parse errors
def test_parsing_errors
Please sign in to comment.
Something went wrong with that request. Please try again.