naturalsorter 0.7.12 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -42,7 +42,7 @@ This here is again for an array with objects. Spezially optimizied for sorting v
42
42
 
43
43
  `Naturalsorter::Sorter.sort_version_by_method(array, method)`
44
44
 
45
- `Naturalsorter::Sorter.sort_version_by_method_desc(array)`
45
+ `Naturalsorter::Sorter.sort_version_by_method_desc(array, method)`
46
46
 
47
47
  Get the newest version from the both given.
48
48
 
@@ -76,7 +76,7 @@ because '~>1.1' doesn't fit anymore the newest version.
76
76
 
77
77
  You should add this line to your Gemfile
78
78
 
79
- `gem 'naturalsorter', '0.7.12'`
79
+ `gem 'naturalsorter', '1.0.0'`
80
80
 
81
81
  and run this command in your app root directory
82
82
 
data/lib/natcmp.rb CHANGED
@@ -30,47 +30,47 @@ class Natcmp
30
30
 
31
31
  # 'Natural order' comparison of two strings
32
32
  def self.natcmp(str1, str2, caseInsensitive=false)
33
- str1, str2 = str1.dup, str2.dup
34
- compareExpression = /^(\D*)(\d*)(.*)$/
33
+ str1, str2 = str1.dup, str2.dup
34
+ compareExpression = /^(\D*)(\d*)(.*)$/
35
35
 
36
- if caseInsensitive
37
- str1.downcase!
38
- str2.downcase!
39
- end
36
+ if caseInsensitive
37
+ str1.downcase!
38
+ str2.downcase!
39
+ end
40
40
 
41
- # Remove all whitespace
42
- str1.gsub!(/\s*/, '')
43
- str2.gsub!(/\s*/, '')
41
+ # Remove all whitespace
42
+ str1.gsub!(/\s*/, '')
43
+ str2.gsub!(/\s*/, '')
44
44
 
45
- while (str1.length > 0) or (str2.length > 0) do
46
- # Extract non-digits, digits and rest of string
47
- str1 =~ compareExpression
48
- chars1, num1, str1 = $1.dup, $2.dup, $3.dup
45
+ while (str1.length > 0) or (str2.length > 0) do
46
+ # Extract non-digits, digits and rest of string
47
+ str1 =~ compareExpression
48
+ chars1, num1, str1 = $1.dup, $2.dup, $3.dup
49
49
 
50
- str2 =~ compareExpression
51
- chars2, num2, str2 = $1.dup, $2.dup, $3.dup
50
+ str2 =~ compareExpression
51
+ chars2, num2, str2 = $1.dup, $2.dup, $3.dup
52
52
 
53
- # Compare the non-digits
54
- case (chars1 <=> chars2)
55
- when 0 # Non-digits are the same, compare the digits...
56
- # If either number begins with a zero, then compare alphabetically,
57
- # otherwise compare numerically
58
- if (num1[0] != 48) and (num2[0] != 48)
59
- num1, num2 = num1.to_i, num2.to_i
60
- end
53
+ # Compare the non-digits
54
+ case (chars1 <=> chars2)
55
+ when 0 # Non-digits are the same, compare the digits...
56
+ # If either number begins with a zero, then compare alphabetically,
57
+ # otherwise compare numerically
58
+ if (num1[0] != 48) and (num2[0] != 48)
59
+ num1, num2 = num1.to_i, num2.to_i
60
+ end
61
61
 
62
- case (num1 <=> num2)
63
- when -1 then return -1
64
- when 1 then return 1
65
- end
66
- when -1 then return -1
67
- when 1 then return 1
68
- end # case
62
+ case (num1 <=> num2)
63
+ when -1 then return -1
64
+ when 1 then return 1
65
+ end
66
+ when -1 then return -1
67
+ when 1 then return 1
68
+ end # case
69
69
 
70
- end # while
70
+ end # while
71
71
 
72
- # Strings are naturally equal
73
- return 0
72
+ # Strings are naturally equal
73
+ return 0
74
74
  end
75
75
 
76
76
  end
data/lib/naturalsorter.rb CHANGED
@@ -156,7 +156,63 @@ module Naturalsorter
156
156
  end
157
157
  true
158
158
  end
159
+
160
+ def self.replace_minimum_stability val
161
+ Sorter.replace_minimum_stability val
162
+ end
159
163
 
160
164
  end
