Permalink
Browse files

improvement

  • Loading branch information...
1 parent 9d1a5bd commit 13341b0a6f92571c91f129d7b660fb4c0ab7ef48 reiz committed Apr 6, 2012
Showing with 23 additions and 11 deletions.
  1. +1 −1 README.markdown
  2. +1 −1 lib/naturalsorter/version.rb
  3. +9 −9 lib/versioncmp.rb
  4. +12 −0 spec/versioncmp_spec.rb
View
@@ -49,7 +49,7 @@ Get newest.
You should add this line to your Gemfile
-`gem 'naturalsorter', '0.3.0'`
+`gem 'naturalsorter', '0.3.1'`
and run this command in your app root directory
@@ -1,3 +1,3 @@
module Naturalsorter
- VERSION = "0.3.0"
+ VERSION = "0.3.1"
end
View
@@ -92,20 +92,20 @@ def self.checkForRC(a, b)
return Versioncmp.getRcValue(a, b)
end
elsif (Versioncmp.isBeta(big))
- bigwithoutBeta = big.gsub(/\.beta[1-9]*$/i, "")
- bigwithoutBeta = bigwithoutBeta.gsub(/\-beta[1-9]*$/i, "")
+ bigwithoutBeta = big.gsub(/\.beta.*$/i, "")
+ bigwithoutBeta = bigwithoutBeta.gsub(/\-beta.*$/i, "")
if (Versioncmp.compareString(bigwithoutBeta, small) == 0)
return Versioncmp.getRcValue(a, b)
end
elsif (Versioncmp.isAlpha(big))
- bigwithoutAlpha = big.gsub(/\.alpha[1-9]*$/i, "")
- bigwithoutAlpha = bigwithoutAlpha.gsub(/\-alpha[1-9]*$/i, "")
+ bigwithoutAlpha = big.gsub(/\.alpha.*$/i, "")
+ bigwithoutAlpha = bigwithoutAlpha.gsub(/\-alpha.*$/i, "")
if (Versioncmp.compareString(bigwithoutAlpha, small) == 0)
return Versioncmp.getRcValue(a, b)
end
elsif (Versioncmp.isPre(big))
- bigwithoutPre = big.gsub(/\.pre[1-9]*$/i, "")
- bigwithoutPre = bigwithoutPre.gsub(/\-pre[1-9]*$/i, "")
+ bigwithoutPre = big.gsub(/\.pre.*$/i, "")
+ bigwithoutPre = bigwithoutPre.gsub(/\-pre.*$/i, "")
if (Versioncmp.compareString(bigwithoutPre, small) == 0)
return Versioncmp.getRcValue(a, b)
end
@@ -130,15 +130,15 @@ def self.isJbossorg(a)
end
def self.isBeta(a)
- return a.match(/.*beta[1-9]*$/i) != nil;
+ return a.match(/.*beta.*$/i) != nil;
end
def self.isAlpha(a)
- return a.match(/.*alpha[1-9]*$/i) != nil;
+ return a.match(/.*alpha.*$/i) != nil;
end
def self.isPre(a)
- return a.match(/.*pre[1-9]*$/i) != nil;
+ return a.match(/.*pre.*$/i) != nil;
end
def self.getAPiece(offset, cake)
@@ -42,10 +42,22 @@
Versioncmp.compare("1.1-alpha1", "1.1").should eql(-1)
end
+ it "smaller alpha-1" do
+ Versioncmp.compare("1.1-alpha-1", "1.1").should eql(-1)
+ end
+
+ it "smaller alpha" do
+ Versioncmp.compare("1.1", "1.1-alpha-1").should eql(1)
+ end
+
it "smaller beta" do
Versioncmp.compare("3.1-beta1", "3.1").should eql(-1)
end
+ it "smaller beta" do
+ Versioncmp.compare("3.1-beta-1", "3.1").should eql(-1)
+ end
+
it "smaller 3.0-rc4-negotiate" do
Versioncmp.compare("3.0-rc4-negotiate", "3.0").should eql(-1)
end

0 comments on commit 13341b0

Please sign in to comment.