naturalsorter 3.0.23 → 3.0.28

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9290de5341a8ef7b6b9be56c88f1681f809a3c5228a88747c9e2ea45d6c514cc
4
- data.tar.gz: d4d8428298d684556241c1cdd9d9fb55e87214e1f593808abaa7072fb660ae6d
3
+ metadata.gz: 2c3dd53e850c9f543a6720acd9076261217782b794a42bf911cad9e5ffde9b72
4
+ data.tar.gz: 9512924d1830308f8b6c16d272e9c450551efc04b2456dc0aea884216c223089
5
5
  SHA512:
6
- metadata.gz: ea5558167d520a1593f1465f4523cc31d0bda2cf84a0ff0412108d5b15b166e2a71134fda097e16efeb263257d8c95496fb3b7cb756a858797d6fad0b899d56b
7
- data.tar.gz: 4b6347068aac95054d835b9498157c0d68bc71d3ed62790412f977b89c9a9785171c8a463da11888427731e2aeacabf0a2a9f16f016dcf24e687318b138cdcd1
6
+ metadata.gz: 6671128838d34e04e4598030edc12be861902680be0fb952f360fb1e089fe33c0c6cbdaa928ea600f15680bb2fd0254969d0480dc5b560d1f0124d418ce61ddf
7
+ data.tar.gz: 9b38c32f74cc56aff89feda824e3430c24f8ee8e3d3cde08776bf94f208c991fab2ba84763f63b99e489957c4aade6e8f23c4984e9870d62d16b2ad6258e3834
Binary file
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.23"
2
+ VERSION = "3.0.28"
3
3
  end
@@ -78,7 +78,7 @@ class VersionTagRecognizer
78
78
  end
79
79
 
80
80
  def self.remove_minimum_stability val
81
- val.gsub!(/@.*$/, "") if val.match(/@.*$/)
81
+ val.gsub!(/@.*$/, "") if val.to_s.match(/@.*$/)
82
82
  end
83
83
 
84
84
 
@@ -110,11 +110,11 @@ class VersionTagRecognizer
110
110
 
111
111
 
112
112
  def self.stability_tag_for( version )
113
- if version.match(/@.*$/)
113
+ if version.to_s.match(/@.*$/)
114
114
  spliti = version.split("@")
115
115
  return spliti[1]
116
116
  else
117
- return A_STABILITY_DEV if version.match(/\Adev-/i) || version.match(/-dev\z/i)
117
+ return A_STABILITY_DEV if version.to_s.match(/\Adev-/i) || version.to_s.match(/-dev\z/i)
118
118
 
119
119
  if self.stable? version
120
120
  return A_STABILITY_STABLE
@@ -141,61 +141,62 @@ class VersionTagRecognizer
141
141
  end
142
142
 
143
143
  def self.stable? value
144
- return false if value.match(/\Adev-/i) || value.match(/-dev\z/i)
144
+ return true if value.to_s.empty?
145
+ return false if value.to_s.match(/\Adev-/i) || value.to_s.match(/-dev\z/i)
145
146
  return false if self.preview?( value )
146
147
 
147
- return true if value.match(/.+RELEASE.*/i)
148
- return true if value.match(/.+FINAL.*/i)
149
- return true if value.match(/.+SP.*/i)
150
- return true if value.match(/.+GA.*/i)
151
- return true if value.match(/.*patch.*/i)
148
+ return true if value.to_s.match(/.+RELEASE.*/i)
149
+ return true if value.to_s.match(/.+FINAL.*/i)
150
+ return true if value.to_s.match(/.+SP.*/i)
151
+ return true if value.to_s.match(/.+GA.*/i)
152
+ return true if value.to_s.match(/.*patch.*/i)
152
153
 
153
154
  !self.alpha?(value) and !self.beta?(value) and
154
155
  !self.dev?(value) and !self.pre?(value) and
155
- !self.rc?(value) and !value.match(/.+SEC.*/i) and
156
- !self.snapshot?(value) and !value.match(/.+M.+/i) and
156
+ !self.rc?(value) and !value.to_s.match(/.+SEC.*/i) and
157
+ !self.snapshot?(value) and !value.to_s.match(/.+M.+/i) and
157
158
  !self.build?(value)
158
159
  end
159
160
 
160
161
  def self.patch? value
