versionomy 0.4.1 → 0.4.2

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.
@@ -1,15 +1,15 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Versionomy version
4
- #
4
+ #
5
5
  # -----------------------------------------------------------------------------
6
6
  # Copyright 2008-2009 Daniel Azuma
7
- #
7
+ #
8
8
  # All rights reserved.
9
- #
9
+ #
10
10
  # Redistribution and use in source and binary forms, with or without
11
11
  # modification, are permitted provided that the following conditions are met:
12
- #
12
+ #
13
13
  # * Redistributions of source code must retain the above copyright notice,
14
14
  # this list of conditions and the following disclaimer.
15
15
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -18,7 +18,7 @@
18
18
  # * Neither the name of the copyright holder, nor the names of any other
19
19
  # contributors to this software, may be used to endorse or promote products
20
20
  # derived from this software without specific prior written permission.
21
- #
21
+ #
22
22
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23
23
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24
24
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,11 +35,11 @@
35
35
 
36
36
 
37
37
  module Versionomy
38
-
38
+
39
39
  # Current gem version, as a frozen string.
40
40
  VERSION_STRING = ::File.read(::File.dirname(__FILE__)+'/../../Version').strip.freeze
41
-
41
+
42
42
  # Current gem version, as a Versionomy::Value.
43
43
  VERSION = ::Versionomy.parse(VERSION_STRING, :standard)
44
-
44
+
45
45
  end
@@ -1,17 +1,17 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Versionomy parsing tests on standard schema
4
- #
4
+ #
5
5
  # This file contains tests for parsing on the standard schema
6
- #
6
+ #
7
7
  # -----------------------------------------------------------------------------
8
8
  # Copyright 2008-2009 Daniel Azuma
9
- #
9
+ #
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # Redistribution and use in source and binary forms, with or without
13
13
  # modification, are permitted provided that the following conditions are met:
14
- #
14
+ #
15
15
  # * Redistributions of source code must retain the above copyright notice,
16
16
  # this list of conditions and the following disclaimer.
17
17
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -20,7 +20,7 @@
20
20
  # * Neither the name of the copyright holder, nor the names of any other
21
21
  # contributors to this software, may be used to endorse or promote products
22
22
  # derived from this software without specific prior written permission.
23
- #
23
+ #
24
24
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
25
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
26
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,12 +41,12 @@ require 'versionomy'
41
41
 
42
42
  module Versionomy
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestCustomFormat < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
46
+
47
+
48
48
  # Test parsing with custom format for patchlevel
49
-
49
+
50
50
  def test_parsing_custom_patchlevel_format
51
51
  format_ = ::Versionomy.default_format.modified_copy do
52
52
  field(:patchlevel, :requires_previous_field => false) do
@@ -58,9 +58,9 @@ module Versionomy
58
58
  value2_ = value1_.format.parse('2008 sp3')
59
59
  assert_equal(3, value2_.patchlevel)
60
60
  end
61
-
62
-
61
+
62
+
63
63
  end
64
-
64
+
65
65
  end
66
66
  end
@@ -1,17 +1,17 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Versionomy tests of the README examples
4
- #
4
+ #
5
5
  # This file contains tests to ensure the README is valid
6
- #
6
+ #
7
7
  # -----------------------------------------------------------------------------
8
8
  # Copyright 2008-2009 Daniel Azuma
9
- #
9
+ #
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # Redistribution and use in source and binary forms, with or without
13
13
  # modification, are permitted provided that the following conditions are met:
14
- #
14
+ #
15
15
  # * Redistributions of source code must retain the above copyright notice,
16
16
  # this list of conditions and the following disclaimer.
17
17
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -20,7 +20,7 @@
20
20
  # * Neither the name of the copyright holder, nor the names of any other
21
21
  # contributors to this software, may be used to endorse or promote products
22
22
  # derived from this software without specific prior written permission.
