naturalsorter 3.0.9 → 3.0.10

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: 26c550b34ce0dc4469c49e3e961b1b1c73821ddf
4
- data.tar.gz: 941b2e7359ecedbe4d701eb29b9b5ecbd05164c2
3
+ metadata.gz: f77ff5a0c7843443a170d17863591648994e8d4e
4
+ data.tar.gz: 70345fa0e81a99dc9ac2ebb055a8a3ea08704694
5
5
  SHA512:
6
- metadata.gz: 3def80a792398c9db5da56d468bd9558f861cb720143aee5441188a305e3eda19879a412e5e3ee995950e558826fe1effcb6f5835fee1ce321c6eee0e4dd633a
7
- data.tar.gz: ede6284471e7032e9930d59243a3d3b304f8a323d2eb0a9e9f04613c7e469cf5b5f8b9c658a6bddff6881ecb3d18d38d523f4c6e3d21905b63dbaef7789bf759
6
+ metadata.gz: 802d8e6f34de0cd67ef29f176e3c47337c141a9d5945f99bfaf3b69c09307c893f4e52679727240d4dc94628a053a7e825bb1e55430dbfe162e81c2e9eb06b0c
7
+ data.tar.gz: c1e51ac23f8fcc923b106d4549dc1b505468491d6ac8c64ad0ea343099a457f42a7fe9847ddb6e7e5a96f43bf73b824309575a1ae5b756e6570fee2a00b81e30
data/README.markdown CHANGED
@@ -26,7 +26,7 @@ Because the default sort method does not recognize the numbers in the string. Th
26
26
 
27
27
  You should add this line to your Gemfile
28
28
 
29
- `gem 'naturalsorter', '3.0.8'`
29
+ `gem 'naturalsorter', '3.0.10'`
30
30
 
31
31
  and run this command in your app root directory
32
32
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.9"
2
+ VERSION = "3.0.10"
3
3
  end
data/lib/versioncmp.rb CHANGED
@@ -40,6 +40,14 @@ class Versioncmp
40
40
  a = pre_process a_val
41
41
  b = pre_process b_val
42
42
 
43
+ am = a.match(/\A(\d+\.\d+)\.\d+\z/i)
44
+ bm = b.match(/\A(\d+\.\d+)-\w+\z/i)
45
+ return 1 if am && bm && am[1].eql?(bm[1])
46
+
47
+ am = a.match(/\A(\d+\.\d+)-\w+\z/i)
48
+ bm = b.match(/\A(\d+\.\d+)\.\d+\z/i)
49
+ return -1 if am && bm && am[1].eql?(bm[1])
50
+
43
51
  ab = [a, b]
44
52
  offsets = [0, 0]
45
53
 
@@ -54,6 +54,16 @@ describe Versioncmp do
54
54
  Versioncmp.compare("2.3.d-b01", "2.3.1").should eql(-1)
55
55
  end
56
56
 
57
+
58
+ it "2.18.1 is bigger than 2.18-20141019" do
59
+ Versioncmp.compare("2.18.1", "2.18-20141019").should eql(1)
60
+ end
61
+
62
+ it "2.18-20141019 is smaller than 2.18.1" do
63
+ Versioncmp.compare("2.18-20141019", "2.18.1").should eql(-1)
64
+ end
65
+
66
+
57
67
  it "1.1 is smaller than 1.1.1" do
58
68
  Versioncmp.compare("1.1", "1.1.1").should eql(-1)
59
69
  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.9
4
+ version: 3.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - reiz