summaryrefslogtreecommitdiff
path: root/lib/bundler/current_ruby.rb
diff options
context:
space:
mode:
authorHemant Kumar <gethemant@gmail.com>2013-07-18 11:52:24 +0530
committerHemant Kumar <gethemant@gmail.com>2013-07-18 11:54:56 +0530
commitbe64412a04229e778ecec4b6e9acc91430d58bcb (patch)
tree219efb2883ce982b3c6e8609bf36cbdf97bb995c /lib/bundler/current_ruby.rb
parentb65fcc000681bcc102648b885770a9a7a90362ee (diff)
downloadbundler-be64412a04229e778ecec4b6e9acc91430d58bcb.tar.gz
Extract Current Ruby version/platform detection from dependency.rb
That can be reused across several places in bundler and hence extracted that code which is responsible for properly detecting current ruby version.
Diffstat (limited to 'lib/bundler/current_ruby.rb')
-rw-r--r--lib/bundler/current_ruby.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/bundler/current_ruby.rb b/lib/bundler/current_ruby.rb
new file mode 100644
index 0000000000..a08d353947
--- /dev/null
+++ b/lib/bundler/current_ruby.rb
@@ -0,0 +1,81 @@
+module Bundler
+ class CurrentRuby
+ def on_18?
+ RUBY_VERSION =~ /^1\.8/
+ end
+
+ def on_19?
+ RUBY_VERSION =~ /^1\.9/
+ end
+
+ def on_20?
+ RUBY_VERSION =~ /^2\.0/
+ end
+
+ def ruby?
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby" || RUBY_ENGINE == "rbx" || RUBY_ENGINE == "maglev")
+ end
+
+ def ruby_18?
+ ruby? && on_18?
+ end
+
+ def ruby_19?
+ ruby? && on_19?
+ end
+
+ def ruby_20?
+ ruby? && on_20?
+ end
+
+ def mri?
+ !mswin? && (!defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby")
+ end
+
+ def mri_18?
+ mri? && on_18?
+ end
+
+ def mri_19?
+ mri? && on_19?
+ end
+
+
+ def mri_20?
+ mri? && on_20?
+ end
+
+ def rbx?
+ ruby? && defined?(RUBY_ENGINE) && RUBY_ENGINE == "rbx"
+ end
+
+ def jruby?
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
+ end
+
+ def maglev?
+ defined?(RUBY_ENGINE) && RUBY_ENGINE == "maglev"
+ end
+
+ def mswin?
+ Bundler::WINDOWS
+ end
+
+ def mingw?
+ Bundler::WINDOWS && Gem::Platform.local.os == "mingw32"
+ end
+
+ def mingw_18?
+ mingw? && on_18?
+ end
+
+ def mingw_19?
+ mingw? && on_19?
+ end
+
+ def mingw_20?
+ mingw? && on_20?
+ end
+
+ end
+end