naturalsorter 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -49,7 +49,7 @@ Get newest.
49
49
 
50
50
  You should add this line to your Gemfile
51
51
 
52
- `gem 'naturalsorter', '0.2.1'`
52
+ `gem 'naturalsorter', '0.2.2'`
53
53
 
54
54
  and run this command in your app root directory
55
55
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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 Versioncmp.compareString(big, small);
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)
@@ -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"])
@@ -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.1
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-04 00:00:00.000000000Z
12
+ date: 2012-04-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70304887095540 !ruby/object:Gem::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: *70304887095540
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