diff options
author | Andre Arko <andre@arko.net> | 2013-08-04 13:19:55 -0700 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2013-08-04 13:23:34 -0700 |
commit | 452f4c44c4138389269c043e514a3298f29abbed (patch) | |
tree | 4cbafd1ff96988e915914b0299d4b7f891d58810 | |
parent | ac3c8ba95db01197db34454114c56e53d8675530 (diff) | |
download | bundler-452f4c44c4138389269c043e514a3298f29abbed.tar.gz |
Add RubygemsIntegration#provides?
-rw-r--r-- | lib/bundler/installer.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index 63890528a8..b82e470114 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -192,7 +192,7 @@ module Bundler private def can_install_parallely? - if Bundler.current_ruby.mri? || Gem::VERSION >= "2.1.0" + if Bundler.current_ruby.mri? || Bundler.rubygems.provides?(">= 2.1.0.rc") true else Bundler.ui.warn "Bundler has detected Rubygems version #{Gem::VERSION} which is " \ diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 68b3d2cf73..bcd36ca4b9 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -6,6 +6,22 @@ require 'rubygems/config_file' module Bundler class RubygemsIntegration + def self.version + @version ||= Gem::Version.new(Gem::VERSION) + end + + def self.provides?(req_str) + Gem::Requirement.new(req_str).satisfied_by?(version) + end + + def version + self.class.version + end + + def provides?(req_str) + self.class.provides?(req_str) + end + def build_args Gem::Command.build_args end @@ -498,15 +514,15 @@ module Bundler end - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.99.99') + if RubygemsIntegration.provides?(">= 1.99.99") @rubygems = RubygemsIntegration::Future.new - elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.5') + elsif RubygemsIntegration.provides?('>= 1.8.5') @rubygems = RubygemsIntegration::Modern.new - elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') + elsif RubygemsIntegration.provides?('>= 1.8.0') @rubygems = RubygemsIntegration::AlmostModern.new - elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.7.0') + elsif RubygemsIntegration.provides?('>= 1.7.0') @rubygems = RubygemsIntegration::Transitional.new - elsif Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.4.0') + elsif RubygemsIntegration.provides?('>= 1.4.0') @rubygems = RubygemsIntegration::Legacy.new else # Rubygems 1.3.6 and 1.3.7 @rubygems = RubygemsIntegration::Ancient.new |