23
- #
23
+ #
24
24
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
25
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
26
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,14 +41,14 @@ require 'versionomy'
41
41
 
42
42
  module Versionomy
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestReadmeExamples < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
46
+
47
+
48
48
  # Test the README file.
49
49
  # This actually reads the README file and does some eval magic
50
50
  # to run it and ensure it works the way it claims.
51
-
51
+
52
52
  def test_readme_file
53
53
  binding_ = _get_binding
54
54
  ::File.open("#{::File.dirname(__FILE__)}/../README.rdoc") do |io_|
@@ -56,14 +56,14 @@ module Versionomy
56
56
  buffer_ = ''
57
57
  buffer_start_line_ = nil
58
58
  io_.each_line do |line_|
59
-
59
+
60
60
  # Run code in the "Some examples" section.
61
61
  running_ = false if line_ =~ /^===/
62
62
  running_ = true if line_ =~ /^=== Some examples/
63
63
  next unless running_ && line_[0,1] == ' '
64
64
  # Skip the require line
65
65
  next if line_ =~ /^\s+require/
66
-
66
+
67
67
  # If there isn't an expects clause, then collect the code into
68
68
  # a buffer to run all at once, because it might be code that
69
69
  # gets spread over multiple lines.
@@ -73,7 +73,7 @@ module Versionomy
73
73
  buffer_ << line_
74
74
  next
75
75
  end
76
-
76
+
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
@@ -81,18 +81,18 @@ module Versionomy
81
81
  buffer_ = ''
82
82
  buffer_start_line_ = nil
83
83
  end
84
-
84
+
85
85
  # Parse the line into an expression and an expectation
86
86
  expr_ = line_[0,delim_index_]
87
87
  expect_ = line_[delim_index_+3..-1]
88
-
88
+
89
89
  if expect_ =~ /^=> (.*)$/
90
90
  # Expect a value
91
91
  expect_value_ = ::Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
92
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
98
  expect_error_ = ::Kernel.eval($1, binding_, 'README.rdoc', io_.lineno)
@@ -100,22 +100,22 @@ module Versionomy
100
100
  assert_raise(expect_error_) do
101
101
  ::Kernel.eval(expr_, binding_, 'README.rdoc', io_.lineno)
102
102
  end
103
-
103
+
104
104
  else
105
105
  raise "Unknown expect syntax: #{expect_.inspect}"
106
106
  end
107
-
107
+
108
108
  end
109
109
  end
110
110
  end
111
-
112
-
111
+
112
+
113
113
  def _get_binding
114
114
  binding
115
115
  end
116
-
117
-
116
+
117
+
118
118
  end
119
-
119
+
120
120
  end
121
121
  end
@@ -1,17 +1,17 @@
1
1
  # -----------------------------------------------------------------------------
2
- #
2
+ #
3
3
  # Versionomy basic tests on rubygems schema
4
- #
4
+ #
5
5
  # This file contains tests for the basic use cases on the rubygems schema
6
- #
6
+ #
7
7
  # -----------------------------------------------------------------------------
8
8
  # Copyright 2008-2009 Daniel Azuma
9
- #
9
+ #
10
10
  # All rights reserved.
11
- #
11
+ #
12
12
  # Redistribution and use in source and binary forms, with or without
13
13
  # modification, are permitted provided that the following conditions are met:
14
- #
14
+ #
15
15
  # * Redistributions of source code must retain the above copyright notice,
16
16
  # this list of conditions and the following disclaimer.
17
17
  # * Redistributions in binary form must reproduce the above copyright notice,
@@ -20,7 +20,7 @@
20
20
  # * Neither the name of the copyright holder, nor the names of any other
21
21
  # contributors to this software, may be used to endorse or promote products
22
22
  # derived from this software without specific prior written permission.
23
- #
23
+ #
24
24
  # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25
25
  # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26
26
  # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -41,12 +41,12 @@ require 'versionomy'
41
41
 
