diff options
| author | Hemant Kumar <gethemant@gmail.com> | 2013-07-18 11:52:24 +0530 |
|---|---|---|
| committer | Hemant Kumar <gethemant@gmail.com> | 2013-07-18 11:54:56 +0530 |
| commit | be64412a04229e778ecec4b6e9acc91430d58bcb (patch) | |
| tree | 219efb2883ce982b3c6e8609bf36cbdf97bb995c /lib/bundler/current_ruby.rb | |
| parent | b65fcc000681bcc102648b885770a9a7a90362ee (diff) | |
| download | bundler-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.rb | 81 |
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 |
