naturalsorter 2.0.3 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -76,7 +76,7 @@ because '~>1.1' doesn't fit anymore the newest version.
76
76
 
77
77
  You should add this line to your Gemfile
78
78
 
79
- `gem 'naturalsorter', '2.0.3'`
79
+ `gem 'naturalsorter', '2.0.4'`
80
80
 
81
81
  and run this command in your app root directory
82
82
 
@@ -1,3 +1,3 @@
1
1
  module Naturalsorter
2
- VERSION = "2.0.3"
2
+ VERSION = "2.0.4"
3
3
  end
data/lib/versioncmp.rb CHANGED
@@ -135,6 +135,7 @@ class Versioncmp
135
135
  a = replace_x_dev val
136
136
  replace_leading_v a
137
137
  replace_99_does_not_exist a
138
+ replace_timestamps a
138
139
  VersionTagRecognizer.remove_minimum_stability a
139
140
  a
140
141
  end
@@ -145,6 +146,18 @@ class Versioncmp
145
146
  end
146
147
  end
147
148
 
149
+ # Some glory Java Devs used the timestamp as version string
150
+ # http://www.versioneye.com/package/commons-beanutils--commons-beanutils
151
+ # Ganz grosses Kino
152
+ #
153
+ def self.replace_timestamps val
154
+ if val.match(/^[0-9]{8}$/)
155
+ val.gsub!(/^[0-9]{8}$/, "0.0.0")
156
+ elsif val.match(/^[0-9]{8}.[0-9]{6}$/)
157
+ val.gsub!(/^[0-9]{8}.[0-9]{6}$/, "0.0.0")
158
+ end
159
+ end
160
+
148
161
  def self.replace_x_dev val
149
162
  new_val = String.new(val)
150
163
  if val.eql?("dev-master")
@@ -36,6 +36,10 @@ describe Naturalsorter::Sorter do
36
36
  it "1.1 is 1.1" do
37
37
  Naturalsorter::Sorter.sort_version(["1.1"]).should eql(["1.1"])
38
38
  end
39
+
40
+ it "1.1 is bigger than 20030211.134440" do
41
+ Naturalsorter::Sorter.sort_version(["1.1", "20030211.134440"]).should eql(["20030211.134440", "1.1"])
42
+ end
39
43
 
40
44
  it "1.1, 1.0 is 1.0, 1.1" do
41
45
  Naturalsorter::Sorter.sort_version(["1.1", "1.0"]).should eql(["1.0", "1.1"])
@@ -157,6 +161,12 @@ describe Naturalsorter::Sorter do
157
161
  it "returns true" do
158
162
  Naturalsorter::Sorter.bigger?("1.1", "1.0").should be_true
159
163
  end
164
+ it "returns true" do
165
+ Naturalsorter::Sorter.bigger?("1.1", "20030211.134440").should be_true
166
+ end
167
+ it "returns true" do
168
+ Naturalsorter::Sorter.bigger?("1.1", "20030211").should be_true
169
+ end
160
170
  it "returns true" do
161
171
  Naturalsorter::Sorter.bigger?("2.0", "1.0").should be_true
162
172
  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.3
4
+ version: 2.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: