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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGI4NzU3ZjlhMDA0NjI2MTljODI5ZTFhMDU4MTlhMzU5ZjM2YmZiNQ==
4
+ ZWZlNGQxOTJiYTNmMDcwODY2ZWEwYmIyNDM1M2Y1YjEzYWRiYTgwMQ==
5
5
  data.tar.gz: !binary |-
6
- YTEzYzdlYTRhMGVkNDg2MzU4MWUxN2UwMDExMzQwYTg3OTFkNzI2Mg==
6
+ NTc2YzJjNDA5MjlhZDdmY2RjZTM5NjVkMzIzMjgwMTU0N2Q1ODEzYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Y2E4YzFjYzI0MTIyZmRkY2IyMGM4NjcxYTIyOTVhMjM0NzliM2VjYjc5N2M0
10
- ZjYwMTMyZWU1NmM0ZmM4Mjg3MTI4MGRiZGI5NDY0ZDU2NjgyNjllN2ZiZjA0
11
- MDIyYTZjOWE3YmE4NTYyMGZiN2Q5MjJmMGNmODJhNzc4NmEyZWU=
9
+ ODk0ZjllMDY3MzUyZDUwMWFiODg1NDdkNTc2YjI0N2FjODJlNTg3YTZlMTc4
10
+ NTQ0NmQxZDExYzRmNTA2ZTJjYjRhZjYwYzRmNDk3M2M5ZGJkNTI2ZWEyMmNk
11
+ YWM1OTA5Yzk4MTNhYjRkODYwMDZjMWQ0MzlkMWZkNjVhMDFkOWE=
12
12
  data.tar.gz: !binary |-
13
- ZTFhYWZjNGNjNmUzYmE0MTdmNWIzMjExYmEzM2JlM2U4NGJlMmEwYWU3Nzkz
14
- NzU0MzdjODFkMTc3MGZlODVhMjY4YjU5YTVkNDg5ZDA5ZTNjZmU2NWJlYmVi
15
- ZjU0YTg4ZGJhNTE0ZmRiZjdmNTM3ZmMxY2ZhZWQ3NmNjNjJkYzg=
13
+ MmY4NTYyNWE3MzhmMzgxMmJjMWMyZmRmZTI4MzRhZjVkYWEwYjE3NmM2YzE4
14
+ MmJjNDA1NzFhNjlkYjFkMjNmYzg5ZTJiNmM2ZDVhMTY2YzcxMmQ3YmZlZjFl
15
+ MDgyOTFjZDBiNjM0YjFkNTJjZTk2ODA3MWE3OWQ1NDFhMjdlZjI=
data/README.markdown CHANGED
@@ -74,7 +74,7 @@ because '~>1.1' doesn't fit anymore the newest version.
74
74
 
75
75
  You should add this line to your Gemfile
76
76
 
77
- `gem 'naturalsorter', '2.0.7'`
77
+ `gem 'naturalsorter', '2.0.8'`
78
78
 
79
79
  and run this command in your app root directory
80
80
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "2.0.7"
2
+ VERSION = "2.0.8"
3
3
  end
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 a, b, offsets
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 a, b, offsets
56
- a += ".0" if offsets[0] >= a.length
57
- b += ".0" if offsets[0] >= b.length
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], a
60
- part2 = Versioncmp.get_a_piece_of_the_cake offsets[0], b
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 a, b, part1, part2
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?(part)
157
+ def self.timestamp? part
157
158
  return part.length() == 8 && part.match(/^[0-9]+$/) != nil
158
159
  end
159
160
 
@@ -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.13.0"
25
- end
24
+ s.add_development_dependency "rspec", "2.14.1"
25
+ end
@@ -158,4 +158,8 @@ describe Versioncmp do
158
158
  Versioncmp.compare("2.2.1-b03", "2.2").should eql(1)
159
159
  end
160
160
 
161
+ it "3.0.0 is equal to 3.0" do
162
+ Versioncmp.compare("3.0.0", "3.0").should eql(1)
163
+ end
164
+
161
165
  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: 2.0.7
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.13.0
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.13.0
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.