42
42
  module Versionomy
43
43
  module Tests # :nodoc:
44
-
44
+
45
45
  class TestRubygemsBasic < ::Test::Unit::TestCase # :nodoc:
46
-
47
-
46
+
47
+
48
48
  # Test the default version value.
49
-
49
+
50
50
  def test_default_value
51
51
  value_ = ::Versionomy.create(nil, :rubygems)
52
52
  assert_equal(1, value_.field0)
@@ -58,10 +58,10 @@ module Versionomy
58
58
  assert_equal(0, value_.field6)
59
59
  assert_equal(0, value_.field7)
60
60
  end
61
-
62
-
61
+
62
+
63
63
  # Test an arbitrary value.
64
-
64
+
65
65
  def test_arbitrary_value
66
66
  value_ = ::Versionomy.create([1, 9, 2, 'pre', 2], :rubygems)
67
67
  assert_equal(1, value_.field0)
@@ -73,27 +73,27 @@ module Versionomy
73
73
  assert_equal(0, value_.field6)
74
74
  assert_equal(0, value_.field7)
75
75
  end
76
-
77
-
76
+
77
+
78
78
  # Test aliases
79
-
79
+
80
80
  def test_alias_fields
81
81
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
82
82
  assert_equal(1, value_.major)
83
83
  assert_equal(9, value_.minor)
84
84
  end
85
-
86
-
85
+
86
+
87
87
  # Test construction using aliases
88
-
88
+
89
89
  def test_alias_field_construction
90
90
  value_ = ::Versionomy.create({:major => 1, :minor => 9, :field2 => 2}, :rubygems)
91
91
  assert_equal([1, 9, 2, 0, 0, 0, 0, 0], value_.values_array)
92
92
  end
93
-
94
-
93
+
94
+
95
95
  # Test comparison of numeric values.
96
-
96
+
97
97
  def test_numeric_comparison
98
98
  value1_ = ::Versionomy.create([1, 9, 2], :rubygems)
99
99
  value2_ = ::Versionomy.create([1, 9], :rubygems)
@@ -102,46 +102,46 @@ module Versionomy
102
102
  value2_ = ::Versionomy.create([1, 9], :rubygems)
103
103
  assert(value2_ == value1_)
104
104
  end
105
-
106
-
105
+
106
+
107
107
  # Test comparison of string values.
108
-
108
+
109
109
  def test_string_comparison
110
110
  value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
111
111
  value2_ = ::Versionomy.create([1, 9, 2, 'b', 1], :rubygems)
112
112
  assert(value2_ > value1_)
113
113
  end
114
-
115
-
114
+
115
+
116
116
  # Test comparison of numeric and string values.
117
-
117
+
118
118
  def test_numeric_and_string_comparison
119
119
  value1_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
120
120
  value2_ = ::Versionomy.create([1, 9, 2, 1], :rubygems)
121
121
  assert(value2_ > value1_)
122
122
  end
123
-
124
-
123
+
124
+
125
125
  # Test parsing numeric.
126
-
126
+
127
127
  def test_parsing_numeric
128
128
  value_ = ::Versionomy.parse('2.0.1.1.4.6', :rubygems)
129
129
  assert_equal([2, 0, 1, 1, 4, 6, 0, 0], value_.values_array)
130
130
  assert_equal('2.0.1.1.4.6', value_.unparse)
131
131
  end
132
-
133
-
132
+
133
+
134
134
  # Test parsing with a string.
135
-
135
+
136
136
  def test_parsing_with_string
137
137
  value_ = ::Versionomy.parse('1.9.2.pre.2', :rubygems)
138
138
  assert_equal([1, 9, 2, 'pre', 2, 0, 0, 0], value_.values_array)
139
139
  assert_equal('1.9.2.pre.2', value_.unparse)
140
140
  end
141
-
142
-
141
+
142
+
143
143
  # Test parsing with trailing zeros.
144
-
144
+
145
145
  def test_parsing_trailing_zeros
146
146
  value_ = ::Versionomy.parse('2.0.0', :rubygems)
147
147
  assert_equal([2, 0, 0, 0, 0, 0, 0, 0], value_.values_array)
@@ -149,56 +149,56 @@ module Versionomy
149
149
  assert_equal('2.0.0.0.0', value_.unparse(:required_fields => [:field4]))
150
150
  assert_equal('2.0', value_.unparse(:optional_fields => [:field2]))
151
151
  end
152
-
153
-
152
+
153
+
154
154
  # Test bumping a numeric field.
155
-
155
+
156
156
  def test_bump_numeric
157
157
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
158
158
  value_ = value_.bump(:field2)
159
159
  assert_equal([1, 9, 3, 0, 0, 0, 0, 0], value_.values_array)
160
160
  end
161
-
162
-
161
+
162
+
163
163
  # Test bumping a string field.
164
-
164
+
165
165
  def test_bump_string
166
166
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
167
167
  value_ = value_.bump(:field3)
168
168
  assert_equal([1, 9, 2, 'b', 0, 0, 0, 0], value_.values_array)
169
169
  end
170
-
171
-
170
+
171
+
172
172
  # Test bumping an alias field.
173
-
173
+
174
174
  def test_bump_alias
175
175
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
176
176
  value_ = value_.bump(:minor)
177
177
  assert_equal([1, 10, 0, 0, 0, 0, 0, 0], value_.values_array)
178
178
  end
179
-
180
-
179
+
180
+
181
181
  # Test changing an alias field.
182
-
182
+
183
183
  def test_change_alias
184
184
  value_ = ::Versionomy.create([1, 8, 7, 'a', 2], :rubygems)
185
185
  value_ = value_.change(:minor => 9)
186
186
  assert_equal([1, 9, 7, 'a', 2, 0, 0, 0], value_.values_array)
187
187
  end
188
-
189
-
188
+
189
+
190
190
  # Test "prerelase?" custom method
191
-
191
+
192
192
  def test_method_prereleasep
193
193
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
194
194
  assert_equal(true, value_.prerelease?)
195
195
  value_ = ::Versionomy.create([1, 9, 2, 2], :rubygems)
196
196
  assert_equal(false, value_.prerelease?)
197
197
  end
198
-
199
-
198
+
199
+
200
200
  # Test "relase" custom method
201
-
201
+
202
202
  def test_method_release
203
203
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
204
204
  value2_ = value_.release
@@ -207,39 +207,39 @@ module Versionomy
207
207
  value2_ = value_.release
208
208
  assert_equal(value_, value2_)
209
209
  end
210
-
211
-
210
+
211
+
212
212
  # Test "parts" custom method
213
-
213
+
214
214
  def test_method_parts
215
215
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
216
216
  assert_equal([1, 9, 2, 'a', 2], value_.parts)
217
217
  value_ = ::Versionomy.create([1, 9, 0], :rubygems)
218
218
  assert_equal([1, 9], value_.parts)
219
219
  end
220
-
221
-
220
+
221
+
222
222
  # Test marshalling
223
-
223
+
224
224
  def test_marshal
225
225
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
226
226
  str_ = ::Marshal.dump(value_)
227
227
  value2_ = ::Marshal.load(str_)
228
228
  assert_equal(value_, value2_)
229
229
  end
230
-
231
-
230
+
231
+
232
232
  # Test YAML
233
-
233
+
234
234
  def test_yaml
235
235
  value_ = ::Versionomy.create([1, 9, 2, 'a', 2], :rubygems)
236
236
  str_ = ::YAML.dump(value_)
237
237
  value2_ = ::YAML.load(str_)
238
238
  assert_equal(value_, value2_)
239
239
  end
240
-
241
-
240
+
241
+
242
242
  end
243
-
243
+
244
244
  end
245
245
  end