naturalsorter 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -1
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +4 -3
- data/spec/naturalsorter_spec.rb +4 -0
- data/spec/versioncmp_spec.rb +8 -0
- metadata +4 -4
data/README.markdown
CHANGED
data/lib/versioncmp.rb
CHANGED
@@ -35,8 +35,7 @@ class Versioncmp
|
|
35
35
|
break if offset1 >= a.length() || offset2 >= b.length()
|
36
36
|
|
37
37
|
part1 = Versioncmp.getAPiece(offset1, a);
|
38
|
-
part2 = Versioncmp.getAPiece(offset2, b);
|
39
|
-
|
38
|
+
part2 = Versioncmp.getAPiece(offset2, b);
|
40
39
|
|
41
40
|
offset1 += part1.length() + 1;
|
42
41
|
offset2 += part2.length() + 1;
|
@@ -95,7 +94,9 @@ class Versioncmp
|
|
95
94
|
return Versioncmp.getRcValue(a, b)
|
96
95
|
end
|
97
96
|
end
|
98
|
-
return
|
97
|
+
return 1 if a.length > b.length
|
98
|
+
return -1 if a.length < b.length
|
99
|
+
return 0
|
99
100
|
end
|
100
101
|
|
101
102
|
def self.isRc(a)
|
data/spec/naturalsorter_spec.rb
CHANGED
@@ -60,6 +60,10 @@ describe Naturalsorter::Sorter do
|
|
60
60
|
it "1.2, 1.1 is 1.1, 1.2" do
|
61
61
|
Naturalsorter::Sorter.sort_version_desc(["0.4", "0.1", "1.1", "1.2", "1.0", "1.0.RC1"]).should eql(["1.2", "1.1", "1.0", "1.0.RC1", "0.4", "0.1"])
|
62
62
|
end
|
63
|
+
|
64
|
+
it "1.2, 1.1 is 1.1, 1.2" do
|
65
|
+
Naturalsorter::Sorter.sort_version_desc(["0.4", "0.1", "1.1", "1.1.1", "1.2", "1.2.1", "1.0", "1.0.RC1"]).should eql(["1.2.1", "1.2", "1.1.1", "1.1", "1.0", "1.0.RC1", "0.4", "0.1"])
|
66
|
+
end
|
63
67
|
|
64
68
|
it "1.2, 1.1 is 1.1, 1.2" do
|
65
69
|
Naturalsorter::Sorter.sort_version(["1.1", "1.2", "1.0"]).should eql(["1.0", "1.1", "1.2"])
|
data/spec/versioncmp_spec.rb
CHANGED
@@ -10,6 +10,14 @@ describe Versioncmp do
|
|
10
10
|
Versioncmp.compare("1.1", "1.0").should eql(1)
|
11
11
|
end
|
12
12
|
|
13
|
+
it "1.1.1 is bigger than 1.1" do
|
14
|
+
Versioncmp.compare("1.1.1", "1.1").should eql(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "1.1 is smaller than 1.1.1" do
|
18
|
+
Versioncmp.compare("1.1", "1.1.1").should eql(-1)
|
19
|
+
end
|
20
|
+
|
13
21
|
it "equal" do
|
14
22
|
Versioncmp.compare("1.1", "1.1").should eql(0)
|
15
23
|
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: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-06 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70101287446020 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70101287446020
|
25
25
|
description: This GEM is sorting Arrays in a natural order. a2 < a10
|
26
26
|
email:
|
27
27
|
- robert.reiz@gmx.com
|