165
+
166
+ class ReleaseRecognizer
167
+
168
+ def self.value_for( value )
169
+ ReleaseRecognizer.value_for value
170
+ end
171
+
172
+ def self.compare_scopes( a, b)
173
+ ReleaseRecognizer.compare_scopes(a, b)
174
+ end
175
+
176
+ def self.scoped? value
177
+ ReleaseRecognizer.scoped? value
178
+ end
179
+
180
+ def self.remove_scope value
181
+ ReleaseRecognizer.remove_scope value
182
+ end
183
+
184
+ def self.stable? value
185
+ ReleaseRecognizer.stable? value
186
+ end
187
+
188
+ def self.alpha? value
189
+ ReleaseRecognizer.alpha? value
190
+ end
191
+
192
+ def self.beta? value
193
+ ReleaseRecognizer.beta? value
194
+ end
195
+
196
+ def self.dev? value
197
+ ReleaseRecognizer.dev? value
198
+ end
199
+
200
+ def self.rc? value
201
+ ReleaseRecognizer.rc? value
202
+ end
203
+
204
+ def self.snapshot? value
205
+ ReleaseRecognizer.snapshot? value
206
+ end
207
+
208
+ def self.pre? value
209
+ ReleaseRecognizer.pre? value
210
+ end
211
+
212
+ def self.jbossorg? value
213
+ ReleaseRecognizer.jbossorg? value
214
+ end
215
+
216
+ end
161
217
 
162
218
  end
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "0.7.12"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -1,16 +1,93 @@
1
1
  class ReleaseRecognizer
2
2
 
3
- def self.release?(value)
3
+ def self.value_for( value )
4
+ return 0 if self.dev? value
5
+ return 2 if self.snapshot? value
6
+ return 3 if self.pre? value
7
+ return 4 if self.alpha? value
8
+ return 5 if self.beta? value
9
+ return 6 if self.rc? value
10
+ return 10 if self.stable? value
11
+ return 1
12
+ end
13
+
14
+ def self.compare_scopes( a, b)
15
+ a_val = self.value_for a
16
+ b_val = self.value_for b
17
+ return -1 if a_val < b_val
18
+ return 1 if a_val > b_val
19
+ return 0
20
+ end
21
+
22
+ def self.scoped? value
23
+ self.alpha?(value) or self.beta?(value) or
24
+ self.dev?(value) or self.rc?(value) or
25
+ self.snapshot?(value) or self.pre?(value) or
26
+ self.jbossorg?(value)
27
+ end
28
+
29
+ def self.remove_scope value
30
+ if self.alpha? value
31
+ new_value = value.gsub(/\.[\w-]*alpha.*$/i, "")
32
+ return new_value.gsub(/\.[\w-]*a.*$/i, "")
33
+ elsif self.beta? value
34
+ new_value = value.gsub(/\.[\w-]*beta.*$/i, "")
35
+ return new_value.gsub(/\.[\w-]*b.*$/i, "")
36
+ elsif self.rc? value
37
+ return value.gsub(/\.[\w-]*rc.*$/i, "")
38
+ elsif self.pre? value
39
+ return value.gsub(/\.[\w-]*pre.*$/i, "")
40
+ elsif self.jbossorg? value
41
+ return value.gsub(/\.jbossorg.*$/i, "")
42
+ elsif self.snapshot? value
43
+ return value.gsub(/\.snapshot.*$/i, "")
44
+ end
45
+ return value
46
+ end
47
+
48
+ def self.release? value
49
+ self.stable? value
50
+ end
51
+
52
+ def self.stable? value
4
53
  if value.match(/.+RELEASE.*/i) or value.match(/.+BUILD.*/i) or
5
54
  value.match(/.+FINAL.*/i) or value.match(/.+SP.*/i) or
6
55
  value.match(/.+GA.*/i)
7
56
  return true
8
57
  end
