naturalsorter 3.0.20 → 3.0.25

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: 882f355aed3f92457ee271ed1b6e8d411362356533559153f4f0bb8ca223ae57
4
- data.tar.gz: 7fb4a30607b686aa832f9c4b3ff39da32962aa0cdc995c75e66b97a7d07ad06a
3
+ metadata.gz: 64f9e0f448ccaad8213ca33662905db43571a2056828a249921d155345757708
4
+ data.tar.gz: '0086cc8790c43e94cae90191898d0aca9ead6210923f2c1522df103ef6bee4e0'
5
5
  SHA512:
6
- metadata.gz: 8d667855051e443833abecc71b4f40292584c58a81f07e53196448380d138dedc468a23d6f2c987fd2061458f9acf7cca4a869c12cc137abe57f52d42e28dc75
7
- data.tar.gz: 8822a77b8a5797f9d0819da08aafbd7aa407f54b2daef5f5010227fc4e7b8770ff60a9e289a2dfe8af75cf7bebd67a0197327b4fb4fb1b55e932103353fdb814
6
+ metadata.gz: 41a05b255453f5ea3a4cef24375af6c03a6799a006629b1f18615371c7ab6366c352d0dce639daef65812a293e01ad1a583db5096fc1a1ff0c97f670d490bebc
7
+ data.tar.gz: 16f45ea622801d0b38c11138d2b4987eba44260991524593d472cbe72c42335054f5c60b6050d2d21e7493611f3683a58915e8a4f5cb434d1cc4082fb544c94f
@@ -27,7 +27,7 @@ Because the default sort method does not recognize the numbers in the string. Th
27
27
 
28
28
  You should add this line to your Gemfile
29
29
 
30
- `gem 'naturalsorter', '3.0.19'`
30
+ `gem 'naturalsorter', '3.0.22'`
31
31
 
32
32
  and run this command in your app root directory
33
33
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.20"
2
+ VERSION = "3.0.25"
3
3
  end
@@ -24,12 +24,24 @@ class VersionTagRecognizer
24
24
  return 1
25
25
  end
26
26
 
27
+ def self.value_for_key( value )
28
+ return 0 if A_STABILITY_DEV.eql? value
29
+ return 2 if A_STABILITY_SNAPSHOT.eql? value
30
+ return 3 if A_STABILITY_ALPHA.eql? value
31
+ return 4 if A_STABILITY_BETA.eql? value
32
+ return 5 if A_STABILITY_RC.eql? value
33
+ return 6 if A_STABILITY_PRE.eql? value
34
+ return 10 if A_STABILITY_STABLE.eql? value
35
+ return 11 if A_STABILITY_PATCH.eql? value
36
+ return 1
37
+ end
38
+
27
39
  def self.compare_tags( a, b)
28
40
  a_val = self.value_for a
29
41
  b_val = self.value_for b
30
42
  return -1 if a_val < b_val
31
43
  return 1 if a_val > b_val
32
- return 0
44
+ return 0
33
45
  end
34
46
 
35
47
  def self.tagged? value
@@ -98,11 +110,11 @@ class VersionTagRecognizer
98
110
 
99
111
 
100
112
  def self.stability_tag_for( version )
101
- if version.match(/@.*$/)
113
+ if version.to_s.match(/@.*$/)
102
114
  spliti = version.split("@")
103
115
  return spliti[1]
104
116
  else
105
- 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)
106
118
 
107
119
  if self.stable? version
108
120
  return A_STABILITY_STABLE
@@ -129,6 +141,7 @@ class VersionTagRecognizer
129
141
  end
130
142
 
131
143
  def self.stable? value
144
+ return true if value.to_s.empty?
132
145
  return false if value.match(/\Adev-/i) || value.match(/-dev\z/i)
133
146
  return false if self.preview?( value )
134
147
 
@@ -146,44 +159,44 @@ class VersionTagRecognizer
146
159
  end
147
160
 
148
161
  def self.patch? value
149
- value.match(/.*patch.*/i)
162
+ value.to_s.match(/.*patch.*/i)
150
163
  end
151
164
 
152
165
  def self.alpha? value
153
166
  return false if self.beta? value
154
- value.match(/.*alpha.*/i) or value.match(/.+a.*/i)
167
+ value.to_s.match(/.*alpha.*/i) or value.to_s.match(/.+a.*/i)
155
168
  end
156
169
 
157
170
  def self.beta? value
158
- value.match(/.*beta.*/i) or value.match(/.+b.*/i)
171
+ value.to_s.match(/.*beta.*/i) or value.to_s.match(/.+b.*/i)
159
172
  end
160
173
 
161
174
  def self.dev? value
