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/dependency.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/dependency.rb')
-rw-r--r-- | lib/bundler/dependency.rb | 84 |
1 files changed, 3 insertions, 81 deletions
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index aa5681fe19..1fb6d8e1d4 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -70,7 +70,9 @@ module Bundler def current_platform? return true if @platforms.empty? - @platforms.any? { |p| send("#{p}?") } + @platforms.any? { |p| + Bundler.current_ruby.send("#{p}?") + } end def to_lock @@ -85,85 +87,5 @@ module Bundler rescue NoMethodError requirement != ">= 0" end - - private - - 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 |