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 +4 -4
- data/README.markdown +1 -1
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +8 -0
- data/spec/versioncmp_spec.rb +10 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f77ff5a0c7843443a170d17863591648994e8d4e
|
4
|
+
data.tar.gz: 70345fa0e81a99dc9ac2ebb055a8a3ea08704694
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 802d8e6f34de0cd67ef29f176e3c47337c141a9d5945f99bfaf3b69c09307c893f4e52679727240d4dc94628a053a7e825bb1e55430dbfe162e81c2e9eb06b0c
|
7
|
+
data.tar.gz: c1e51ac23f8fcc923b106d4549dc1b505468491d6ac8c64ad0ea343099a457f42a7fe9847ddb6e7e5a96f43bf73b824309575a1ae5b756e6570fee2a00b81e30
|
data/README.markdown
CHANGED
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
|
|
data/spec/versioncmp_spec.rb
CHANGED
@@ -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
|