162
- value.match(/.*dev.*/i)
175
+ value.to_s.match(/.*dev.*/i)
163
176
  end
164
177
 
165
178
  def self.rc? value
166
- value.match(/.*rc.*/i) || value.match(/.*cr.*/i)
179
+ value.to_s.match(/.*rc.*/i) || value.to_s.match(/.*cr.*/i)
167
180
  end
168
181
 
169
182
  def self.snapshot? value
170
- value.match(/.+SNAPSHOT.*/i)
183
+ value.to_s.match(/.+SNAPSHOT.*/i)
171
184
  end
172
185
 
173
186
  def self.build? value
174
- value.match(/.+build.*/i)
187
+ value.to_s.match(/.+build.*/i)
175
188
  end
176
189
 
177
190
  def self.pre? value
178
- value.match(/.*pre.*$/i)
191
+ value.to_s.match(/.*pre.*$/i)
179
192
  end
180
193
 
181
194
  def self.jbossorg? value
182
- value.match(/.*jbossorg.*$/i)
195
+ value.to_s.match(/.*jbossorg.*$/i)
183
196
  end
184
197
 
185
198
  def self.preview? value
186
- value.match(/-preview\d+-/i) || value.match(/-preview-/i)
199
+ value.to_s.match(/-preview\d+-/i) || value.to_s.match(/-preview-/i)
187
200
  end
188
201
 
189
202
  end
@@ -287,7 +287,7 @@ class Versioncmp
287
287
 
288
288
  def self.replace_x_dev val
289
289
  new_val = String.new(val)
290
- if val.eql?("dev-master")
290
+ if ['dev-master', 'master', 'trunk'].include?( val )
291
291
  new_val = "99999999999"
292
292
  elsif val.eql?("dev-develop")
293
293
  new_val = "9999999999"
@@ -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
@@ -297,6 +302,31 @@ describe VersionTagRecognizer do
297
302
  end
298
303
 
299
304
 
305
+ it "returns the right value for stable" do
306
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_STABLE)).to eql(10)
307
+ end
308
+ it "returns the right value for patch" do
309
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PATCH)).to eql(11)
310
+ end
311
+ it "returns the right value for pre" do
312
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PRE)).to eql(6)
313
+ end
314
+ it "returns the right value for rc" do
315
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_RC)).to eql(5)
316
+ end
317
+ it "returns the right value for beta" do
318
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_BETA)).to eql(4)
319
+ end
320
+ it "returns the right value for alpha" do
321
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_ALPHA)).to eql(3)
322
+ end
323
+ it "returns the right value for snapshot" do
324
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_SNAPSHOT)).to eql(2)
325
+ end
326
+ it "returns the right value for dev" do
327
+ expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_DEV)).to eql(0)
328
+ end
329
+
300
330
 
301
331
  it "returns compares right for alpha and beta" do
302
332
  expect( VersionTagRecognizer.compare_tags("1.1.1-alpha", "1.1.1-beta")).to eql(-1)
@@ -334,6 +364,9 @@ describe VersionTagRecognizer do
334
364
  it "does fit stability" do
335
365
  expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-BETA", "beta" )).to be_truthy
336
366
  end
367
+ it "does fit stability" do
368
+ expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-alpha", "beta" )).to be_falsey
369
+ end
337
370
  it "does fit stability" do
338
371
  expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.x-dev", "dev" )).to be_truthy
339
372
  end
@@ -95,6 +95,14 @@ describe Versioncmp do
95
95
  expect( Versioncmp.compare("dev-master", "10.10.999")).to eql(1)
96
96
  end
97
97
 
98
+ it "master is bigger than 10.10.999" do
99
+ expect( Versioncmp.compare("master", "10.10.999")).to eql(1)
100
+ end
101
+
102
+ it "trunk is bigger than 10.10.999" do
103
+ expect( Versioncmp.compare("trunk", "10.10.999")).to eql(1)
104
+ end
105
+
98
106
  it "2.2.x-dev is bigger than 2.2.1" do
99
107
  expect( Versioncmp.compare("2.2.x-dev", "2.2.1")).to eql(1)
100
108
  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.20
4
+ version: 3.0.25
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-11 00:00:00.000000000 Z
12
+ date: 2020-07-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -85,7 +85,7 @@ homepage: https://github.com/versioneye/naturalsorter
85
85
  licenses:
86
86
  - MIT
87
87
  metadata: {}
88
- post_install_message:
88
+ post_install_message:
89
89
  rdoc_options: []
90
90
  require_paths:
91
91
  - lib
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  requirements: []
103
103
  rubygems_version: 3.0.8
104
- signing_key:
104
+ signing_key:
105
105
  specification_version: 4
106
106
  summary: Sorting arrays in natural order
107
107
  test_files: