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 +1 -1
- data/lib/naturalsorter/version.rb +1 -1
- data/lib/versioncmp.rb +13 -0
- data/spec/naturalsorter_spec.rb +10 -0
- metadata +1 -1
data/README.markdown
CHANGED
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")
|
data/spec/naturalsorter_spec.rb
CHANGED
@@ -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
|