naturalsorter 3.0.14 → 3.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +1 -1
- data/lib/naturalsorter.rb +1 -0
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +3 -0
- data/spec/naturalsorter/naturalsorter_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cb49c41dd12e92691683fc4e40b8f84de78fb98
|
4
|
+
data.tar.gz: 3de2f502f7f3e2492a4f98d7fbf8af5bdce2dfeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f626bf945ab9052d8bbcfa1f6f40ae44414428187ca746a6b1d6d8d1685b563be6a6174f77b0e1f20d968a1be03271ffb22afba2a611aea2dfcae25f5597a82
|
7
|
+
data.tar.gz: 6f28c830de880e7d717afac609e2d5d323f2114a8174907bd847ee2a8b0fe27f602de40669f9b4b41e594ea5ef0af02df40208c30615c2c9811998d5b520d353
|
data/README.markdown
CHANGED
data/lib/naturalsorter.rb
CHANGED
@@ -45,6 +45,7 @@ module Naturalsorter
|
|
45
45
|
|
46
46
|
def self.sort_version(array, asc = true)
|
47
47
|
return array if (array.nil? || array.empty? || array.length == 1)
|
48
|
+
return array if (array[0].nil? || array[1].nil?)
|
48
49
|
return array.sort { |a,b| Versioncmp.compare( a, b ) } if asc
|
49
50
|
return array.sort { |a,b| Versioncmp.compare( b, a ) }
|
50
51
|
end
|
data/lib/versioncmp.rb
CHANGED
@@ -49,6 +49,9 @@ class Versioncmp
|
|
49
49
|
return 1 if b_val.length > a_val.length && b_val.match(/\A#{a_val}-rc.*/i)
|
50
50
|
return -1 if a_val.length > b_val.length && a_val.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)
|
54
|
+
|
52
55
|
a = pre_process a_val
|
53
56
|
b = pre_process b_val
|
54
57
|
|
@@ -123,6 +123,10 @@ describe Naturalsorter::Sorter do
|
|
123
123
|
expect( Naturalsorter::Sorter.sort_version(["1.5.2", "1.4.4", "1.5.2-patch"])).to eql(["1.4.4", "1.5.2", "1.5.2-patch"])
|
124
124
|
end
|
125
125
|
|
126
|
+
it "3.0.1u2 is bigger than 3.0.1" do
|
127
|
+
expect( Naturalsorter::Sorter.sort_version(["3.0.1u2", "3.0.1"])).to eql(["3.0.1", "3.0.1u2"])
|
128
|
+
end
|
129
|
+
|
126
130
|
end
|
127
131
|
|
128
132
|
describe "sort_version_by_method" do
|
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.15
|
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: 2017-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|