naturalsorter 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0057390025a6528368be274f2b63d6bd41e4ec35
4
- data.tar.gz: 55f9fe1879d27e00d685f1f8fd07f47ef35d9ed1
3
+ metadata.gz: 9ec3495480af6412be235cedca0e391da3da6920
4
+ data.tar.gz: d07b2807cfdc5a9d4b75e68cafab8602e22f55bb
5
5
  SHA512:
6
- metadata.gz: dfebbedb80998e35e945bfa1d9b955fe6abfdf11749ac6c20c02616814081d4d4cb309fdd0eb367e6775cfeba1df0a17de757d0ab977c94639dc44b1caa04772
7
- data.tar.gz: e5f31f6da7fdfc773aead02b3b5c5b8864c5ee8b3eea6fc29b33941caba5b8be5088f51ca9f9ea610df4abe654526b212126ba92b0bbc8d324caef54e31689d3
6
+ metadata.gz: d97a01a73a68871758784a29ef5471ce3071490cafcd2b44f069bfb1ad048e3db0056fd58d939228ff0a067bddfa4b8d4f26f79d152f4e2e371b6a4f31450c65
7
+ data.tar.gz: 3781db9ca46c941bb4048dccad7171e2d83597c17fdbc8bd8e1a3ff92d3a08f7379a6d8cb7767d552edd96092ff17635a47b8fcf8eeb6ff6fc5db696d289c527
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.3'`
29
+ `gem 'naturalsorter', '3.0.4'`
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.3"
2
+ VERSION = "3.0.4"
3
3
  end
@@ -32,6 +32,7 @@ class VersionTagRecognizer
32
32
  end
33
33
 
34
34
  def self.tagged? value
35
+ return true if self.patch?(value)
35
36
  return true if self.alpha?(value)
36
37
  return true if self.beta?(value)
37
38
  return true if self.dev?(value)
@@ -43,7 +44,9 @@ class VersionTagRecognizer
43
44
  end
44
45
 
45
46
  def self.remove_tag value
46
- if self.alpha? value
47
+ if self.patch? value
48
+ return value.gsub(/\.patch.*$/i, "")
49
+ elsif self.alpha? value
47
50
  new_value = value.gsub(/\.[\w-]*alpha.*$/i, "")
48
51
  return new_value.gsub(/\.[\w-]*a.*$/i, "")
49
52
  elsif self.beta? value
@@ -66,6 +69,7 @@ class VersionTagRecognizer
66
69
  end
67
70
 
68
71
  def self.does_it_fit_stability?( version_number, stability )
72
+ patch = self.patch?( version_number )
69
73
  stable = self.stable?( version_number )
70
74
  pre = stable || self.pre?( version_number )
71
75
  rc = stable || self.rc?( version_number )
@@ -73,6 +77,7 @@ class VersionTagRecognizer
73
77
  alpha = beta || self.alpha?( version_number )
74
78
  snapshot = alpha || self.pre?( version_number ) || self.snapshot?( version_number )
75
79
 
80
+ return true if (stability.casecmp( A_STABILITY_PATCH ) == 0) && patch
76
81
  return true if (stability.casecmp( A_STABILITY_STABLE ) == 0) && stable
77
82
  return true if (stability.casecmp( A_STABILITY_PRE ) == 0) && pre
78
83
  return true if (stability.casecmp( A_STABILITY_RC ) == 0) && rc
@@ -117,7 +122,7 @@ class VersionTagRecognizer
117
122
  return true if value.match(/.+FINAL.*/i)
118
123
  return true if value.match(/.+SP.*/i)
119
124
  return true if value.match(/.+GA.*/i)
120
- return true if value.match(/.+patch.*/i)
125
+ return true if value.match(/.*patch.*/i)
121
126
 
122
127
  !self.alpha?(value) and !self.beta?(value) and
123
128
  !self.dev?(value) and !self.pre?(value) and
data/lib/versioncmp.rb CHANGED
@@ -100,6 +100,9 @@ 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
+
104
+ digit = part1 if part1.match(/\d/)
105
+ return -1 if ( part1.match(/\d/) && part2.match(/#{digit}\S*patch\S*/) )
103
106
  return 1 if ( part1.eql?("0") && part2.match(/^[a-zA-Z]+/) )
104
107
  return -1 if ( part2.eql?("0") && part1.match(/^[a-zA-Z]+/) )
105
108
  return -1 if ( part1.eql?("0") && part2.match(/^[1-9]+[-_a-zA-Z]+/) )
@@ -12,7 +12,7 @@ describe Naturalsorter::Sorter do
12
12
  it "c400b5a1 is a1b5c400" do
13
13
  Naturalsorter::Sorter.sort(["a400", "a5", "a1"], true).should eql(["a1", "a5", "a400"])
14
14
  end
15
- it "cba is abc" do
15
+ it "1.5.2 is lower than 1.5.2-patch" do
16
16
  Naturalsorter::Sorter.sort(["1.5.2", "1.4.4", "1.5.2-patch"], true).should eql(["1.4.4", "1.5.2", "1.5.2-patch"])
17
17
  end
18
18
  end
@@ -194,4 +194,8 @@ describe Versioncmp do
194
194
  Versioncmp.compare("3.1", "3.2-SNAPSHOT").should eql(-1)
195
195
  end
196
196
 
197
+ it "1.5.2 is smaller than 1.5.2-patch1" do
198
+ Versioncmp.compare("1.5.2", "1.5.2-patch1").should eql(-1)
199
+ end
200
+
197
201
  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: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - reiz