9
- !value.match(/.*alpha.*/i) and !value.match(/.*beta.*/i) and
10
- !value.match(/.+a.*/i) and !value.match(/.+b.*/i) and
11
- !value.match(/.*dev.*/i) and !value.match(/.*pre.*/i) and
12
- !value.match(/.*rc.*/i) and !value.match(/.+SEC.*/i) and
13
- !value.match(/.+SNAPSHOT.*/i) and !value.match(/.+M.+/i)
58
+ !self.alpha?(value) and !self.beta?(value) and
59
+ !self.dev?(value) and !self.pre?(value) and
60
+ !self.rc?(value) and !value.match(/.+SEC.*/i) and
61
+ !self.snapshot?(value) and !value.match(/.+M.+/i)
62
+ end
63
+
64
+ def self.alpha? value
65
+ return false if self.beta? value
66
+ value.match(/.*alpha.*/i) or value.match(/.+a.*/i)
67
+ end
68
+
69
+ def self.beta? value
70
+ value.match(/.*beta.*/i) or value.match(/.+b.*/i)
71
+ end
72
+
73
+ def self.dev? value
74
+ value.match(/.*dev.*/i)
75
+ end
76
+
77
+ def self.rc? value
78
+ value.match(/.*rc.*/i)
79
+ end
80
+
81
+ def self.snapshot? value
82
+ value.match(/.+SNAPSHOT.*/i)
83
+ end
84
+
85
+ def self.pre? value
86
+ value.match(/.*pre.*$/i)
87
+ end
88
+
89
+ def self.jbossorg? value
90
+ value.match(/.*jbossorg.*$/i)
14
91
  end
15
92
 
16
93
  end
data/lib/versioncmp.rb CHANGED
@@ -26,6 +26,7 @@
26
26
  class Versioncmp
27
27
 
28
28
  # 'Natural version order' comparison of two version strings
29
+ #
29
30
  def self.compare(a_val, b_val)
30
31
 
31
32
  if (!a_val.nil? || a_val.eql?("") ) && b_val.nil?
@@ -40,154 +41,75 @@ class Versioncmp
40
41
  return -1
41
42
  end
42
43
 
43
- a = do_x_dev_replacements a_val
44
- b = do_x_dev_replacements b_val
44
+ a = pre_process a_val
45
+ b = pre_process b_val
45
46
 
46
- replace_leading_v( a )
47
- replace_leading_v( b )
48
-
49
- offset1 = 0;
47
+ offset1 = 0;
50
48
  offset2 = 0;
51
49
 
52
50
  for i in 0..100
53
51
  break if offset1 >= a.length() || offset2 >= b.length()
54
52
 
55
- part1 = Versioncmp.getAPiece(offset1, a);
56
- part2 = Versioncmp.getAPiece(offset2, b);
53
+ part1 = Versioncmp.get_a_piece_of_the_cake(offset1, a);
54
+ part2 = Versioncmp.get_a_piece_of_the_cake(offset2, b);
57
55
 
58
- if Versioncmp.timestamp?(part1) && part2.length() < 8
59
- return -1
60
- end
61
- if Versioncmp.timestamp?(part2) && part1.length() < 8
62
- return 1
63
- end
56
+ return -1 if Versioncmp.timestamp?(part1) && part2.length() < 8
57
+ return 1 if Versioncmp.timestamp?(part2) && part1.length() < 8
64
58
 
65
59
  offset1 += part1.length() + 1;
66
60
  offset2 += part2.length() + 1;
67
61
 
