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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99cf7219e287435ad7d1f71da79bd53727a1017e
4
- data.tar.gz: 5d72f5b05da3d87fa50d7e15182421120189e77b
3
+ metadata.gz: 2cb49c41dd12e92691683fc4e40b8f84de78fb98
4
+ data.tar.gz: 3de2f502f7f3e2492a4f98d7fbf8af5bdce2dfeb
5
5
  SHA512:
6
- metadata.gz: 2f1e54e6f62b500f482c98e07ad523f2aabe929f9458b974a224ae876d9e17bf6f6a296282d13032cc2900bed6a624f6730d592f943a8a23197a8fbcee3150b2
7
- data.tar.gz: b59d4a2c2487a80e0cc383e15c623652d4b6b305ec4d2a7363e068c516fcc88e0a99ed702d7ece1dc4552d5ac01fbd5c113d11f109eedaeb0098fed4f1c57375
6
+ metadata.gz: 6f626bf945ab9052d8bbcfa1f6f40ae44414428187ca746a6b1d6d8d1685b563be6a6174f77b0e1f20d968a1be03271ffb22afba2a611aea2dfcae25f5597a82
7
+ data.tar.gz: 6f28c830de880e7d717afac609e2d5d323f2114a8174907bd847ee2a8b0fe27f602de40669f9b4b41e594ea5ef0af02df40208c30615c2c9811998d5b520d353
data/README.markdown CHANGED
@@ -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.14'`
30
+ `gem 'naturalsorter', '3.0.15'`
31
31
 
32
32
  and run this command in your app root directory
33
33
 
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
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.14"
2
+ VERSION = "3.0.15"
3
3
  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.14
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: 2016-06-19 00:00:00.000000000 Z
12
+ date: 2017-01-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec