naturalsorter 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +27 -7
- data/spec/versioncmp_spec.rb +24 -0
- metadata +3 -3
data/lib/versioncmp.rb
CHANGED
@@ -58,14 +58,10 @@ class Versioncmp
|
|
58
58
|
return result if (result != 0)
|
59
59
|
next
|
60
60
|
else
|
61
|
-
|
62
|
-
if
|
63
|
-
return
|
61
|
+
result = Versioncmp.check_jquery_versioning(part1, part2)
|
62
|
+
if result != nil
|
63
|
+
return result
|
64
64
|
end
|
65
|
-
if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
|
66
|
-
return 1
|
67
|
-
end
|
68
|
-
# --- END ---- special case for awesome jquery shitty verison numbers
|
69
65
|
return 1 if (part1.match(/^[0-9]+$/) != nil && part2.match(/^[0-9]+$/) == nil)
|
70
66
|
return -1;
|
71
67
|
end
|
@@ -85,6 +81,30 @@ class Versioncmp
|
|
85
81
|
return -1 if a < b
|
86
82
|
return 1
|
87
83
|
end
|
84
|
+
|
85
|
+
def self.check_jquery_versioning(part1, part2)
|
86
|
+
# --- START ---- special case for awesome jquery shitty verison numbers
|
87
|
+
if ( part1.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part2.match(/^[0-9]+$/) != nil )
|
88
|
+
part1_1 = part1.match(/^[0-9]+/)
|
89
|
+
result = Versioncmp.compareInt(part1_1[0], part2)
|
90
|
+
if result != 0
|
91
|
+
return result
|
92
|
+
end
|
93
|
+
return -1
|
94
|
+
end
|
95
|
+
|
96
|
+
if ( part2.match(/^[0-9]+[a-zA-Z]+[0-9]+$/) != nil && part1.match(/^[0-9]+$/) != nil )
|
97
|
+
part2_1 = part2.match(/^[0-9]+/)
|
98
|
+
result = Versioncmp.compareInt(part2_1[0], part1)
|
99
|
+
if result != 0
|
100
|
+
return result
|
101
|
+
end
|
102
|
+
return 1
|
103
|
+
end
|
104
|
+
|
105
|
+
return nil
|
106
|
+
# --- END ---- special case for awesome jquery shitty verison numbers
|
107
|
+
end
|
88
108
|
|
89
109
|
def self.checkForRC(a, b)
|
90
110
|
big = String.new(a)
|
data/spec/versioncmp_spec.rb
CHANGED
@@ -94,4 +94,28 @@ describe Versioncmp do
|
|
94
94
|
Versioncmp.compare("1.7b2", "1.7").should eql(-1)
|
95
95
|
end
|
96
96
|
|
97
|
+
it "1.7 is bigger than 1.7b2" do
|
98
|
+
Versioncmp.compare("1.7", "1.7b2").should eql(1)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "1.7 is bigger than 1.7rc2" do
|
102
|
+
Versioncmp.compare("1.7", "1.7rc2").should eql(1)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "1.7 is bigger than 1.7RC2" do
|
106
|
+
Versioncmp.compare("1.7", "1.7RC2").should eql(1)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "1.7 is bigger than 1.7a" do
|
110
|
+
Versioncmp.compare("1.7", "1.7a").should eql(1)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "1.7 is bigger than 1.7b" do
|
114
|
+
Versioncmp.compare("1.7", "1.7b").should eql(1)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "1.7b is bigger than 1.7a" do
|
118
|
+
Versioncmp.compare("1.7", "1.7b").should eql(1)
|
119
|
+
end
|
120
|
+
|
97
121
|
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.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-14 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70269390492700 !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: *70269390492700
|
25
25
|
description: This GEM is sorting Arrays in a natural order. a2 < a10
|
26
26
|
email:
|
27
27
|
- robert.reiz@gmx.com
|