versionomy 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +15 -1
- data/README.rdoc +73 -22
- data/Rakefile +1 -1
- data/lib/versionomy/{formats.rb → conversion/base.rb} +36 -37
- data/lib/versionomy/conversion/parsing.rb +173 -0
- data/lib/versionomy/conversion/rubygems.rb +138 -0
- data/lib/versionomy/conversion.rb +145 -0
- data/lib/versionomy/errors.rb +22 -2
- data/lib/versionomy/format/base.rb +53 -5
- data/lib/versionomy/format/delimiter.rb +39 -27
- data/lib/versionomy/format/rubygems.rb +234 -0
- data/lib/versionomy/format/standard.rb +382 -0
- data/lib/versionomy/format.rb +73 -4
- data/lib/versionomy/interface.rb +22 -14
- data/lib/versionomy/schema/field.rb +14 -5
- data/lib/versionomy/schema/wrapper.rb +84 -10
- data/lib/versionomy/schema.rb +9 -6
- data/lib/versionomy/value.rb +191 -53
- data/lib/versionomy/version.rb +1 -1
- data/lib/versionomy.rb +6 -2
- data/tests/tc_custom_format.rb +4 -4
- data/tests/tc_readme_examples.rb +9 -9
- data/tests/tc_rubygems_basic.rb +210 -0
- data/tests/tc_rubygems_conversions.rb +178 -0
- data/tests/tc_standard_basic.rb +10 -10
- data/tests/tc_standard_bump.rb +10 -10
- data/tests/tc_standard_change.rb +5 -5
- data/tests/tc_standard_comparison.rb +29 -16
- data/tests/tc_standard_misc.rb +95 -0
- data/tests/tc_standard_parse.rb +43 -23
- metadata +15 -5
- data/lib/versionomy/formats/standard.rb +0 -346
data/tests/tc_readme_examples.rb
CHANGED
@@ -36,13 +36,13 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
require 'test/unit'
|
39
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
40
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
44
|
|
45
|
-
class TestReadmeExamples < Test::Unit::TestCase # :nodoc:
|
45
|
+
class TestReadmeExamples < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
48
|
# Test the README file.
|
@@ -51,7 +51,7 @@ module Versionomy
|
|
51
51
|
|
52
52
|
def test_readme_file
|
53
53
|
binding_ = _get_binding
|
54
|
-
File.open("#{File.dirname(__FILE__)}/../README.rdoc") do |io_|
|
54
|
+
::File.open("#{::File.dirname(__FILE__)}/../README.rdoc") do |io_|
|
55
55
|
running_ = false
|
56
56
|
buffer_ = ''
|
57
57
|
buffer_start_line_ = nil
|
@@ -68,7 +68,7 @@ module Versionomy
|
|
68
68
|
# a buffer to run all at once, because it might be code that
|
69
69
|
# gets spread over multiple lines.
|
70
70
|
delim_index_ = line_.index(' # ')
|
71
|
-
|
71
|
+
if !delim_index_ || line_[0, delim_index_].strip.length == 0
|
72
72
|
buffer_start_line_ ||= io_.lineno
|
73
73
|
buffer_ << line_
|
74
74
|
next
|
@@ -77,7 +77,7 @@ module Versionomy
|
|
77
77
|
# At this point, we have an expects clause. First run any buffer
|
78
78
|
# accumulated up to now.
|
79
79
|
if buffer_.length > 0
|
80
|
-
Kernel.eval(buffer_, binding_, 'README.rdoc', buffer_start_line_)
|
80
|
+
::Kernel.eval(buffer_, binding_, 'README.rdoc', buffer_start_line_)
|
81
81
|
buffer_ = ''
|
82
82
|
buffer_start_line_ = nil
|
83
83
|
end
|
@@ -88,17 +88,17 @@ module Versionomy
|
|
88
88
|
|
89
89
|
if expect_ =~ /^=> (.*)$/
|
90
90
|
# Expect a value
|
91
|
-
expect_value_ = Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
|
92
|
-
actual_value_ = Kernel.eval(expr_, binding_, 'README.rdoc', io_.lineno)
|
91
|
+
expect_value_ = ::Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
|
92
|
+
actual_value_ = ::Kernel.eval(expr_, binding_, 'README.rdoc', io_.lineno)
|
93
93
|
assert_equal(expect_value_, actual_value_,
|
94
94
|
"Values did not match on line #{io_.lineno} of README.rdoc")
|
95
95
|
|
96
96
|
elsif expect_ =~ /^raises (.*)$/
|
97
97
|
# Expect an exception to be raised
|
98
|
-
expect_error_ = Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
|
98
|
+
expect_error_ = ::Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
|
99
99
|
got_error_ = false
|
100
100
|
assert_raise(expect_error_) do
|
101
|
-
Kernel.eval(expr_, binding_, 'README.rdoc', io_.lineno)
|
101
|
+
::Kernel.eval(expr_, binding_, 'README.rdoc', io_.lineno)
|
102
102
|
end
|
103
103
|
|
104
104
|
else
|
@@ -0,0 +1,210 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy basic tests on rubygems schema
|
4
|
+
#
|
5
|
+
# This file contains tests for the basic use cases on the rubygems schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008-2009 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require 'test/unit'
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
|
+
|
41
|
+
|
42
|
+
module Versionomy
|
43
|
+
module Tests # :nodoc:
|
44
|
+
|
45
|
+
class TestRubygemsBasic < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
# Test the default version value.
|
49
|
+
|
50
|
+
def test_default_value
|
51
|
+
value_ = ::Versionomy.create(nil, :rubygems)
|
52
|
+
assert_equal(1, value_.field0)
|
53
|
+
assert_equal(0, value_.field1)
|
54
|
+
assert_equal(0, value_.field2)
|
55
|
+
assert_equal(0, value_.field3)
|
56
|
+
assert_equal(0, value_.field4)
|
57
|
+
assert_equal(0, value_.field5)
|
58
|
+
assert_equal(0, value_.field6)
|
59
|
+
assert_equal(0, value_.field7)
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
# Test an arbitrary value.
|
64
|
+
|
65
|
+
def test_arbitrary_value
|
66
|
+
value_ = ::Versionomy.create([1, 9, 2, 'pre', 2], :rubygems)
|
67
|
+
assert_equal(1, value_.field0)
|
68
|
+
assert_equal(9, value_.field1)
|
69
|
+
assert_equal(2, value_.field2)
|
70
|
+
assert_equal('pre', value_.field3)
|
71
|
+
assert_equal(2, value_.field4)
|
72
|
+
assert_equal(0, value_.field5)
|
73
|
+
assert_equal(0, value_.field6)
|
74
|
+
assert_equal(0, value_.field7)
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# Test comparison of numeric values.
|
79
|
+
|
80
|
+
def test_numeric_comparison
|
81
|
+
value1_ = ::Versionomy.create([1, 9, 2], :rubygems)
|
82
|
+
value2_ = ::Versionomy.create([1, 9], :rubygems)
|
83
|
+
assert(value2_ < value1_)
|
84
|
+
value1_ = ::Versionomy.create([1, 9, 0], :rubygems)
|
85
|
+
value2_ = ::Versionomy.create([1, 9], :rubygems)
|
86
|
+
assert(value2_ == value1_)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
# Test comparison of string values.
|
91
|
+
|
92
|
+
def test_string_comparison
|
93
|
+
value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
94
|
+
value2_ = ::Versionomy.create([1, 9, 2, 'b', 1], :rubygems)
|
95
|
+
assert(value2_ > value1_)
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
# Test comparison of numeric and string values.
|
100
|
+
|
101
|
+
def test_numeric_and_string_comparison
|
102
|
+
value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
103
|
+
value2_ = ::Versionomy.create([1, 9, 2, 1], :rubygems)
|
104
|
+
assert(value2_ > value1_)
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
# Test parsing numeric.
|
109
|
+
|
110
|
+
def test_parsing_numeric
|
111
|
+
value_ = ::Versionomy.parse('2.0.1.1.4.6', :rubygems)
|
112
|
+
assert_equal([2, 0, 1, 1, 4, 6, 0, 0], value_.values_array)
|
113
|
+
assert_equal('2.0.1.1.4.6', value_.unparse)
|
114
|
+
end
|
115
|
+
|
116
|
+
|
117
|
+
# Test parsing with a string.
|
118
|
+
|
119
|
+
def test_parsing_with_string
|
120
|
+
value_ = ::Versionomy.parse('1.9.2.pre.2', :rubygems)
|
121
|
+
assert_equal([1, 9, 2, 'pre', 2, 0, 0, 0], value_.values_array)
|
122
|
+
assert_equal('1.9.2.pre.2', value_.unparse)
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
# Test parsing with trailing zeros.
|
127
|
+
|
128
|
+
def test_parsing_trailing_zeros
|
129
|
+
value_ = ::Versionomy.parse('2.0.0', :rubygems)
|
130
|
+
assert_equal([2, 0, 0, 0, 0, 0, 0, 0], value_.values_array)
|
131
|
+
assert_equal('2.0.0', value_.unparse)
|
132
|
+
assert_equal('2.0.0.0.0', value_.unparse(:required_fields => [:field4]))
|
133
|
+
assert_equal('2.0', value_.unparse(:optional_fields => [:field2]))
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
# Test bumping a numeric field.
|
138
|
+
|
139
|
+
def test_bump_numeric
|
140
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
141
|
+
value_ = value_.bump(:field2)
|
142
|
+
assert_equal([1, 9, 3, 0, 0, 0, 0, 0], value_.values_array)
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
# Test bumping a string field.
|
147
|
+
|
148
|
+
def test_bump_string
|
149
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
150
|
+
value_ = value_.bump(:field3)
|
151
|
+
assert_equal([1, 9, 2, 'b', 0, 0, 0, 0], value_.values_array)
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# Test "prerelase?" custom method
|
156
|
+
|
157
|
+
def test_method_prereleasep
|
158
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
159
|
+
assert_equal(true, value_.prerelease?)
|
160
|
+
value_ = ::Versionomy.create([1, 9, 2, 2], :rubygems)
|
161
|
+
assert_equal(false, value_.prerelease?)
|
162
|
+
end
|
163
|
+
|
164
|
+
|
165
|
+
# Test "relase" custom method
|
166
|
+
|
167
|
+
def test_method_release
|
168
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
169
|
+
value2_ = value_.release
|
170
|
+
assert_equal([1, 9, 2, 0, 0, 0, 0, 0], value2_.values_array)
|
171
|
+
value_ = ::Versionomy.create([1, 9, 2, 5, 2], :rubygems)
|
172
|
+
value2_ = value_.release
|
173
|
+
assert_equal(value_, value2_)
|
174
|
+
end
|
175
|
+
|
176
|
+
|
177
|
+
# Test "parts" custom method
|
178
|
+
|
179
|
+
def test_method_parts
|
180
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
181
|
+
assert_equal([1, 9, 2, 'a', 2], value_.parts)
|
182
|
+
value_ = ::Versionomy.create([1, 9, 0], :rubygems)
|
183
|
+
assert_equal([1, 9], value_.parts)
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
# Test marshalling
|
188
|
+
|
189
|
+
def test_marshal
|
190
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
191
|
+
str_ = ::Marshal.dump(value_)
|
192
|
+
value2_ = ::Marshal.load(str_)
|
193
|
+
assert_equal(value_, value2_)
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
# Test YAML
|
198
|
+
|
199
|
+
def test_yaml
|
200
|
+
value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
|
201
|
+
str_ = ::YAML.dump(value_)
|
202
|
+
value2_ = ::YAML.load(str_)
|
203
|
+
assert_equal(value_, value2_)
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
end
|
208
|
+
|
209
|
+
end
|
210
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# -----------------------------------------------------------------------------
|
2
|
+
#
|
3
|
+
# Versionomy tests on rubygems schema conversions
|
4
|
+
#
|
5
|
+
# This file contains tests converting to and from the rubygems schema
|
6
|
+
#
|
7
|
+
# -----------------------------------------------------------------------------
|
8
|
+
# Copyright 2008-2009 Daniel Azuma
|
9
|
+
#
|
10
|
+
# All rights reserved.
|
11
|
+
#
|
12
|
+
# Redistribution and use in source and binary forms, with or without
|
13
|
+
# modification, are permitted provided that the following conditions are met:
|
14
|
+
#
|
15
|
+
# * Redistributions of source code must retain the above copyright notice,
|
16
|
+
# this list of conditions and the following disclaimer.
|
17
|
+
# * Redistributions in binary form must reproduce the above copyright notice,
|
18
|
+
# this list of conditions and the following disclaimer in the documentation
|
19
|
+
# and/or other materials provided with the distribution.
|
20
|
+
# * Neither the name of the copyright holder, nor the names of any other
|
21
|
+
# contributors to this software, may be used to endorse or promote products
|
22
|
+
# derived from this software without specific prior written permission.
|
23
|
+
#
|
24
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
28
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
29
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
30
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
31
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
32
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
33
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
34
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
35
|
+
# -----------------------------------------------------------------------------
|
36
|
+
|
37
|
+
|
38
|
+
require 'test/unit'
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
|
+
|
41
|
+
|
42
|
+
module Versionomy
|
43
|
+
module Tests # :nodoc:
|
44
|
+
|
45
|
+
class TestRubygemsConversions < ::Test::Unit::TestCase # :nodoc:
|
46
|
+
|
47
|
+
|
48
|
+
def setup
|
49
|
+
@standard_format = Format.get(:standard)
|
50
|
+
@rubygems_format = Format.get(:rubygems)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
# Test simple conversion from standard to rubygems.
|
55
|
+
|
56
|
+
def test_standard_to_rubygems_simple
|
57
|
+
value_ = ::Versionomy.parse('1.2')
|
58
|
+
value2_ = value_.convert(:rubygems)
|
59
|
+
assert_equal(@rubygems_format, value2_.format)
|
60
|
+
assert_equal([1, 2, 0, 0, 0, 0, 0, 0], value2_.values_array)
|
61
|
+
value_ = ::Versionomy.parse('1.2.4.1')
|
62
|
+
value2_ = value_.convert(:rubygems)
|
63
|
+
assert_equal(@rubygems_format, value2_.format)
|
64
|
+
assert_equal([1, 2, 4, 1, 0, 0, 0, 0], value2_.values_array)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# Test conversion from standard to rubygems including a patchlevel
|
69
|
+
|
70
|
+
def test_standard_to_rubygems_with_patchlevel
|
71
|
+
value_ = ::Versionomy.parse('1.2-3')
|
72
|
+
value2_ = value_.convert(:rubygems)
|
73
|
+
assert_equal([1, 2, 3, 0, 0, 0, 0, 0], value2_.values_array)
|
74
|
+
value_ = ::Versionomy.parse('1.2p3')
|
75
|
+
value2_ = value_.convert(:rubygems)
|
76
|
+
assert_equal([1, 2, 3, 0, 0, 0, 0, 0], value2_.values_array)
|
77
|
+
value_ = ::Versionomy.parse('1.2c')
|
78
|
+
value2_ = value_.convert(:rubygems)
|
79
|
+
assert_equal([1, 2, 3, 0, 0, 0, 0, 0], value2_.values_array)
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
# Test conversion from standard to rubygems with a beta version
|
84
|
+
|
85
|
+
def test_standard_to_rubygems_beta
|
86
|
+
value_ = ::Versionomy.parse('1.2b3')
|
87
|
+
value2_ = value_.convert(:rubygems)
|
88
|
+
assert_equal([1, 2, 'b', 3, 0, 0, 0, 0], value2_.values_array)
|
89
|
+
value_ = ::Versionomy.parse('1.2 beta 3.4')
|
90
|
+
value2_ = value_.convert(:rubygems)
|
91
|
+
assert_equal([1, 2, 'beta', 3, 4, 0, 0, 0], value2_.values_array)
|
92
|
+
end
|
93
|
+
|
94
|
+
|
95
|
+
# Test simple conversion from rubygems to standard.
|
96
|
+
|
97
|
+
def test_rubygems_to_standard_simple
|
98
|
+
value_ = ::Versionomy.parse('1.2', :rubygems)
|
99
|
+
value2_ = value_.convert(:standard)
|
100
|
+
assert_equal(@standard_format, value2_.format)
|
101
|
+
assert_equal([1, 2, 0, 0, :final, 0, 0], value2_.values_array)
|
102
|
+
value_ = ::Versionomy.parse('1.2.4.1', :rubygems)
|
103
|
+
value2_ = value_.convert(:standard)
|
104
|
+
assert_equal(@standard_format, value2_.format)
|
105
|
+
assert_equal([1, 2, 4, 1, :final, 0, 0], value2_.values_array)
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
# Test conversion from rubygems to standard with a beta version
|
110
|
+
|
111
|
+
def test_rubygems_to_standard_beta
|
112
|
+
value_ = ::Versionomy.parse('1.2.b.3', :rubygems)
|
113
|
+
value2_ = value_.convert(:standard)
|
114
|
+
assert_equal([1, 2, 0, 0, :beta, 3, 0], value2_.values_array)
|
115
|
+
value_ = ::Versionomy.parse('1.2.b3', :rubygems)
|
116
|
+
value2_ = value_.convert(:standard)
|
117
|
+
assert_equal([1, 2, 0, 0, :beta, 3, 0], value2_.values_array)
|
118
|
+
value_ = ::Versionomy.parse('1.2.beta3', :rubygems)
|
119
|
+
value2_ = value_.convert(:standard)
|
120
|
+
assert_equal([1, 2, 0, 0, :beta, 3, 0], value2_.values_array)
|
121
|
+
value_ = ::Versionomy.parse('1.2.b', :rubygems)
|
122
|
+
value2_ = value_.convert(:standard)
|
123
|
+
assert_equal([1, 2, 0, 0, :beta, 0, 0], value2_.values_array)
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
# Test conversion from rubygems to standard with an expectation of failure
|
128
|
+
|
129
|
+
def test_rubygems_to_standard_fail
|
130
|
+
value_ = ::Versionomy.parse('1.2.b.3.4.5', :rubygems)
|
131
|
+
assert_raise(::Versionomy::Errors::ConversionError) do
|
132
|
+
value2_ = value_.convert(:standard)
|
133
|
+
end
|
134
|
+
value_ = ::Versionomy.parse('1.2.c.3', :rubygems)
|
135
|
+
assert_raise(::Versionomy::Errors::ConversionError) do
|
136
|
+
value2_ = value_.convert(:standard)
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
|
141
|
+
# Test equality comparisons between rubygems and standard
|
142
|
+
|
143
|
+
def test_rubygems_to_standard_equality_comparison
|
144
|
+
assert_operator(::Versionomy.parse('1.2.0', :rubygems), :==, ::Versionomy.parse('1.2'))
|
145
|
+
assert_operator(::Versionomy.parse('1.2.b.3', :rubygems), :==, ::Versionomy.parse('1.2b3'))
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
# Test inequality comparisons between rubygems and standard
|
150
|
+
|
151
|
+
def test_rubygems_to_standard_equality_comparison
|
152
|
+
assert_operator(::Versionomy.parse('1.2.3', :rubygems), :<, ::Versionomy.parse('1.2.4'))
|
153
|
+
assert_operator(::Versionomy.parse('1.2.b.3', :rubygems), :>, ::Versionomy.parse('1.2b2'))
|
154
|
+
assert_operator(::Versionomy.parse('1.2', :rubygems), :>, ::Versionomy.parse('1.2b1'))
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
# Test equality comparisons between standard and rubygems
|
159
|
+
|
160
|
+
def test_standard_to_rubygems_equality_comparison
|
161
|
+
assert_operator(::Versionomy.parse('1.2.0'), :==, ::Versionomy.parse('1.2', :rubygems))
|
162
|
+
assert_operator(::Versionomy.parse('1.2b3'), :==, ::Versionomy.parse('1.2.beta.3', :rubygems))
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
# Test inequality comparisons between standard and rubygems
|
167
|
+
|
168
|
+
def test_standard_to_rubygems_inequality_comparison
|
169
|
+
assert_operator(::Versionomy.parse('1.2.4'), :>, ::Versionomy.parse('1.2.3', :rubygems))
|
170
|
+
assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2.beta.3', :rubygems))
|
171
|
+
assert_operator(::Versionomy.parse('1.2b2'), :<, ::Versionomy.parse('1.2', :rubygems))
|
172
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
end
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
data/tests/tc_standard_basic.rb
CHANGED
@@ -36,19 +36,19 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
require 'test/unit'
|
39
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
40
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
44
|
|
45
|
-
class TestStandardBasic < Test::Unit::TestCase # :nodoc:
|
45
|
+
class TestStandardBasic < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
48
|
# Test the default version value.
|
49
49
|
|
50
50
|
def test_default_value
|
51
|
-
value_ = Versionomy.create
|
51
|
+
value_ = ::Versionomy.create
|
52
52
|
assert_equal(1, value_.major)
|
53
53
|
assert_equal(0, value_.minor)
|
54
54
|
assert_equal(0, value_.tiny)
|
@@ -62,7 +62,7 @@ module Versionomy
|
|
62
62
|
# Test an arbitrary release value.
|
63
63
|
|
64
64
|
def test_release_value_1
|
65
|
-
value_ = Versionomy.create(:major => 1, :tiny => 4, :tiny2 => 2, :patchlevel => 5)
|
65
|
+
value_ = ::Versionomy.create(:major => 1, :tiny => 4, :tiny2 => 2, :patchlevel => 5)
|
66
66
|
assert_equal(1, value_.major)
|
67
67
|
assert_equal(0, value_.minor)
|
68
68
|
assert_equal(4, value_.tiny)
|
@@ -78,7 +78,7 @@ module Versionomy
|
|
78
78
|
# Test an arbitrary release value.
|
79
79
|
|
80
80
|
def test_release_value_2
|
81
|
-
value_ = Versionomy.create(:major => 0, :minor => 3)
|
81
|
+
value_ = ::Versionomy.create(:major => 0, :minor => 3)
|
82
82
|
assert_equal(0, value_.major)
|
83
83
|
assert_equal(3, value_.minor)
|
84
84
|
assert_equal(0, value_.tiny)
|
@@ -94,7 +94,7 @@ module Versionomy
|
|
94
94
|
# Test an arbitrary preview value.
|
95
95
|
|
96
96
|
def test_preview_value_1
|
97
|
-
value_ = Versionomy.create(:major => 2, :minor => 3, :release_type => :preview, :preview_version => 3)
|
97
|
+
value_ = ::Versionomy.create(:major => 2, :minor => 3, :release_type => :preview, :preview_version => 3)
|
98
98
|
assert_equal(2, value_.major)
|
99
99
|
assert_equal(3, value_.minor)
|
100
100
|
assert_equal(0, value_.tiny)
|
@@ -110,7 +110,7 @@ module Versionomy
|
|
110
110
|
# Test an arbitrary preview value.
|
111
111
|
|
112
112
|
def test_preview_value_2
|
113
|
-
value_ = Versionomy.create(:major => 2, :minor => 3, :release_type => :preview)
|
113
|
+
value_ = ::Versionomy.create(:major => 2, :minor => 3, :release_type => :preview)
|
114
114
|
assert_equal(2, value_.major)
|
115
115
|
assert_equal(3, value_.minor)
|
116
116
|
assert_equal(0, value_.tiny)
|
@@ -126,7 +126,7 @@ module Versionomy
|
|
126
126
|
# Test an arbitrary beta value.
|
127
127
|
|
128
128
|
def test_beta_value
|
129
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
129
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
130
130
|
assert_equal(2, value_.major)
|
131
131
|
assert_equal(0, value_.minor)
|
132
132
|
assert_equal(1, value_.tiny)
|
@@ -144,7 +144,7 @@ module Versionomy
|
|
144
144
|
# Test specifying fields by index.
|
145
145
|
|
146
146
|
def test_field_get_index
|
147
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
147
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
148
148
|
assert_equal(2, value_[0])
|
149
149
|
assert_equal(0, value_[1])
|
150
150
|
assert_equal(1, value_[2])
|
@@ -158,7 +158,7 @@ module Versionomy
|
|
158
158
|
# Test specifying fields by name.
|
159
159
|
|
160
160
|
def test_field_get_name
|
161
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
161
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :beta, :beta_version => 3)
|
162
162
|
assert_equal(2, value_[:major])
|
163
163
|
assert_equal(0, value_[:minor])
|
164
164
|
assert_equal(1, value_[:tiny])
|
data/tests/tc_standard_bump.rb
CHANGED
@@ -36,19 +36,19 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
require 'test/unit'
|
39
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
40
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
44
|
|
45
|
-
class TestStandardBump < Test::Unit::TestCase # :nodoc:
|
45
|
+
class TestStandardBump < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
48
|
# Test bumping a minor patchlevel.
|
49
49
|
|
50
50
|
def test_bump_patchlevel_minor
|
51
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 0)
|
51
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 0)
|
52
52
|
value_ = value_.bump(:patchlevel_minor)
|
53
53
|
assert_equal(2, value_.major)
|
54
54
|
assert_equal(0, value_.minor)
|
@@ -63,7 +63,7 @@ module Versionomy
|
|
63
63
|
# Test bumping a major patchlevel.
|
64
64
|
|
65
65
|
def test_bump_patchlevel
|
66
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 1)
|
66
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :patchlevel => 3, :patchlevel_minor => 1)
|
67
67
|
value_ = value_.bump(:patchlevel)
|
68
68
|
assert_equal(2, value_.major)
|
69
69
|
assert_equal(0, value_.minor)
|
@@ -78,7 +78,7 @@ module Versionomy
|
|
78
78
|
# Test bumping release type preview.
|
79
79
|
|
80
80
|
def test_bump_preview_to_release
|
81
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :preview)
|
81
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :preview)
|
82
82
|
value_ = value_.bump(:release_type)
|
83
83
|
assert_equal(2, value_.major)
|
84
84
|
assert_equal(0, value_.minor)
|
@@ -93,7 +93,7 @@ module Versionomy
|
|
93
93
|
# Test bumping release type development.
|
94
94
|
|
95
95
|
def test_bump_development_to_alpha
|
96
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :development, :development_version => 7)
|
96
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :development, :development_version => 7)
|
97
97
|
value_ = value_.bump(:release_type)
|
98
98
|
assert_equal(2, value_.major)
|
99
99
|
assert_equal(0, value_.minor)
|
@@ -108,7 +108,7 @@ module Versionomy
|
|
108
108
|
# Test bumping release type alpha.
|
109
109
|
|
110
110
|
def test_bump_alpha_to_beta
|
111
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :alpha)
|
111
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :alpha)
|
112
112
|
value_ = value_.bump(:release_type)
|
113
113
|
assert_equal(2, value_.major)
|
114
114
|
assert_equal(0, value_.minor)
|
@@ -123,7 +123,7 @@ module Versionomy
|
|
123
123
|
# Test bumping release type release_candidate.
|
124
124
|
|
125
125
|
def test_bump_release_candidate_to_release
|
126
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :release_type => :release_candidate, :release_candidate_version => 2)
|
126
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :release_type => :release_candidate, :release_candidate_version => 2)
|
127
127
|
value_ = value_.bump(:release_type)
|
128
128
|
assert_equal(2, value_.major)
|
129
129
|
assert_equal(0, value_.minor)
|
@@ -138,7 +138,7 @@ module Versionomy
|
|
138
138
|
# Test bumping tiny.
|
139
139
|
|
140
140
|
def test_bump_tiny
|
141
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
141
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
142
142
|
value_ = value_.bump(:tiny)
|
143
143
|
assert_equal(2, value_.major)
|
144
144
|
assert_equal(0, value_.minor)
|
@@ -153,7 +153,7 @@ module Versionomy
|
|
153
153
|
# Test bumping major.
|
154
154
|
|
155
155
|
def test_bump_major
|
156
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
156
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
157
157
|
value_ = value_.bump(:major)
|
158
158
|
assert_equal(3, value_.major)
|
159
159
|
assert_equal(0, value_.minor)
|
data/tests/tc_standard_change.rb
CHANGED
@@ -36,19 +36,19 @@
|
|
36
36
|
|
37
37
|
|
38
38
|
require 'test/unit'
|
39
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../lib/versionomy.rb")
|
39
|
+
require ::File.expand_path("#{::File.dirname(__FILE__)}/../lib/versionomy.rb")
|
40
40
|
|
41
41
|
|
42
42
|
module Versionomy
|
43
43
|
module Tests # :nodoc:
|
44
44
|
|
45
|
-
class TestStandardChange < Test::Unit::TestCase # :nodoc:
|
45
|
+
class TestStandardChange < ::Test::Unit::TestCase # :nodoc:
|
46
46
|
|
47
47
|
|
48
48
|
# Test with a changed tiny
|
49
49
|
|
50
50
|
def test_change_tiny
|
51
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
51
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
52
52
|
value_ = value_.change(:tiny => 4)
|
53
53
|
assert_equal(2, value_.major)
|
54
54
|
assert_equal(0, value_.minor)
|
@@ -63,7 +63,7 @@ module Versionomy
|
|
63
63
|
# Test with several changed fields
|
64
64
|
|
65
65
|
def test_change_several
|
66
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
66
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
67
67
|
value_ = value_.change(:tiny => 4, :release_candidate_version => 5)
|
68
68
|
assert_equal(2, value_.major)
|
69
69
|
assert_equal(0, value_.minor)
|
@@ -78,7 +78,7 @@ module Versionomy
|
|
78
78
|
# Test with a changed release type
|
79
79
|
|
80
80
|
def test_change_release_type
|
81
|
-
value_ = Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
81
|
+
value_ = ::Versionomy.create(:major => 2, :tiny => 1, :tiny2 => 3, :release_type => :release_candidate, :release_candidate_version => 2)
|
82
82
|
value_ = value_.change(:release_type => :beta)
|
83
83
|
assert_equal(2, value_.major)
|
84
84
|
assert_equal(0, value_.minor)
|