naturalsorter 3.0.17 → 3.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -1
- data/README.markdown +1 -1
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/version_tag_recognizer.rb +35 -15
- data/lib/versioncmp.rb +8 -1
- data/naturalsorter.gemspec +3 -3
- data/spec/naturalsorter/version_tag_recognizer_spec.rb +28 -0
- data/spec/naturalsorter/versioncmp_spec.rb +16 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 925db38882f2e866dba2a09ec31b09aa5040e09d4859a7960ec53dbb0094167a
|
4
|
+
data.tar.gz: b139ed21d035cbcc6845e7258d827b624980207ffe1782b6684467c09c3eb1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 149a0b39161d753e6152d07a85bbd97341d8a0934dab9a3c6205a74ffc8ea8df441ad910ffcf7b34b4a001d7bd4e9514ded94e365d7eeced281bb50b5244aa9b
|
7
|
+
data.tar.gz: 9014d778f9c6860168e4986ca3091632fbe0d47d73d019fe65c7e9db375fb2bd5cc0ad826526d5e312212f0c068edb780047b7e4e9dd87bf2bea8c758a92280b
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ve-ns
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.8
|
data/README.markdown
CHANGED
@@ -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
|
44
|
+
return 0
|
33
45
|
end
|
34
46
|
|
35
47
|
def self.tagged? value
|
@@ -69,26 +81,34 @@ class VersionTagRecognizer
|
|
69
81
|
val.gsub!(/@.*$/, "") if val.match(/@.*$/)
|
70
82
|
end
|
71
83
|
|
84
|
+
|
72
85
|
def self.does_it_fit_stability?( version_number, stability )
|
73
|
-
patch
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
return true if (stability.casecmp(
|
84
|
-
|
85
|
-
|
86
|
-
return true if (stability.casecmp(
|
86
|
+
patch = self.patch?( version_number )
|
87
|
+
return true if (stability.casecmp( A_STABILITY_PATCH ) == 0) && patch
|
88
|
+
|
89
|
+
stable = self.stable?( version_number )
|
90
|
+
return true if (stability.casecmp( A_STABILITY_STABLE ) == 0) && stable
|
91
|
+
|
92
|
+
pre = stable || self.pre?( version_number )
|
93
|
+
return true if (stability.casecmp( A_STABILITY_PRE ) == 0) && pre
|
94
|
+
|
95
|
+
rc = stable || self.rc?( version_number )
|
96
|
+
return true if (stability.casecmp( A_STABILITY_RC ) == 0) && rc
|
97
|
+
|
98
|
+
beta = rc || self.beta?( version_number )
|
99
|
+
return true if (stability.casecmp( A_STABILITY_BETA ) == 0) && beta
|
100
|
+
|
101
|
+
alpha = beta || self.alpha?( version_number )
|
102
|
+
return true if (stability.casecmp( A_STABILITY_ALPHA ) == 0) && alpha
|
103
|
+
|
104
|
+
snapshot = alpha || self.pre?( version_number ) || self.snapshot?( version_number )
|
87
105
|
return true if (stability.casecmp( A_STABILITY_SNAPSHOT ) == 0) && snapshot
|
88
106
|
return true if (stability.casecmp( A_STABILITY_DEV ) == 0)
|
107
|
+
|
89
108
|
return false
|
90
109
|
end
|
91
110
|
|
111
|
+
|
92
112
|
def self.stability_tag_for( version )
|
93
113
|
if version.match(/@.*$/)
|
94
114
|
spliti = version.split("@")
|
data/lib/versioncmp.rb
CHANGED
@@ -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() ==
|
225
|
+
return part.length() == 9 && part.match(/^[0-9]+$/) != nil
|
226
226
|
end
|
227
227
|
|
228
228
|
|
@@ -234,6 +234,7 @@ class Versioncmp
|
|
234
234
|
replace_99_does_not_exist cleaned_version
|
235
235
|
replace_timestamps cleaned_version
|
236
236
|
replace_groovy cleaned_version
|
237
|
+
replace_redhatx cleaned_version
|
237
238
|
VersionTagRecognizer.remove_minimum_stability cleaned_version
|
238
239
|
cleaned_version
|
239
240
|
end
|
@@ -257,6 +258,12 @@ class Versioncmp
|
|
257
258
|
end
|
258
259
|
end
|
259
260
|
|
261
|
+
def self.replace_redhatx val
|
262
|
+
if val.match(/\-redhat\-[0-9]+$/i)
|
263
|
+
val.gsub!(/\-redhat\-[0-9]+$/i, "")
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
260
267
|
|
261
268
|
# Some glory Java Devs used the timestamp as version string
|
262
269
|
# http://www.versioneye.com/package/commons-beanutils--commons-beanutils
|
data/naturalsorter.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
|
|
22
22
|
# specify any dependencies here; for example:
|
23
23
|
# s.add_development_dependency "rspec"
|
24
24
|
# s.add_runtime_dependency "rest-client"
|
25
|
-
s.add_development_dependency "rspec", "3.
|
26
|
-
s.add_development_dependency "coveralls", "0.8.
|
27
|
-
s.add_development_dependency "simplecov", "0.
|
25
|
+
s.add_development_dependency "rspec", "3.9.0"
|
26
|
+
s.add_development_dependency "coveralls", "0.8.23"
|
27
|
+
s.add_development_dependency "simplecov", "0.16.1"
|
28
28
|
end
|
@@ -297,6 +297,31 @@ describe VersionTagRecognizer do
|
|
297
297
|
end
|
298
298
|
|
299
299
|
|
300
|
+
it "returns the right value for stable" do
|
301
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_STABLE)).to eql(10)
|
302
|
+
end
|
303
|
+
it "returns the right value for patch" do
|
304
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PATCH)).to eql(11)
|
305
|
+
end
|
306
|
+
it "returns the right value for pre" do
|
307
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_PRE)).to eql(6)
|
308
|
+
end
|
309
|
+
it "returns the right value for rc" do
|
310
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_RC)).to eql(5)
|
311
|
+
end
|
312
|
+
it "returns the right value for beta" do
|
313
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_BETA)).to eql(4)
|
314
|
+
end
|
315
|
+
it "returns the right value for alpha" do
|
316
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_ALPHA)).to eql(3)
|
317
|
+
end
|
318
|
+
it "returns the right value for snapshot" do
|
319
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_SNAPSHOT)).to eql(2)
|
320
|
+
end
|
321
|
+
it "returns the right value for dev" do
|
322
|
+
expect( VersionTagRecognizer.value_for_key(VersionTagRecognizer::A_STABILITY_DEV)).to eql(0)
|
323
|
+
end
|
324
|
+
|
300
325
|
|
301
326
|
it "returns compares right for alpha and beta" do
|
302
327
|
expect( VersionTagRecognizer.compare_tags("1.1.1-alpha", "1.1.1-beta")).to eql(-1)
|
@@ -334,6 +359,9 @@ describe VersionTagRecognizer do
|
|
334
359
|
it "does fit stability" do
|
335
360
|
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-BETA", "beta" )).to be_truthy
|
336
361
|
end
|
362
|
+
it "does fit stability" do
|
363
|
+
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.1-alpha", "beta" )).to be_falsey
|
364
|
+
end
|
337
365
|
it "does fit stability" do
|
338
366
|
expect( VersionTagRecognizer.does_it_fit_stability?( "2.2.x-dev", "dev" )).to be_truthy
|
339
367
|
end
|
@@ -23,6 +23,10 @@ describe Versioncmp do
|
|
23
23
|
expect( Versioncmp.compare("0.6-groovy-1.8-rc1", "0.6-groovy-1.8")).to eql(-1)
|
24
24
|
end
|
25
25
|
|
26
|
+
it "smaler" do
|
27
|
+
expect( Versioncmp.compare("0.5.25", "0.5.20170404")).to eql(-1)
|
28
|
+
end
|
29
|
+
|
26
30
|
it "bigger" do
|
27
31
|
expect( Versioncmp.compare("0.6-groovy-1.7", "0.6-groovy-1.7-rc1")).to eql(1)
|
28
32
|
end
|
@@ -79,6 +83,10 @@ describe Versioncmp do
|
|
79
83
|
expect( Versioncmp.compare("2.3", "2.0-beta-1")).to eql(1)
|
80
84
|
end
|
81
85
|
|
86
|
+
it "bigger" do
|
87
|
+
expect( Versioncmp.compare("0.5.20170404", "0.5.25")).to eql(1)
|
88
|
+
end
|
89
|
+
|
82
90
|
it "1.1.1 is bigger than 1.1" do
|
83
91
|
expect( Versioncmp.compare("1.1.1", "1.1")).to eql(1)
|
84
92
|
end
|
@@ -133,6 +141,14 @@ describe Versioncmp do
|
|
133
141
|
expect( Versioncmp.compare("1.0", "1.0.0")).to eql(0)
|
134
142
|
end
|
135
143
|
|
144
|
+
it "equal" do
|
145
|
+
expect( Versioncmp.compare("3.3.1.Final", "3.3.1.Final-redhat-1")).to eql(0)
|
146
|
+
end
|
147
|
+
|
148
|
+
it "equal" do
|
149
|
+
expect( Versioncmp.compare("3.3.1.Final", "3.3.1.Final-RedHat-33")).to eql(0)
|
150
|
+
end
|
151
|
+
|
136
152
|
it "1.0.0 is smaller than 1.0.*" do
|
137
153
|
expect( Versioncmp.compare("1.0.0", "1.0.*")).to eql(-1)
|
138
154
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: naturalsorter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- reiz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -17,42 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 3.
|
20
|
+
version: 3.9.0
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 3.
|
27
|
+
version: 3.9.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: coveralls
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - '='
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.8.
|
34
|
+
version: 0.8.23
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - '='
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.8.
|
41
|
+
version: 0.8.23
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: simplecov
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
46
|
- - '='
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.
|
48
|
+
version: 0.16.1
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
53
|
- - '='
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.16.1
|
56
56
|
description: This GEM is sorting Arrays in a natural order. a2 < a10. Beside that
|
57
57
|
this GEM has some methods to sort version strings. It even recognises alpha, beta,
|
58
58
|
RC, dev and stable versions.
|
@@ -64,6 +64,7 @@ extra_rdoc_files: []
|
|
64
64
|
files:
|
65
65
|
- ".coveralls.yml"
|
66
66
|
- ".gitignore"
|
67
|
+
- ".ruby-gemset"
|
67
68
|
- ".ruby-version"
|
68
69
|
- ".travis.yml"
|
69
70
|
- Gemfile
|
@@ -99,8 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
100
|
- !ruby/object:Gem::Version
|
100
101
|
version: '0'
|
101
102
|
requirements: []
|
102
|
-
|
103
|
-
rubygems_version: 2.4.8
|
103
|
+
rubygems_version: 3.0.8
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Sorting arrays in natural order
|