Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

release recognizer

  • Loading branch information...
commit 1522bc7697498cf1e53fe4547faa08fb3dc3c497 1 parent 558c276
@reiz reiz authored
View
2  README.markdown
@@ -76,7 +76,7 @@ because '~>1.1' doesn't fit anymore the newest version.
You should add this line to your Gemfile
-`gem 'naturalsorter', '0.4.7'`
+`gem 'naturalsorter', '0.5.7'`
and run this command in your app root directory
View
1  lib/naturalsorter.rb
@@ -1,6 +1,7 @@
require "naturalsorter/version"
require "natcmp"
require "versioncmp"
+require "release_recognizer"
# naturalsorter.rb
#
View
2  lib/naturalsorter/version.rb
@@ -1,3 +1,3 @@
module Naturalsorter
- VERSION = "0.4.7"
+ VERSION = "0.5.7"
end
View
15 lib/release_recognizer.rb
@@ -0,0 +1,15 @@
+class ReleaseRecognizer
+
+ def self.release?(value)
+ if value.match(/.+RELEASE.*/i) or value.match(/.+BUILD.*/i) or
+ value.match(/.+FINAL.*/i) or value.match(/.+SP.*/i) or
+ value.match(/.+GA.*/i)
+ return true
+ end
+ !value.match(/.*alpha.*/i) and !value.match(/.*beta.*/i) and
+ !value.match(/.+a.*/i) and !value.match(/.+b.*/i) and
+ !value.match(/.*dev.*/i) and !value.match(/.*pre.*/i) and
+ !value.match(/.*rc.*/i) and !value.match(/.+SEC.*/i)
+ end
+
+end
View
109 spec/release_recognizer_spec.rb
@@ -0,0 +1,109 @@
+require "naturalsorter"
+
+describe ReleaseRecognizer do
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("1.1").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("1.0.0").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("1").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.3.2.GA").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("4.1.5.SP1").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.1.0.RELEASE").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.2.0.BUILD").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.2.0buiLd").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.2.0.Final").should be_true
+ end
+
+ it "release? is true" do
+ ReleaseRecognizer.release?("3.2.0FINAL").should be_true
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("1.1.pre").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("2.5.6.SEC03").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("2.3.8.pre1").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("2.3.9.pre").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.beta4").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.BETA4").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.beta").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.rc").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.rc2").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("3.0.0.RC2").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("2.0.x-dev").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("2.0.x-DEV").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("1.8b1").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("1.8B1").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("1.1.3a").should be_false
+ end
+
+ it "release? is false" do
+ ReleaseRecognizer.release?("1.1.3A").should be_false
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.