naturalsorter 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +1 -1
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +9 -8
- data/naturalsorter.gemspec +2 -2
- data/spec/versioncmp_spec.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZWZlNGQxOTJiYTNmMDcwODY2ZWEwYmIyNDM1M2Y1YjEzYWRiYTgwMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NTc2YzJjNDA5MjlhZDdmY2RjZTM5NjVkMzIzMjgwMTU0N2Q1ODEzYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODk0ZjllMDY3MzUyZDUwMWFiODg1NDdkNTc2YjI0N2FjODJlNTg3YTZlMTc4
|
10
|
+
NTQ0NmQxZDExYzRmNTA2ZTJjYjRhZjYwYzRmNDk3M2M5ZGJkNTI2ZWEyMmNk
|
11
|
+
YWM1OTA5Yzk4MTNhYjRkODYwMDZjMWQ0MzlkMWZkNjVhMDFkOWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MmY4NTYyNWE3MzhmMzgxMmJjMWMyZmRmZTI4MzRhZjVkYWEwYjE3NmM2YzE4
|
14
|
+
MmJjNDA1NzFhNjlkYjFkMjNmYzg5ZTJiNmM2ZDVhMTY2YzcxMmQ3YmZlZjFl
|
15
|
+
MDgyOTFjZDBiNjM0YjFkNTJjZTk2ODA3MWE3OWQ1NDFhMjdlZjI=
|
data/README.markdown
CHANGED
data/lib/versioncmp.rb
CHANGED
@@ -40,10 +40,11 @@ class Versioncmp
|
|
40
40
|
a = pre_process a_val
|
41
41
|
b = pre_process b_val
|
42
42
|
|
43
|
+
ab = [a, b]
|
43
44
|
offsets = [0, 0]
|
44
45
|
|
45
46
|
for i in 0..20
|
46
|
-
result = self.check_the_slice
|
47
|
+
result = self.check_the_slice ab, offsets
|
47
48
|
next if result.nil?
|
48
49
|
return result if result == 1 || result == -1
|
49
50
|
end
|
@@ -52,12 +53,12 @@ class Versioncmp
|
|
52
53
|
end
|
53
54
|
|
54
55
|
|
55
|
-
def self.check_the_slice
|
56
|
-
|
57
|
-
|
56
|
+
def self.check_the_slice ab, offsets
|
57
|
+
ab[0] += ".0" if offsets[0] >= ab[0].length
|
58
|
+
ab[1] += ".0" if offsets[0] >= ab[1].length
|
58
59
|
|
59
|
-
part1 = Versioncmp.get_a_piece_of_the_cake offsets[0],
|
60
|
-
part2 = Versioncmp.get_a_piece_of_the_cake offsets[0],
|
60
|
+
part1 = Versioncmp.get_a_piece_of_the_cake offsets[0], ab[0]
|
61
|
+
part2 = Versioncmp.get_a_piece_of_the_cake offsets[0], ab[1]
|
61
62
|
|
62
63
|
return -1 if Versioncmp.timestamp?(part1) && part2.length() < 8
|
63
64
|
return 1 if Versioncmp.timestamp?(part2) && part1.length() < 8
|
@@ -68,7 +69,7 @@ class Versioncmp
|
|
68
69
|
if ( part1.match(/^[0-9]+$/) && part2.match(/^[0-9]+$/) )
|
69
70
|
return self.compare_numbers part1, part2
|
70
71
|
elsif ( !part1.match(/^[0-9]+$/) && !part2.match(/^[0-9]+$/) )
|
71
|
-
return self.compare_strings
|
72
|
+
return self.compare_strings ab[0], ab[1], part1, part2
|
72
73
|
else
|
73
74
|
return self.compare_specia_cases part1, part2
|
74
75
|
end
|
@@ -153,7 +154,7 @@ class Versioncmp
|
|
153
154
|
end
|
154
155
|
|
155
156
|
|
156
|
-
def self.timestamp?
|
157
|
+
def self.timestamp? part
|
157
158
|
return part.length() == 8 && part.match(/^[0-9]+$/) != nil
|
158
159
|
end
|
159
160
|
|
data/naturalsorter.gemspec
CHANGED
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
|
|
21
21
|
# specify any dependencies here; for example:
|
22
22
|
# s.add_development_dependency "rspec"
|
23
23
|
# s.add_runtime_dependency "rest-client"
|
24
|
-
s.add_development_dependency "rspec", "2.
|
25
|
-
end
|
24
|
+
s.add_development_dependency "rspec", "2.14.1"
|
25
|
+
end
|
data/spec/versioncmp_spec.rb
CHANGED
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: 2.0.
|
4
|
+
version: 2.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- reiz
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.
|
20
|
+
version: 2.14.1
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.
|
27
|
+
version: 2.14.1
|
28
28
|
description: This GEM is sorting Arrays in a natural order. a2 < a10. Beside that
|
29
29
|
this GEM has some methods to sort version strings. It even recognises alpha, beta,
|
30
30
|
RC, dev and stable versions.
|