naturalsorter 3.0.4 → 3.0.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ec3495480af6412be235cedca0e391da3da6920
4
- data.tar.gz: d07b2807cfdc5a9d4b75e68cafab8602e22f55bb
3
+ metadata.gz: e4bcfeb77065843f4df41aebbd0275236fe3ea2b
4
+ data.tar.gz: 2a096d344d38ff5c88c3f061b1a72decef62d009
5
5
  SHA512:
6
- metadata.gz: d97a01a73a68871758784a29ef5471ce3071490cafcd2b44f069bfb1ad048e3db0056fd58d939228ff0a067bddfa4b8d4f26f79d152f4e2e371b6a4f31450c65
7
- data.tar.gz: 3781db9ca46c941bb4048dccad7171e2d83597c17fdbc8bd8e1a3ff92d3a08f7379a6d8cb7767d552edd96092ff17635a47b8fcf8eeb6ff6fc5db696d289c527
6
+ metadata.gz: e9ec94d6f963303ae144b3e71aaaf2ac73938fac5efdba337a0409188e2b7925eff954c5b16eb317fc39c31b7c5442fc4755b7fc6e8369b380db93358b11becc
7
+ data.tar.gz: 468f456b3b7dde55bd4ef1aa9115bc28ad186fb8b5afa8a75584ebe2190258604963574d6597083fe7e02c67f468e9bfd303e8e28a5e3391de018722082b3999
data/README.markdown CHANGED
@@ -26,7 +26,7 @@ Because the default sort method does not recognize the numbers in the string. Th
26
26
 
27
27
  You should add this line to your Gemfile
28
28
 
29
- `gem 'naturalsorter', '3.0.4'`
29
+ `gem 'naturalsorter', '3.0.5'`
30
30
 
31
31
  and run this command in your app root directory
32
32
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "3.0.4"
2
+ VERSION = "3.0.5"
3
3
  end
data/lib/versioncmp.rb CHANGED
@@ -100,9 +100,17 @@ class Versioncmp
100
100
  def self.compare_specia_cases part1, part2
101
101
  result = Versioncmp.check_jquery_versioning(part1, part2)
102
102
  return result if result != nil
103
-
103
+
104
104
  digit = part1 if part1.match(/\d/)
105
105
  return -1 if ( part1.match(/\d/) && part2.match(/#{digit}\S*patch\S*/) )
106
+
107
+ digit = part2 if part2.match(/\d/)
108
+ return 1 if ( part2.match(/\d/) && part1.match(/#{digit}\S*patch\S*/) )
109
+
110
+ if ( part1.match(/#\S*patch\S*/) && part2.match(/\S*patch\S*/) )
111
+ return compare_string(part1, part2)
112
+ end
113
+
106
114
  return 1 if ( part1.eql?("0") && part2.match(/^[a-zA-Z]+/) )
107
115
  return -1 if ( part2.eql?("0") && part1.match(/^[a-zA-Z]+/) )
108
116
  return -1 if ( part1.eql?("0") && part2.match(/^[1-9]+[-_a-zA-Z]+/) )
@@ -29,6 +29,9 @@ describe Naturalsorter::Sorter do
29
29
  it "c400b5a1 is a1b5c400" do
30
30
  Naturalsorter::Sorter.sort_by_method(["a400", "a5", "a1"], "to_s", true).should eql(["a1", "a5", "a400"])
31
31
  end
32
+ it "1.5.2 is lower than 1.5.2-patch" do
33
+ Naturalsorter::Sorter.sort_by_method(["1.5.2-patch", "1.5.2", "1.4.4"], "to_s", true).should eql(["1.4.4", "1.5.2", "1.5.2-patch"])
34
+ end
32
35
  end
33
36
  describe "sort_by_method_desc" do
34
37
  it "a5 a400 a1 is a400 a5 a1" do
@@ -115,6 +118,16 @@ describe Naturalsorter::Sorter do
115
118
  Naturalsorter::Sorter.sort_version(["2.1.0-beta11", "2.1.0-beta9"]).should eql(["2.1.0-beta9", "2.1.0-beta11"])
116
119
  end
117
120
 
121
+ it "1.5.2-patch is bigger than 1.5.2" do
122
+ Naturalsorter::Sorter.sort_version(["1.5.2", "1.4.4", "1.5.2-patch"]).should eql(["1.4.4", "1.5.2", "1.5.2-patch"])
123
+ end
124
+
125
+ end
126
+
127
+ describe "sort_version_by_method" do
128
+ it "1.5.2-patch is bigger than 1.5.2" do
129
+ Naturalsorter::Sorter.sort_version_by_method(["1.5.2", "1.4.4", "1.4.2", "1.5.2-patch2", "1.5.2-patch1"], 'to_s').should eql(["1.4.2", "1.4.4", "1.5.2", "1.5.2-patch1", "1.5.2-patch2"])
130
+ end
118
131
  end
119
132
 
120
133
  describe "is_version_current?" do
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: 3.0.4
4
+ version: 3.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - reiz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-28 00:00:00.000000000 Z
12
+ date: 2015-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec