versionomy 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +10 -1
- data/README.txt +0 -1
- data/Rakefile +1 -1
- data/lib/versionomy/errors.rb +7 -0
- data/lib/versionomy/format.rb +25 -3
- data/lib/versionomy/schema.rb +22 -17
- data/lib/versionomy/standard.rb +50 -43
- data/lib/versionomy/value.rb +48 -33
- data/lib/versionomy/version.rb +1 -1
- data/tests/tc_standard_comparison.rb +21 -0
- data/tests/tc_standard_parse.rb +21 -0
- metadata +4 -4
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
=== 0.0.4 / 2008-10-24
|
2
|
+
|
3
|
+
* Fixed incompatibility with Blockenspiel 0.0.4
|
4
|
+
* Fixed a number of issues with remembering value parse settings
|
5
|
+
* Parser recognizes additional release type formats
|
6
|
+
* Values have a parse method to parse another string in the same form
|
7
|
+
* Implemented comparison between value and string
|
8
|
+
* Exceptions correctly raised on comparison between incompatible types
|
9
|
+
|
1
10
|
=== 0.0.3 / 2008-10-21
|
2
11
|
|
3
12
|
* Fixed string representations (inspect method)
|
@@ -5,7 +14,7 @@
|
|
5
14
|
|
6
15
|
=== 0.0.2 / 2008-10-20
|
7
16
|
|
8
|
-
*
|
17
|
+
* Fixed manifest
|
9
18
|
|
10
19
|
=== 0.0.1 / 2008-10-20
|
11
20
|
|
data/README.txt
CHANGED
data/Rakefile
CHANGED
@@ -43,7 +43,7 @@ Hoe.new('versionomy', Versionomy::VERSION_STRING) do |p_|
|
|
43
43
|
p_.author = ['Daniel Azuma']
|
44
44
|
p_.email = ['dazuma@gmail.com']
|
45
45
|
p_.test_globs = ['tests/tc_*.rb']
|
46
|
-
p_.extra_deps = [['blockenspiel', '>= 0.0.
|
46
|
+
p_.extra_deps = [['blockenspiel', '>= 0.0.4']]
|
47
47
|
p_.description_sections = ['versionomy']
|
48
48
|
p_.url = 'http://virtuoso.rubyforge.org/versionomy'
|
49
49
|
end
|
data/lib/versionomy/errors.rb
CHANGED
@@ -61,6 +61,13 @@ module Versionomy
|
|
61
61
|
end
|
62
62
|
|
63
63
|
|
64
|
+
# This exception is raised if you try to perform a comparison
|
65
|
+
# between incompatible schemas.
|
66
|
+
|
67
|
+
class SchemaMismatchError < VersionomyError
|
68
|
+
end
|
69
|
+
|
70
|
+
|
64
71
|
# This exception is raised during parsing if the specified format
|
65
72
|
# name is not recognized.
|
66
73
|
|
data/lib/versionomy/format.rb
CHANGED
@@ -42,7 +42,10 @@ module Versionomy
|
|
42
42
|
module Format
|
43
43
|
|
44
44
|
|
45
|
-
# A simple base formatter
|
45
|
+
# A simple base formatter.
|
46
|
+
#
|
47
|
+
# Formats need not extend this base class, as long as they duck-type the
|
48
|
+
# required methods name, parse, and unparse.
|
46
49
|
|
47
50
|
class Base
|
48
51
|
|
@@ -50,7 +53,8 @@ module Versionomy
|
|
50
53
|
# If a block is provided, you may call methods of Versionomy::Format::Builder
|
51
54
|
# within the block, to specify ways to parse and unparse.
|
52
55
|
|
53
|
-
def initialize(&block_)
|
56
|
+
def initialize(name_, &block_)
|
57
|
+
@name = name_.to_sym
|
54
58
|
@parser = @unparser = nil
|
55
59
|
Blockenspiel.invoke(block_, Versionomy::Format::Builder.new(self))
|
56
60
|
end
|
@@ -64,6 +68,17 @@ module Versionomy
|
|
64
68
|
@unparser = block_
|
65
69
|
end
|
66
70
|
|
71
|
+
def _set_name(name_) # :nodoc:
|
72
|
+
@name = name_
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
# The format name
|
77
|
+
|
78
|
+
def name
|
79
|
+
@name
|
80
|
+
end
|
81
|
+
|
67
82
|
|
68
83
|
# A simple parse algorithm.
|
69
84
|
# If a parser block was provided during initialization, calls that block.
|
@@ -87,7 +102,7 @@ module Versionomy
|
|
87
102
|
if @unparser
|
88
103
|
@unparser.call(schema_, value_, params_)
|
89
104
|
else
|
90
|
-
value_.
|
105
|
+
value_.values.join('.')
|
91
106
|
end
|
92
107
|
end
|
93
108
|
|
@@ -124,6 +139,13 @@ module Versionomy
|
|
124
139
|
@format._set_unparser(block_)
|
125
140
|
end
|
126
141
|
|
142
|
+
|
143
|
+
# Specify the format name
|
144
|
+
|
145
|
+
def set_name(name_)
|
146
|
+
@format._set_name(name_)
|
147
|
+
end
|
148
|
+
|
127
149
|
end
|
128
150
|
|
129
151
|
|
data/lib/versionomy/schema.rb
CHANGED
@@ -103,7 +103,7 @@ module Versionomy
|
|
103
103
|
@default_subschema = nil
|
104
104
|
@formats = Hash.new
|
105
105
|
@default_format_name = nil
|
106
|
-
Blockenspiel.invoke(block_, Versionomy::Schema::Builder.new(self))
|
106
|
+
Blockenspiel.invoke(block_, Versionomy::Schema::Builder.new(self)) if block_
|
107
107
|
@initial_value = canonicalize_value(@initial_value)
|
108
108
|
end
|
109
109
|
|
@@ -231,17 +231,18 @@ module Versionomy
|
|
231
231
|
end
|
232
232
|
|
233
233
|
|
234
|
-
# Define a
|
235
|
-
#
|
236
|
-
#
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
@
|
234
|
+
# Define a format for this schema.
|
235
|
+
#
|
236
|
+
# You may either:
|
237
|
+
#
|
238
|
+
# * pass a format, or
|
239
|
+
# * pass a name and provide a block that calls methods in
|
240
|
+
# Versionomy::Format::Builder.
|
241
|
+
|
242
|
+
def define_format(format_=nil, &block_)
|
243
|
+
format_ = Versionomy::Format::Base.new(format_, &block_) if block_
|
244
|
+
@formats[format_.name] = format_
|
245
|
+
@default_format_name ||= format_.name
|
245
246
|
end
|
246
247
|
|
247
248
|
|
@@ -522,12 +523,16 @@ module Versionomy
|
|
522
523
|
end
|
523
524
|
|
524
525
|
|
525
|
-
# Define a
|
526
|
-
#
|
527
|
-
#
|
526
|
+
# Define a format for this schema.
|
527
|
+
#
|
528
|
+
# You may either:
|
529
|
+
#
|
530
|
+
# * pass a format, or
|
531
|
+
# * pass a name and provide a block that calls methods in
|
532
|
+
# Versionomy::Format::Builder.
|
528
533
|
|
529
|
-
def define_format(
|
530
|
-
@schema.define_format(
|
534
|
+
def define_format(format_=nil, &block_)
|
535
|
+
@schema.define_format(format_, &block_)
|
531
536
|
end
|
532
537
|
|
533
538
|
|
data/lib/versionomy/standard.rb
CHANGED
@@ -107,12 +107,19 @@ module Versionomy
|
|
107
107
|
# Create a new formatter
|
108
108
|
|
109
109
|
def initialize(opts_={})
|
110
|
-
@
|
111
|
-
@
|
112
|
-
@
|
113
|
-
@
|
114
|
-
@
|
115
|
-
@
|
110
|
+
@name = opts_[:name] || :standard
|
111
|
+
@patchlevel_separator = opts_[:patchlevel_separator] || ['-', '\s?[Pp]']
|
112
|
+
@prerelease_symbol = opts_[:prerelease_symbol] || '\s?(PRE|Pre|pre)'
|
113
|
+
@development_symbol = opts_[:development_symbol] || '\s?[Dd]'
|
114
|
+
@alpha_symbol = opts_[:alpha_symbol] || '\s?[Aa](LPHA|lpha)?'
|
115
|
+
@beta_symbol = opts_[:beta_symbol] || '\s?[Bb](ETA|eta)?'
|
116
|
+
@release_candidate_symbol = opts_[:release_candidate_symbol] || '\s?(RC|Rc|rc)'
|
117
|
+
@patchlevel_separator_unparse = opts_[:patchlevel_separator_unparse] || '-'
|
118
|
+
@prerelease_symbol_unparse = opts_[:prerelease_symbol_unparse] || 'pre'
|
119
|
+
@development_symbol_unparse = opts_[:development_symbol_unparse] || 'd'
|
120
|
+
@alpha_symbol_unparse = opts_[:alpha_symbol_unparse] || 'a'
|
121
|
+
@beta_symbol_unparse = opts_[:beta_symbol_unparse] || 'b'
|
122
|
+
@release_candidate_symbol_unparse = opts_[:release_candidate_symbol_unparse] || 'rc'
|
116
123
|
end
|
117
124
|
|
118
125
|
|
@@ -133,24 +140,18 @@ module Versionomy
|
|
133
140
|
end
|
134
141
|
private :_create_regex
|
135
142
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
default_[0].to_s
|
142
|
-
else
|
143
|
-
default_.to_s
|
144
|
-
end
|
145
|
-
end
|
143
|
+
|
144
|
+
# The format name
|
145
|
+
|
146
|
+
def name
|
147
|
+
@name
|
146
148
|
end
|
147
|
-
private :_create_separator
|
148
149
|
|
149
150
|
|
150
151
|
# Parse a string for the standard schema.
|
151
152
|
|
152
153
|
def parse(schema_, str_, params_)
|
153
|
-
params_ =
|
154
|
+
params_ = {:format => @name}.merge(params_)
|
154
155
|
hash_ = Hash.new
|
155
156
|
if str_ =~ /^(\d+)(.*)$/
|
156
157
|
hash_[:major] = $1.to_i
|
@@ -181,10 +182,11 @@ module Versionomy
|
|
181
182
|
params_[:required_fields] = 1
|
182
183
|
end
|
183
184
|
if str_ =~ /^(#{_create_regex(params_[:prerelease_symbol], @prerelease_symbol)})(\d+)(.*)$/
|
184
|
-
|
185
|
+
matches_ = $~
|
186
|
+
params_[:prerelease_symbol_unparse] = matches_[1]
|
185
187
|
hash_[:release_type] = :prerelease
|
186
|
-
hash_[:prerelease_version] =
|
187
|
-
str_ =
|
188
|
+
hash_[:prerelease_version] = matches_[-2].to_i
|
189
|
+
str_ = matches_[-1]
|
188
190
|
if str_ =~ /^\.(\d+)/
|
189
191
|
hash_[:prerelease_minor] = $1.to_i
|
190
192
|
params_[:prerelease_required_fields] = 2
|
@@ -192,10 +194,11 @@ module Versionomy
|
|
192
194
|
params_[:prerelease_required_fields] = 1
|
193
195
|
end
|
194
196
|
elsif str_ =~ /^(#{_create_regex(params_[:development_symbol], @development_symbol)})(\d+)(.*)$/
|
195
|
-
|
197
|
+
matches_ = $~
|
198
|
+
params_[:development_symbol_unparse] = matches_[1]
|
196
199
|
hash_[:release_type] = :development
|
197
|
-
hash_[:development_version] =
|
198
|
-
str_ =
|
200
|
+
hash_[:development_version] = matches_[-2].to_i
|
201
|
+
str_ = matches_[-1]
|
199
202
|
if str_ =~ /^\.(\d+)/
|
200
203
|
hash_[:development_minor] = $1.to_i
|
201
204
|
params_[:development_required_fields] = 2
|
@@ -203,10 +206,11 @@ module Versionomy
|
|
203
206
|
params_[:development_required_fields] = 1
|
204
207
|
end
|
205
208
|
elsif str_ =~ /^(#{_create_regex(params_[:alpha_symbol], @alpha_symbol)})(\d+)(.*)$/
|
206
|
-
|
209
|
+
matches_ = $~
|
210
|
+
params_[:alpha_symbol_unparse] = matches_[1]
|
207
211
|
hash_[:release_type] = :alpha
|
208
|
-
hash_[:alpha_version] =
|
209
|
-
str_ =
|
212
|
+
hash_[:alpha_version] = matches_[-2].to_i
|
213
|
+
str_ = matches_[-1]
|
210
214
|
if str_ =~ /^\.(\d+)/
|
211
215
|
hash_[:alpha_minor] = $1.to_i
|
212
216
|
params_[:alpha_required_fields] = 2
|
@@ -214,10 +218,11 @@ module Versionomy
|
|
214
218
|
params_[:alpha_required_fields] = 1
|
215
219
|
end
|
216
220
|
elsif str_ =~ /^(#{_create_regex(params_[:beta_symbol], @beta_symbol)})(\d+)(.*)$/
|
217
|
-
|
221
|
+
matches_ = $~
|
222
|
+
params_[:beta_symbol_unparse] = matches_[1]
|
218
223
|
hash_[:release_type] = :beta
|
219
|
-
hash_[:beta_version] =
|
220
|
-
str_ =
|
224
|
+
hash_[:beta_version] = matches_[-2].to_i
|
225
|
+
str_ = matches_[-1]
|
221
226
|
if str_ =~ /^\.(\d+)/
|
222
227
|
hash_[:beta_minor] = $1.to_i
|
223
228
|
params_[:beta_required_fields] = 2
|
@@ -225,10 +230,11 @@ module Versionomy
|
|
225
230
|
params_[:beta_required_fields] = 1
|
226
231
|
end
|
227
232
|
elsif str_ =~ /^(#{_create_regex(params_[:release_candidate_symbol], @release_candidate_symbol)})(\d+)(.*)$/
|
228
|
-
|
229
|
-
|
233
|
+
matches_ = $~
|
234
|
+
params_[:release_candidate_symbol_unparse] = matches_[1]
|
235
|
+
hash_[:release_candidate_version] = matches_[-2].to_i
|
230
236
|
hash_[:release_type] = :release_candidate
|
231
|
-
str_ =
|
237
|
+
str_ = matches_[-1]
|
232
238
|
if str_ =~ /^\.(\d+)/
|
233
239
|
hash_[:release_candidate_minor] = $1.to_i
|
234
240
|
params_[:release_candidate_required_fields] = 2
|
@@ -238,10 +244,11 @@ module Versionomy
|
|
238
244
|
else
|
239
245
|
hash_[:release_type] = :release
|
240
246
|
if str_ =~ /^(#{_create_regex(params_[:patchlevel_separator], @patchlevel_separator)})(\d+)(.*)$/
|
241
|
-
|
247
|
+
matches_ = $~
|
248
|
+
params_[:patchlevel_separator_unparse] = matches_[1]
|
242
249
|
params_[:patchlevel_format] = :digit
|
243
|
-
hash_[:patchlevel] =
|
244
|
-
str_ =
|
250
|
+
hash_[:patchlevel] = matches_[-2].to_i
|
251
|
+
str_ = matches_[-1]
|
245
252
|
if str_ =~ /^\.(\d+)/
|
246
253
|
hash_[:patchlevel_minor] = $1.to_i
|
247
254
|
params_[:patchlevel_required_fields] = 2
|
@@ -273,35 +280,35 @@ module Versionomy
|
|
273
280
|
case value_.release_type
|
274
281
|
when :prerelease
|
275
282
|
prerelease_required_fields_ = params_[:prerelease_required_fields] || 1
|
276
|
-
str_ <<
|
283
|
+
str_ << (params_[:prerelease_symbol_unparse] || @prerelease_symbol_unparse)
|
277
284
|
str_ << value_.prerelease_version.to_s
|
278
285
|
if value_.prerelease_minor > 0 || prerelease_required_fields_ > 1
|
279
286
|
str_ << ".#{value_.prerelease_minor}"
|
280
287
|
end
|
281
288
|
when :development
|
282
289
|
development_required_fields_ = params_[:development_required_fields] || 1
|
283
|
-
str_ <<
|
290
|
+
str_ << (params_[:development_symbol_unparse] || @development_symbol_unparse)
|
284
291
|
str_ << value_.development_version.to_s
|
285
292
|
if value_.development_minor > 0 || development_required_fields_ > 1
|
286
293
|
str_ << ".#{value_.development_minor}"
|
287
294
|
end
|
288
295
|
when :alpha
|
289
296
|
alpha_required_fields_ = params_[:alpha_required_fields] || 1
|
290
|
-
str_ <<
|
297
|
+
str_ << (params_[:alpha_symbol_unparse] || @alpha_symbol_unparse)
|
291
298
|
str_ << value_.alpha_version.to_s
|
292
299
|
if value_.alpha_minor > 0 || alpha_required_fields_ > 1
|
293
300
|
str_ << ".#{value_.alpha_minor}"
|
294
301
|
end
|
295
302
|
when :beta
|
296
303
|
beta_required_fields_ = params_[:beta_required_fields] || 1
|
297
|
-
str_ <<
|
304
|
+
str_ << (params_[:beta_symbol_unparse] || @beta_symbol_unparse)
|
298
305
|
str_ << value_.beta_version.to_s
|
299
306
|
if value_.beta_minor > 0 || beta_required_fields_ > 1
|
300
307
|
str_ << ".#{value_.beta_minor}"
|
301
308
|
end
|
302
309
|
when :release_candidate
|
303
310
|
release_candidate_required_fields_ = params_[:release_candidate_required_fields] || 1
|
304
|
-
str_ <<
|
311
|
+
str_ << (params_[:release_candidate_symbol_unparse] || @release_candidate_symbol_unparse)
|
305
312
|
str_ << value_.release_candidate_version.to_s
|
306
313
|
if value_.release_candidate_minor > 0 || release_candidate_required_fields_ > 1
|
307
314
|
str_ << ".#{value_.release_candidate_minor}"
|
@@ -314,7 +321,7 @@ module Versionomy
|
|
314
321
|
elsif params_[:patchlevel_format] == :alpha_upper
|
315
322
|
str_.concat(64 + value_.patchlevel)
|
316
323
|
else
|
317
|
-
str_ <<
|
324
|
+
str_ << (params_[:patchlevel_separator_unparse] || @patchlevel_separator_unparse)
|
318
325
|
str_ << value_.patchlevel.to_s
|
319
326
|
if value_.patchlevel_minor > 0 || patchlevel_required_fields_ > 1
|
320
327
|
str_ << ".#{value_.patchlevel_minor}"
|
@@ -372,7 +379,7 @@ module Versionomy
|
|
372
379
|
end
|
373
380
|
end
|
374
381
|
end
|
375
|
-
define_format(
|
382
|
+
define_format(StandardFormat.new)
|
376
383
|
end
|
377
384
|
end
|
378
385
|
|
data/lib/versionomy/value.rb
CHANGED
@@ -93,6 +93,20 @@ module Versionomy
|
|
93
93
|
end
|
94
94
|
|
95
95
|
|
96
|
+
# Get the value of the most significant field
|
97
|
+
|
98
|
+
def _toplevel_value # :nodoc:
|
99
|
+
@value
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
# Get a value representing all fields except the most significant field
|
104
|
+
|
105
|
+
def _subvalue # :nodoc:
|
106
|
+
@subvalue
|
107
|
+
end
|
108
|
+
|
109
|
+
|
96
110
|
# Returns a string representation generated by unparsing.
|
97
111
|
# If unparsing fails, does not raise Versionomy::Errors::ParseError,
|
98
112
|
# but instead returns the string generated by +inspect+.
|
@@ -119,6 +133,14 @@ module Versionomy
|
|
119
133
|
end
|
120
134
|
|
121
135
|
|
136
|
+
# Parse another string using the same schema, and same parse parameters
|
137
|
+
# as this value, subject to the given modifications.
|
138
|
+
|
139
|
+
def parse(str_, params_={})
|
140
|
+
@schema.parse(str_, @parse_params.merge(params_))
|
141
|
+
end
|
142
|
+
|
143
|
+
|
122
144
|
# Return the schema defining the form of this version number
|
123
145
|
|
124
146
|
def schema
|
@@ -134,6 +156,7 @@ module Versionomy
|
|
134
156
|
|
135
157
|
|
136
158
|
# Returns an array of recognized field names for this value, in field order.
|
159
|
+
|
137
160
|
def fields
|
138
161
|
@subvalue ? @subvalue.fields.unshift(@schema.name) : [@schema.name]
|
139
162
|
end
|
@@ -169,8 +192,8 @@ module Versionomy
|
|
169
192
|
|
170
193
|
# Returns the value as an array of field values, in field order.
|
171
194
|
|
172
|
-
def
|
173
|
-
@subvalue ? @subvalue.
|
195
|
+
def values
|
196
|
+
@subvalue ? @subvalue.values.unshift(@value) : [@value]
|
174
197
|
end
|
175
198
|
|
176
199
|
|
@@ -215,7 +238,7 @@ module Versionomy
|
|
215
238
|
|
216
239
|
|
217
240
|
def hash # :nodoc:
|
218
|
-
@schema.name.hash ^ @value.hash ^ @subvalue.hash
|
241
|
+
@hash ||= @schema.name.hash ^ @value.hash ^ @subvalue.hash
|
219
242
|
end
|
220
243
|
|
221
244
|
|
@@ -224,11 +247,14 @@ module Versionomy
|
|
224
247
|
# schemas may actually be different.
|
225
248
|
|
226
249
|
def eql?(obj_)
|
250
|
+
if obj_.kind_of?(String)
|
251
|
+
obj_ = parse(obj_) rescue nil
|
252
|
+
end
|
227
253
|
if obj_.kind_of?(Versionomy::Value)
|
228
|
-
if @schema.name != obj_.schema.name || @value != obj_.
|
254
|
+
if @schema.name != obj_.schema.name || @value != obj_._toplevel_value
|
229
255
|
false
|
230
256
|
elsif @subvalue
|
231
|
-
@subvalue.eql?(obj_.
|
257
|
+
@subvalue.eql?(obj_._subvalue)
|
232
258
|
else
|
233
259
|
true
|
234
260
|
end
|
@@ -252,23 +278,26 @@ module Versionomy
|
|
252
278
|
# even if the schemas are different.
|
253
279
|
|
254
280
|
def <=>(obj_)
|
255
|
-
if obj_.kind_of?(
|
256
|
-
|
257
|
-
|
281
|
+
if obj_.kind_of?(String)
|
282
|
+
obj_ = parse(obj_)
|
283
|
+
end
|
284
|
+
if !obj_.kind_of?(Versionomy::Value)
|
285
|
+
raise ArgumentError, "comparison of Versionomy::Value with #{obj_.class} failed"
|
286
|
+
end
|
287
|
+
if @schema.name != obj_.schema.name
|
288
|
+
raise SchemaMismatchError
|
289
|
+
end
|
290
|
+
val_ = @schema.compare_values(@value, obj_._toplevel_value)
|
291
|
+
if val_ == 0
|
292
|
+
if @subvalue.nil? && obj_._subvalue.nil?
|
293
|
+
0
|
294
|
+
elsif !@subvalue.nil? && !obj_._subvalue.nil?
|
295
|
+
@subvalue <=> obj_._subvalue
|
258
296
|
else
|
259
|
-
|
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
|
297
|
+
raise SchemaMismatchError
|
269
298
|
end
|
270
299
|
else
|
271
|
-
|
300
|
+
val_
|
272
301
|
end
|
273
302
|
end
|
274
303
|
|
@@ -291,20 +320,6 @@ module Versionomy
|
|
291
320
|
end
|
292
321
|
|
293
322
|
|
294
|
-
# Get the value of the most significant field
|
295
|
-
|
296
|
-
def toplevel_value
|
297
|
-
@value
|
298
|
-
end
|
299
|
-
|
300
|
-
|
301
|
-
# Get a value representing all fields except the most significant field
|
302
|
-
|
303
|
-
def subvalue
|
304
|
-
@subvalue
|
305
|
-
end
|
306
|
-
|
307
|
-
|
308
323
|
# Field values may be retrieved by calling them as methods.
|
309
324
|
|
310
325
|
def method_missing(symbol_)
|
data/lib/versionomy/version.rb
CHANGED
@@ -101,6 +101,27 @@ module Versionomy
|
|
101
101
|
end
|
102
102
|
|
103
103
|
|
104
|
+
# Test equality with string.
|
105
|
+
|
106
|
+
def test_equality_string
|
107
|
+
value1_ = Versionomy.parse("1.8.7p72")
|
108
|
+
assert_operator(value1_, :==, "1.8.7p72")
|
109
|
+
assert_operator(value1_, :==, "1.8.7.0-72.0")
|
110
|
+
end
|
111
|
+
|
112
|
+
|
113
|
+
# Test comparison with string.
|
114
|
+
|
115
|
+
def test_comparison_string
|
116
|
+
value1_ = Versionomy.parse("1.8.7p72")
|
117
|
+
assert_operator(value1_, :<, "1.8.7p73")
|
118
|
+
assert_operator(value1_, :<, "1.8.8pre1")
|
119
|
+
assert_operator(value1_, :>, "1.8.7p71")
|
120
|
+
assert_operator(value1_, :>, "1.8.7rc2")
|
121
|
+
assert_operator(value1_, :>, "1.8.7.0")
|
122
|
+
end
|
123
|
+
|
124
|
+
|
104
125
|
end
|
105
126
|
|
106
127
|
end
|
data/tests/tc_standard_parse.rb
CHANGED
@@ -139,6 +139,17 @@ module Versionomy
|
|
139
139
|
end
|
140
140
|
|
141
141
|
|
142
|
+
# Test parsing beta alternates
|
143
|
+
|
144
|
+
def test_parsing_beta_alternates
|
145
|
+
assert_equal(Versionomy.parse('2.52.1 beta4'), '2.52.1b4')
|
146
|
+
assert_equal(Versionomy.parse('2.52.1B4'), '2.52.1b4')
|
147
|
+
assert_equal(Versionomy.parse('2.52.1BETA4'), '2.52.1b4')
|
148
|
+
assert_equal(Versionomy.parse('2.52.1 Beta4'), '2.52.1b4')
|
149
|
+
assert_not_equal(Versionomy.parse('2.52.1 eta4'), '2.52.1b4')
|
150
|
+
end
|
151
|
+
|
152
|
+
|
142
153
|
# Test parsing release candidate.
|
143
154
|
|
144
155
|
def test_parsing_release_candidate
|
@@ -156,6 +167,16 @@ module Versionomy
|
|
156
167
|
end
|
157
168
|
|
158
169
|
|
170
|
+
# Test parsing with custom symbols
|
171
|
+
|
172
|
+
def test_parsing_custom_patchlevel_symbols
|
173
|
+
value1_ = Versionomy.parse('2008 SP2', :patchlevel_separator => '\s?(SP|sp)')
|
174
|
+
assert_equal(2, value1_.patchlevel)
|
175
|
+
value2_ = value1_.parse('2008 sp3')
|
176
|
+
assert_equal(3, value2_.patchlevel)
|
177
|
+
end
|
178
|
+
|
179
|
+
|
159
180
|
end
|
160
181
|
|
161
182
|
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.4
|
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-24 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.
|
23
|
+
version: 0.0.4
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: hoe
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.8.
|
33
|
+
version: 1.8.1
|
34
34
|
version:
|
35
35
|
description: Versionomy is a generalized version number library. It provides tools to represent, manipulate, parse, and compare version numbers in the wide variety of versioning schemes in use.
|
36
36
|
email:
|