68
- if ( part1.match(/^[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
62
+ if ( part1.match(/^[0-9]+$/) && part2.match(/^[0-9]+$/) )
69
63
  ai = part1.to_i;
70
64
  bi = part2.to_i;
71
- result = Versioncmp.compareInt(ai, bi);
65
+ result = Versioncmp.compare_int(ai, bi);
72
66
  return result if result != 0
73
67
  next
74
- elsif ( part1.match(/^[0-9]+$/) == nil && part2.match(/^[0-9]+$/) == nil )
75
- result = Versioncmp.compareString(part1, part2)
68
+ elsif ( !part1.match(/^[0-9]+$/) && !part2.match(/^[0-9]+$/) )
69
+ result = double_scope_checker(a, b)
70
+ return result if result != 0
71
+ result = Versioncmp.compare_string(part1, part2)
76
72
  return result if (result != 0)
77
73
  next
78
74
  else
79
75
  result = Versioncmp.check_jquery_versioning(part1, part2)
80
- if result != nil
81
- return result
82
- end
83
- return 1 if (part1.match(/^[0-9]+$/) != nil && part2.match(/^[0-9]+$/) == nil)
76
+ return result if result != nil
77
+ return 1 if (part1.match(/^[0-9]+$/) && part2.match(/^[0-9]+$/) == nil)
84
78
  return -1;
85
79
  end
86
- end
87
- result = Versioncmp.checkForRC(a, b)
88
- return result
89
- end
90
-
91
- def self.compareInt(ai, bi)
92
- return -1 if (ai < bi)
93
- return 0 if (ai == bi)
94
- return 1
95
- end
96
-
97
- def self.compareString(a, b)
98
- return 0 if a.eql? b
99
- return -1 if a < b
100
- return 1
101
- end
102
-
103
- def self.check_jquery_versioning(part1, part2)
104
- # --- START ---- special case for awesome jquery shitty verison numbers
105
- if ( part1.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
106
- part1_1 = part1.match(/^[0-9]+/)
107
- result = Versioncmp.compareInt(part1_1[0], part2)
108
- if result != 0
109
- return result
110
- end
111
- return -1
112
- end
113
-
114
- if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
115
- part2_1 = part2.match(/^[0-9]+/)
116
- result = Versioncmp.compareInt(part1, part2_1[0])
117
- if result != 0
118
- return result
119
- end
120
- return 1
121
80
  end
122
-
123
- return nil
124
- # --- END ---- special case for awesome jquery shitty verison numbers
81
+ result = Versioncmp.check_for_scopes(a, b)
82
+ return result
125
83
  end
126
84
 
127
- def self.checkForRC(a, b)
85
+ def self.check_for_scopes(a, b)
128
86
  big = String.new(a)
129
87
  small = String.new(b)
130
88
  if (a.length() < b.length())
131
89
  big = String.new(b)
132
90
  small = String.new(a)
133
91
  end
134
- if (Versioncmp.isRc(big))
135
- bigwithoutRc = big.gsub(/\.rc.*$/i, "")
136
- bigwithoutRc = bigwithoutRc.gsub(/\-rc.*$/i, "")
137
- if (Versioncmp.compareString(bigwithoutRc, small) == 0)
138
- return Versioncmp.getRcValue(a, b)
139
- end
140
- elsif (Versioncmp.isBeta(big))
141
- bigwithoutBeta = big.gsub(/\.beta.*$/i, "")
142
- bigwithoutBeta = bigwithoutBeta.gsub(/\-beta.*$/i, "")
143
- if (Versioncmp.compareString(bigwithoutBeta, small) == 0)
144
- return Versioncmp.getRcValue(a, b)
145
- end
146
- elsif (Versioncmp.isAlpha(big))
147
- bigwithoutAlpha = big.gsub(/\.alpha.*$/i, "")
148
- bigwithoutAlpha = bigwithoutAlpha.gsub(/\-alpha.*$/i, "")
149
- if (Versioncmp.compareString(bigwithoutAlpha, small) == 0)
150
- return Versioncmp.getRcValue(a, b)
151
- end
152
- elsif (Versioncmp.isPre(big))
153
- bigwithoutPre = big.gsub(/\.pre.*$/i, "")
154
- bigwithoutPre = bigwithoutPre.gsub(/\-pre.*$/i, "")
155
- if (Versioncmp.compareString(bigwithoutPre, small) == 0)
156
- return Versioncmp.getRcValue(a, b)
157
- end
158
- elsif (Versioncmp.isJbossorg(big))
159
- bigwithoutRc = big.gsub(/\.jbossorg.*$/i, "")
160
- bigwithoutRc = bigwithoutRc.gsub(/\-jbossorg.*$/i, "")
161
- if (Versioncmp.compareString(bigwithoutRc, small) == 0)
162
- return Versioncmp.getRcValue(a, b)
92
+ if (ReleaseRecognizer.scoped?(big))
93
+ big_without_scope = ReleaseRecognizer.remove_scope big
94
+ if (Versioncmp.compare_string(big_without_scope, small) == 0)
95
+ return Versioncmp.compare_string_length(a, b)
163
96
  end
164
97
  end
165
- return 1 if a.length > b.length
166
- return -1 if a.length < b.length
167
- return 0
168
- end
169
-
170
- def self.isRc(a)
171
- return a.match(/.*rc.*$/i) != nil;
98
+ self.compare_string_length_odd(a, b)
172
99
  end
173
-
174
- def self.isJbossorg(a)
175
- return a.match(/.*jbossorg.*$/i) != nil;
176
- end
177
-
178
- def self.isBeta(a)
179
- return a.match(/.*beta.*$/i) != nil;
180
- end
181
-
182
- def self.isAlpha(a)
183
- return a.match(/.*alpha.*$/i) != nil;
184
- end
185
-
186
- def self.isPre(a)
187
- return a.match(/.*pre.*$/i) != nil;
100
+
101
+ def self.double_scope_checker(a, b)
102
+ if ReleaseRecognizer.scoped?(a) && ReleaseRecognizer.scoped?(b)
103
+ a_without_scope = ReleaseRecognizer.remove_scope a
104
+ b_without_scope = ReleaseRecognizer.remove_scope b
105
+ if a_without_scope.eql? b_without_scope
106
+ return ReleaseRecognizer.compare_scopes(a, b)
107
+ end
108
+ end
109
+ 0
188
110
  end
189
111
 
190
- def self.getAPiece(offset, cake)
112
+ def self.get_a_piece_of_the_cake(offset, cake)
191
113
  for z in 0..100
192
114
  offsetz = offset + z
193
115
  break if offsetz > cake.length()
@@ -203,16 +125,18 @@ class Versioncmp
203
125
  return piece
204
126
  end
205
127
 
206
- def self.getRcValue(a, b)
207
- return 1 if (a.length() < b.length())
208
- return -1
209
- end
210
-
211
128
  def self.timestamp?(part)
212
129
  return part.length() == 8 && part.match(/^[0-9]+$/) != nil
213
130
  end
214
131
 
215
- def self.do_x_dev_replacements val
132
+ def self.pre_process val
133
+ a = replace_x_dev val
134
+ replace_leading_v( a )
135
+ replace_minimum_stability( a )
136
+ a
137
+ end
138
+
139
+ def self.replace_x_dev val
216
140
  new_val = String.new(val)
217
141
  if val.eql?("dev-master")
218
142
  new_val = "9999999"
@@ -230,4 +154,58 @@ class Versioncmp
230
154
  end
231
155
  end
232
156
 
157
+ def self.replace_minimum_stability val
158
+ if val.match(/@.*$/)
159
+ val.gsub!(/@.*$/, "")
160
+ end
161
+ end
162
+
163
+ def self.check_jquery_versioning(part1, part2)
164
+ # --- START ---- special case for awesome jquery shitty verison numbers
165
+ if ( part1.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
166
+ part1_1 = part1.match(/^[0-9]+/)
167
+ result = Versioncmp.compare_int(part1_1[0], part2)
168
+ if result != 0
169
+ return result
170
+ end
171
+ return -1
172
+ end
173
+
174
+ if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
175
+ part2_1 = part2.match(/^[0-9]+/)
176
+ result = Versioncmp.compare_int(part1, part2_1[0])
177
+ if result != 0
178
+ return result
179
+ end
180
+ return 1
181
+ end
182
+
183
+ return nil
184
+ # --- END ---- special case for awesome jquery shitty verison numbers
185
+ end
186
+
187
+ def self.compare_int(ai, bi)
188
+ return -1 if (ai < bi)
189
+ return 0 if (ai == bi)
190
+ return 1
191
+ end
192
+
193
+ def self.compare_string(a, b)
194
+ return 0 if a.eql? b
195
+ return -1 if a < b
196
+ return 1
197
+ end
198
+
199
+ def self.compare_string_length(a, b)
200
+ return 0 if a.length() == b.length()
201
+ return 1 if a.length() < b.length()
202
+ return -1
203
+ end
204
+
205
+ def self.compare_string_length_odd(a, b)
206
+ return 1 if a.length > b.length
207
+ return -1 if a.length < b.length
208
+ return 0
209
+ end
210
+
233
211
  end
@@ -122,4 +122,119 @@ describe ReleaseRecognizer do
122
122
  ReleaseRecognizer.release?("2.0-m4").should be_false
123
123
  end
124
124
 
125
+
126
+
127
+ it "is alpha? is true" do
128
+ ReleaseRecognizer.alpha?("2.0.alpha").should be_true
129
+ end
130
+
131
+ it "is alpha? is true" do
132
+ ReleaseRecognizer.alpha?("2.1.0alpha").should be_true
133
+ end
134
+
135
+ it "is alpha? is false" do
136
+ ReleaseRecognizer.alpha?("2.0.1").should be_false
137
+ end
138
+
139
+ it "is alpha? is false" do
140
+ ReleaseRecognizer.alpha?("2.1.0-BETA1").should be_false
141
+ end
142
+
143
+ it "is scoped? is true" do
144
+ ReleaseRecognizer.scoped?("2.1.0alpha").should be_true
145
+ end
146
+
147
+ it "remove_scope is right" do
148
+ ReleaseRecognizer.remove_scope("2.1.0alpha").should eql("2.1")
149
+ end
150
+
151
+
152
+
153
+ it "is beta? is true" do
154
+ ReleaseRecognizer.beta?("2.0.beta").should be_true
155
+ end
156
+
157
+ it "is beta? is true" do
158
+ ReleaseRecognizer.beta?("2.1.0beta").should be_true
159
+ end
160
+
161
+ it "is beta? is false" do
162
+ ReleaseRecognizer.beta?("2.0.1").should be_false
163
+ end
164
+
165
+ it "is beta? is true" do
166
+ ReleaseRecognizer.beta?("2.2.0-BETA2").should be_true
167
+ end
168
+
169
+ it "is beta? is true" do
170
+ ReleaseRecognizer.beta?("2.1.0-BETA1").should be_true
171
+ end
172
+
173
+ it "is scoped? is true" do
174
+ ReleaseRecognizer.scoped?("2.1.0-BETA1").should be_true
175
+ end
176
+
177
+ it "remove_scope is right" do
178
+ ReleaseRecognizer.remove_scope("2.1.0-BETA1").should eql("2.1")
179
+ end
180
+
181
+
182
+
183
+ it "is dev? is true" do
184
+ ReleaseRecognizer.dev?("dev-master").should be_true
185
+ end
186
+
187
+ it "is dev? is true" do
188
+ ReleaseRecognizer.dev?("dev-progress-helper").should be_true
189
+ end
190
+
191
+ it "is dev? is true" do
192
+ ReleaseRecognizer.dev?("dev-deprecated").should be_true
193
+ end
194
+
195
+ it "is dev? is true" do
196
+ ReleaseRecognizer.dev?("2.2.x-dev").should be_true
197
+ end
198
+
199
+ it "is dev? is false" do
200
+ ReleaseRecognizer.dev?("2.0.1").should be_false
201
+ end
202
+
203
+
204
+
205
+ it "is rc? is true" do
206
+ ReleaseRecognizer.rc?("2.0.rc").should be_true
207
+ end
208
+
209
+ it "is rc? is true" do
210
+ ReleaseRecognizer.rc?("2.1.0rc").should be_true
211
+ end
212
+
213
+ it "is rc? is true" do
214
+ ReleaseRecognizer.rc?("2.2.0-RC3").should be_true
215
+ end
216
+
217
+ it "is rc? is false" do
218
+ ReleaseRecognizer.rc?("2.0.1").should be_false
219
+ end
220
+
221
+
222
+
223
+ it "is snapshot? is true" do
224
+ ReleaseRecognizer.snapshot?("2.0.snapshot").should be_true
225
+ end
226
+
227
+ it "is snapshot? is true" do
228
+ ReleaseRecognizer.snapshot?("2.1.0snapshot").should be_true
229
+ end
230
+
231
+ it "is snapshot? is true" do
232
+ ReleaseRecognizer.snapshot?("2.2.0-snapshot3").should be_true
233
+ end
234
+
235
+ it "is snapshot? is false" do
236
+ ReleaseRecognizer.snapshot?("2.0.1").should be_false
237
+ end
238
+
239
+
125
240
  end
@@ -45,6 +45,10 @@ describe Versioncmp do
45
45
  it "smaller RC" do
46
46
  Versioncmp.compare("1.1.rc1", "1.1").should eql(-1)
47
47
  end
48
+
49
+ it "smaller RC" do
50
+ Versioncmp.compare("1.1.rc1", "2.0").should eql(-1)
51
+ end
48
52
 
49
53
  it "smaller RC" do
50
54
  Versioncmp.compare("1.1-rc1", "1.1").should eql(-1)
@@ -53,6 +57,10 @@ describe Versioncmp do
53
57
  it "smaller alpha" do
54
58
  Versioncmp.compare("1.1-alpha1", "1.1").should eql(-1)
55
59
  end
60
+
61
+ it "alpha is smaller than BETA" do
62
+ Versioncmp.compare("2.1.0alpha", "2.1.0-BETA1").should eql(-1)
63
+ end
56
64
 
57
65
  it "smaller alpha-1" do
58
66
  Versioncmp.compare("1.1-alpha-1", "1.1").should eql(-1)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: naturalsorter
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.12
5
+ version: 1.0.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - reiz
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2013-03-11 00:00:00 Z
14
+ date: 2013-03-13 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rspec