161
- value.match(/.*patch.*/i)
162
+ value.to_s.match(/.*patch.*/i)
162
163
  end
163
164
 
164
165
  def self.alpha? value
165
166
  return false if self.beta? value
166
- value.match(/.*alpha.*/i) or value.match(/.+a.*/i)
167
+ value.to_s.match(/.*alpha.*/i) or value.to_s.match(/.+a.*/i)
167
168
  end
168
169
 
169
170
  def self.beta? value
170
- value.match(/.*beta.*/i) or value.match(/.+b.*/i)
171
+ value.to_s.match(/.*beta.*/i) or value.to_s.match(/.+b.*/i)
171
172
  end
172
173
 
173
174
  def self.dev? value
174
- value.match(/.*dev.*/i)
175
+ value.to_s.match(/.*dev.*/i)
175
176
  end
176
177
 
177
178
  def self.rc? value
178
- value.match(/.*rc.*/i) || value.match(/.*cr.*/i)
179
+ value.to_s.match(/.*rc.*/i) || value.to_s.match(/.*cr.*/i)
179
180
  end
180
181
 
181
182
  def self.snapshot? value
182
- value.match(/.+SNAPSHOT.*/i)
183
+ value.to_s.match(/.+SNAPSHOT.*/i)
183
184
  end
184
185
 
185
186
  def self.build? value
186
- value.match(/.+build.*/i)
187
+ value.to_s.match(/.+build.*/i)
187
188
  end
188
189
 
189
190
  def self.pre? value
190
- value.match(/.*pre.*$/i)
191
+ value.to_s.match(/.*pre.*$/i) || value.to_s.match(/.*insiders.*$/i)
191
192
  end
192
193
 
193
194
  def self.jbossorg? value
194
- value.match(/.*jbossorg.*$/i)
195
+ value.to_s.match(/.*jbossorg.*$/i)
195
196
  end
196
197
 
197
198
  def self.preview? value
198
- value.match(/-preview\d+-/i) || value.match(/-preview-/i)
199
+ value.to_s.match(/-preview\d+-/i) || value.to_s.match(/-preview-/i)
199
200
  end
200
201
 
201
202
  end
@@ -33,34 +33,34 @@ class Versioncmp
33
33
  b_empty = b_val.to_s.empty?
34
34
 
35
35
  return 0 if a_empty && b_empty
36
- return 0 if a_val.eql?( b_val )
36
+ return 0 if a_val.to_s.eql?( b_val.to_s )
37
37
  return 1 if (a_empty == false) && (b_empty == true )
38
38
  return -1 if (b_empty == false) && (a_empty == true )
39
39
 
40
- return 1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}-SNAPSHOT/i)
41
- return -1 if a_val.length > b_val.length && a_val.match(/\A#{a_val}-SNAPSHOT/i)
40
+ return 1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}-SNAPSHOT/i)
41
+ return -1 if a_val.length > b_val.length && a_val.to_s.match(/\A#{a_val}-SNAPSHOT/i)
42
42
 
43
- return 1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}-BETA.*/i)
44
- return -1 if a_val.length > b_val.length && a_val.match(/\A#{a_val}-BETA.*/i)
43
+ return 1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}-BETA.*/i)
44
+ return -1 if a_val.length > b_val.length && a_val.to_s.match(/\A#{a_val}-BETA.*/i)
45
45
 
46
- return 1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}-alpha.*/i)
47
- return -1 if a_val.length > b_val.length && a_val.match(/\A#{a_val}-alpha.*/i)
46
+ return 1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}-alpha.*/i)
47
+ return -1 if a_val.length > b_val.length && a_val.to_s.match(/\A#{a_val}-alpha.*/i)
48
48
 
49
- return 1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}-rc.*/i)
50
- return -1 if a_val.length > b_val.length && a_val.match(/\A#{a_val}-rc.*/i)
49
+ return 1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}-rc.*/i)
50
+ return -1 if a_val.length > b_val.length && a_val.to_s.match(/\A#{a_val}-rc.*/i)
51
51
 
52
- return -1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}u\d/i)
53
- return 1 if a_val.length > b_val.length && a_val.match(/\A#{b_val}u\d/i)
52
+ return -1 if b_val.length > a_val.length && b_val.to_s.match(/\A#{a_val}u\d/i)
53
+ return 1 if a_val.length > b_val.length && a_val.to_s.match(/\A#{b_val}u\d/i)
54
54
 
55
55
  a = pre_process a_val
56
56
  b = pre_process b_val
57
57
 
58
- am = a.match(/\A(\d+\.\d+)\.\d+\z/i)
59
- bm = b.match(/\A(\d+\.\d+)-\w+\z/i)
58
+ am = a.to_s.match(/\A(\d+\.\d+)\.\d+\z/i)
59
+ bm = b.to_s.match(/\A(\d+\.\d+)-\w+\z/i)
60
60
  return 1 if am && bm && am[1].eql?(bm[1])
61
61
 
62
- am = a.match(/\A(\d+\.\d+)-\w+\z/i)
63
- bm = b.match(/\A(\d+\.\d+)\.\d+\z/i)
62
+ am = a.to_s.match(/\A(\d+\.\d+)-\w+\z/i)
63
+ bm = b.to_s.match(/\A(\d+\.\d+)\.\d+\z/i)
64
64
  return -1 if am && bm && am[1].eql?(bm[1])
65
65
 
66
66
  ab = [a, b]
@@ -95,9 +95,9 @@ class Versioncmp
95
95
  offsets[0] += part1.length() + 1;
96
96
  offsets[1] += part2.length() + 1;
97
97
 
98
- if ( part1.match(/^[0-9]+$/) && part2.match(/^[0-9]+$/) )
98
+ if ( part1.to_s.match(/^[0-9]+$/) && part2.to_s.match(/^[0-9]+$/) )
99
99
  return self.compare_numbers part1, part2
100
- elsif ( !part1.match(/^[0-9]+$/) && !part2.match(/^[0-9]+$/) )
100
+ elsif ( !part1.to_s.match(/^[0-9]+$/) && !part2.to_s.match(/^[0-9]+$/) )
101
101
  return self.compare_strings ab[0], ab[1], part1, part2
102
102
  else
103
103
  return self.compare_special_cases part1, part2
@@ -127,33 +127,33 @@ class Versioncmp
127
127
  result = Versioncmp.check_jquery_versioning(part1, part2)
128
128
  return result if !result.to_s.strip.empty?
129
129
 
130
- digit = part1 if part1.match(/\d/)
131
- return -1 if ( part1.match(/\d/) && part2.match(/#{digit}\S*patch\S*/) )
130
+ digit = part1 if part1.to_s.match(/\d/)
131
+ return -1 if ( part1.to_s.match(/\d/) && part2.to_s.match(/#{digit}\S*patch\S*/) )
132
132
 
133
- digit = part2 if part2.match(/\d/)
134
- return 1 if ( part2.match(/\d/) && part1.match(/#{digit}\S*patch\S*/) )
133
+ digit = part2 if part2.to_s.match(/\d/)
134
+ return 1 if ( part2.to_s.match(/\d/) && part1.to_s.match(/#{digit}\S*patch\S*/) )
135
135
 
136
- if ( part1.match(/#\S*patch\S*/) && part2.match(/\S*patch\S*/) )
136
+ if ( part1.to_s.match(/#\S*patch\S*/) && part2.to_s.match(/\S*patch\S*/) )
137
137
  return compare_string(part1, part2)
138
138
  end
139
139
 
140
- return 1 if ( part1.eql?("0") && part2.match(/^[a-zA-Z]+/) )
141
- return -1 if ( part2.eql?("0") && part1.match(/^[a-zA-Z]+/) )
142
- return -1 if ( part1.eql?("0") && part2.match(/^[1-9]+[-_a-zA-Z]+/) )
143
- return 1 if ( part2.eql?("0") && part1.match(/^[1-9]+[-_a-zA-Z]+/) )
140
+ return 1 if ( part1.eql?("0") && part2.to_s.match(/^[a-zA-Z]+/) )
141
+ return -1 if ( part2.eql?("0") && part1.to_s.match(/^[a-zA-Z]+/) )
142
+ return -1 if ( part1.eql?("0") && part2.to_s.match(/^[1-9]+[-_a-zA-Z]+/) )
143
+ return 1 if ( part2.eql?("0") && part1.to_s.match(/^[1-9]+[-_a-zA-Z]+/) )
144
144
 
145
- pm1 = part1.match(/\A[0-9]+\z/)
146
- pm2 = part2.match(/\A(\d+)(\w+)\z/i)
145
+ pm1 = part1.to_s.match(/\A[0-9]+\z/)
146
+ pm2 = part2.to_s.match(/\A(\d+)(\w+)\z/i)
147
147
  return 1 if ( pm1 && pm2 && pm2[1].eql?(part1) && VersionTagRecognizer.stable?(pm2[2]) )
148
148
  return -1 if ( pm1 && pm2 && pm2[1].eql?(part1) && !VersionTagRecognizer.stable?(pm2[2]) )
149
149
 
150
- pm1 = part1.match(/\A(\d+)-(\w+)\z/i)
151
- pm2 = part2.match(/\A\d+\z/i)
150
+ pm1 = part1.to_s.match(/\A(\d+)-(\w+)\z/i)
151
+ pm2 = part2.to_s.match(/\A\d+\z/i)
152
152
  return 1 if try_to_i_bigger( pm1, pm2, part2 )
153
153
  return 1 if pm2 && pm1 && pm1[1].eql?(part2) && VersionTagRecognizer.stable?(pm1[2])
154
154
 
155
- pm1 = part1.match(/\A\d+\z/i)
156
- pm2 = part2.match(/\A(\d+)-(\w+)\z/i)
155
+ pm1 = part1.to_s.match(/\A\d+\z/i)
156
+ pm2 = part2.to_s.match(/\A(\d+)-(\w+)\z/i)
157
157
  return 1 if try_to_i_bigger( pm1, pm2, part2 )
158
158
  return -1 if pm1 && pm2 && pm2[1].eql?(part1) && VersionTagRecognizer.stable?(pm2[2])
159
159
 
@@ -211,7 +211,7 @@ class Versioncmp
211
211
  break if offsetz > cake.length()
212
212
 
213
213
  p = cake[ offset..offset + z ]
214
- break if ( p.match(/^\w+\.$/) != nil )
214
+ break if ( p.to_s.match(/^\w+\.$/) != nil )
215
215
  end
216
216
 
217
217
  z = z - 1 if z > 0
@@ -222,7 +222,7 @@ class Versioncmp
222
222
 
223
223
  def self.timestamp? part
224
224
  return false if part.to_s.empty?
225
- return part.length() == 9 && part.match(/^[0-9]+$/) != nil
225
+ return part.length() == 9 && part.to_s.match(/^[0-9]+$/) != nil
226
226
  end
227
227
 
228
228
 
@@ -247,19 +247,19 @@ class Versioncmp
247
247
  end
248
248
 
249
249
  def self.replace_groovy val
250
- if val.match(/\-groovy\-/)
250
+ if val.to_s.match(/\-groovy\-/)
251
251
  val.gsub!("-groovy-", ".")
252
252
  end
253
253
  end
254
254
 
255
255
  def self.replace_snapshot val
256
- if val.match(/\-SNAPSHOT/)
256
+ if val.to_s.match(/\-SNAPSHOT/)
257
257
  val.gsub!("-SNAPSHOT", "")
258
258
  end
259
259
  end
260
260
 
261
261
  def self.replace_redhatx val
262
- if val.match(/\-redhat\-[0-9]+$/i)
262
+ if val.to_s.match(/\-redhat\-[0-9]+$/i)
263
263
  val.gsub!(/\-redhat\-[0-9]+$/i, "")
264
264
  end
265
265
  end
@@ -270,9 +270,9 @@ class Versioncmp
270
270
  # Ganz grosses Kino !
271
271
  #
272
272
  def self.replace_timestamps val
273
- if val.match(/^[0-9]{8}$/)
273
+ if val.to_s.match(/^[0-9]{8}$/)
274
274
  val.gsub!(/^[0-9]{8}$/, "0.0.0")
275
- elsif val.match(/^[0-9]{8}.[0-9]{6}$/)
275
+ elsif val.to_s.match(/^[0-9]{8}.[0-9]{6}$/)
276
276
  val.gsub!(/^[0-9]{8}.[0-9]{6}$/, "0.0.0")
277
277
  end
278
278
  end
@@ -280,7 +280,7 @@ class Versioncmp
280
280
 
281
281
  def self.replace_wildcards val
282
282
  new_val = String.new(val)
283
- new_val = "9999999" if val.match(/\.\*$/)
283
+ new_val = "9999999" if val.to_s.match(/\.\*$/)
284
284
  new_val
285
285
  end
286
286
 
@@ -291,11 +291,11 @@ class Versioncmp
291
291
  new_val = "99999999999"
292
292
  elsif val.eql?("dev-develop")
293
293
  new_val = "9999999999"
294
- elsif val.match(/\Adev-/i)
294
+ elsif val.to_s.match(/\Adev-/i)
295
295
  new_val = "9999999"
296
- elsif val.match(/\.x-dev$/i)
296
+ elsif val.to_s.match(/\.x-dev$/i)
297
297
  new_val = val.gsub("x-dev", "9999999")
298
- elsif val.match(/-dev$/)
298
+ elsif val.to_s.match(/-dev$/)
299
299
  new_val = val.gsub("-dev", ".9999999")
300
300
  end
301
301
  new_val
@@ -303,7 +303,7 @@ class Versioncmp
303
303
 
304
304
 
305
305
  def self.replace_leading_v val
306
- val.gsub!(/^v/, "") if val.match(/^v[0-9]+/)
306
+ val.gsub!(/^v/, "") if val.to_s.match(/^v[0-9]+/)
307
307
  end
308
308
 
309
309
 
@@ -315,7 +315,7 @@ class Versioncmp
315
315
 
316
316
  def self.check_jquery_versioning(part1, part2)
317
317
  # --- START ---- special case for awesome jquery shitty verison numbers
318
- if ( part1.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
318
+ if ( part1.to_s.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.to_s.match(/^[0-9]+$/) != nil )
319
319
  part1_1 = part1.match(/^[0-9]+/)
320
320
  result = Versioncmp.compare_int(part1_1[0], part2)
321
321
  if result != 0
@@ -324,8 +324,8 @@ class Versioncmp
324
324
  return -1
325
325
  end
326
326
 
327
- if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
328
- part2_1 = part2.match(/^[0-9]+/)
327
+ if ( part2.to_s.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.to_s.match(/^[0-9]+$/) != nil )
328
+ part2_1 = part2.to_s.match(/^[0-9]+/)
329
329
  result = Versioncmp.compare_int(part1, part2_1[0])
330
330
  if result != 0
331
331
  return result
@@ -3,6 +3,11 @@ require "naturalsorter"
3
3
 
4
4
  describe VersionTagRecognizer do
5
5
 
6
+ it "release? is true for nil" do
7
+ # if nill we assume the latest stable version.
8
+ expect( VersionTagRecognizer.release?(nil)).to be_truthy
9
+ end
10
+
6
11
  it "release? is true" do
7
12
  expect( VersionTagRecognizer.release?("1.1")).to be_truthy
8
13
  end
@@ -344,6 +349,9 @@ describe VersionTagRecognizer do
344
349
  it "does fit stability" do
345
350
  expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1", "stable" )).to be_truthy
346
351
  end
352
+ it "does not fit stability" do
353
+ expect( VersionTagRecognizer.does_it_fit_stability?( "3.9.2-insiders.20200509", "stable" )).to be_falsey
354
+ end
347
355
  it "does not fit stability" do
348
356
  expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-BETA", "stable" )).to be_falsey
349
357
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naturalsorter
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.23
4
+ version: 3.0.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - reiz
8
8
  - versioneye
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-06-25 00:00:00.000000000 Z
12
+ date: 2020-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -71,6 +71,7 @@ files:
71
71
  - LICENSE
72
72
  - README.markdown
73
73
  - Rakefile
74
+ - lib/.DS_Store
74
75
  - lib/natcmp.rb
75
76
  - lib/naturalsorter.rb
76
77
  - lib/naturalsorter/version.rb
@@ -85,7 +86,7 @@ homepage: https://github.com/versioneye/naturalsorter
85
86
  licenses:
86
87
  - MIT
87
88
  metadata: {}
88
- post_install_message:
89
+ post_install_message:
89
90
  rdoc_options: []
90
91
  require_paths:
91
92
  - lib
@@ -101,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
102
  version: '0'
102
103
  requirements: []
103
104
  rubygems_version: 3.0.8
104
- signing_key:
105
+ signing_key:
105
106
  specification_version: 4
106
107
  summary: Sorting arrays in natural order
107
108
  test_files: