versionomy 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -1
- data/README.txt +1 -1
- data/lib/versionomy/schema.rb +9 -0
- data/lib/versionomy/value.rb +49 -13
- data/lib/versionomy/version.rb +1 -1
- data/tests/tc_standard_comparison.rb +30 -0
- metadata +2 -2
data/History.txt
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
=== 0.0.3 / 2008-10-21
|
2
|
+
|
3
|
+
* Fixed string representations (inspect method)
|
4
|
+
* Fixed up equality and hash computation for version values
|
5
|
+
|
1
6
|
=== 0.0.2 / 2008-10-20
|
2
7
|
|
3
|
-
*
|
8
|
+
* Test release: Fixed manifest
|
4
9
|
|
5
10
|
=== 0.0.1 / 2008-10-20
|
6
11
|
|
data/README.txt
CHANGED
data/lib/versionomy/schema.rb
CHANGED
data/lib/versionomy/value.rb
CHANGED
@@ -75,16 +75,33 @@ module Versionomy
|
|
75
75
|
end
|
76
76
|
|
77
77
|
|
78
|
+
def inspect # :nodoc:
|
79
|
+
begin
|
80
|
+
str_ = unparse
|
81
|
+
"#<#{self.class}:0x#{object_id.to_s(16)} #{str_.inspect}>"
|
82
|
+
rescue Versionomy::Errors::ParseError
|
83
|
+
_inspect
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def _inspect # :nodoc:
|
88
|
+
"#<#{self.class}:0x#{object_id.to_s(16)}#{_inspect2}>"
|
89
|
+
end
|
90
|
+
|
91
|
+
def _inspect2 # :nodoc:
|
92
|
+
" #{@schema.name}=#{@value.inspect}#{@subvalue ? @subvalue._inspect2 : ''}"
|
93
|
+
end
|
94
|
+
|
95
|
+
|
78
96
|
# Returns a string representation generated by unparsing.
|
79
97
|
# If unparsing fails, does not raise Versionomy::Errors::ParseError,
|
80
98
|
# but instead returns the string generated by +inspect+.
|
81
|
-
#
|
82
99
|
|
83
100
|
def to_s
|
84
101
|
begin
|
85
102
|
unparse
|
86
103
|
rescue Versionomy::Errors::ParseError
|
87
|
-
|
104
|
+
_inspect
|
88
105
|
end
|
89
106
|
end
|
90
107
|
|
@@ -197,14 +214,27 @@ module Versionomy
|
|
197
214
|
end
|
198
215
|
|
199
216
|
|
217
|
+
def hash # :nodoc:
|
218
|
+
@schema.name.hash ^ @value.hash ^ @subvalue.hash
|
219
|
+
end
|
220
|
+
|
221
|
+
|
200
222
|
# Returns true if this version number is equal to the given verison number.
|
201
223
|
# Equality means the values and field names are the same, although the
|
202
224
|
# schemas may actually be different.
|
203
225
|
|
204
226
|
def eql?(obj_)
|
205
|
-
|
206
|
-
|
207
|
-
|
227
|
+
if obj_.kind_of?(Versionomy::Value)
|
228
|
+
if @schema.name != obj_.schema.name || @value != obj_.toplevel_value
|
229
|
+
false
|
230
|
+
elsif @subvalue
|
231
|
+
@subvalue.eql?(obj_.subvalue)
|
232
|
+
else
|
233
|
+
true
|
234
|
+
end
|
235
|
+
else
|
236
|
+
false
|
237
|
+
end
|
208
238
|
end
|
209
239
|
|
210
240
|
|
@@ -222,17 +252,23 @@ module Versionomy
|
|
222
252
|
# even if the schemas are different.
|
223
253
|
|
224
254
|
def <=>(obj_)
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
if val_ == 0
|
229
|
-
if @subvalue.nil?
|
230
|
-
obj_.subvalue.nil? ? 0 : nil
|
255
|
+
if obj_.kind_of?(Versionomy::Value)
|
256
|
+
if @schema.name != obj_.schema.name
|
257
|
+
nil
|
231
258
|
else
|
232
|
-
@
|
259
|
+
val_ = @schema.compare_values(@value, obj_.toplevel_value)
|
260
|
+
if val_ == 0
|
261
|
+
if @subvalue.nil?
|
262
|
+
obj_.subvalue.nil? ? 0 : nil
|
263
|
+
else
|
264
|
+
@subvalue <=> obj_.subvalue
|
265
|
+
end
|
266
|
+
else
|
267
|
+
val_
|
268
|
+
end
|
233
269
|
end
|
234
270
|
else
|
235
|
-
|
271
|
+
nil
|
236
272
|
end
|
237
273
|
end
|
238
274
|
|
data/lib/versionomy/version.rb
CHANGED
@@ -71,6 +71,36 @@ module Versionomy
|
|
71
71
|
end
|
72
72
|
|
73
73
|
|
74
|
+
# Test equality for a simple case.
|
75
|
+
|
76
|
+
def test_equality_simple
|
77
|
+
value1_ = Versionomy.create(:major => 2, :minor => 0, :release_type => :alpha, :alpha_version => 5)
|
78
|
+
value2_ = Versionomy.create(:major => 2, :release_type => :alpha, :alpha_version => 5)
|
79
|
+
assert_equal(value2_, value1_)
|
80
|
+
assert_equal(value2_.hash, value1_.hash)
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
# Test equality from parsed values.
|
85
|
+
|
86
|
+
def test_equality_parsed
|
87
|
+
value1_ = Versionomy.parse("1.8.7p72")
|
88
|
+
value2_ = Versionomy.parse("1.8.7.0-72.0")
|
89
|
+
assert_equal(value2_, value1_)
|
90
|
+
assert_equal(value2_.hash, value1_.hash)
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
# Test non-equality from parsed values.
|
95
|
+
|
96
|
+
def test_nonequality_parsed
|
97
|
+
value1_ = Versionomy.parse("1.8.7b7")
|
98
|
+
value2_ = Versionomy.parse("1.8.7a7")
|
99
|
+
assert_not_equal(value2_, value1_)
|
100
|
+
assert_not_equal(value2_.hash, value1_.hash)
|
101
|
+
end
|
102
|
+
|
103
|
+
|
74
104
|
end
|
75
105
|
|
76
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versionomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Azuma
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-21 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|