diff options
author | Vít Ondruch <vondruch@redhat.com> | 2014-12-05 18:17:23 +0100 |
---|---|---|
committer | Vít Ondruch <vondruch@redhat.com> | 2014-12-05 18:17:23 +0100 |
commit | fe0a6e41dc0861f337155056433866a8e6a8f427 (patch) | |
tree | 116849099b738d5f99a4d9293bf8d2aaf8bb5ff2 | |
parent | b951539ed50db8c6b2d6eb1fe73e82070b387fe2 (diff) | |
download | bundler-fe0a6e41dc0861f337155056433866a8e6a8f427.tar.gz |
Use Bundler.rubygems instead of Gem methods directly.
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 13 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 21 |
2 files changed, 19 insertions, 15 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index f139e9d337..a28ece1e77 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -130,6 +130,19 @@ module Bundler yield end + def loaded_gem_paths + # RubyGems 2.2+ can put binary extension into dedicated folders, + # therefore use RubyGems facilities to obtain their load paths. + if Gem::Specification.method_defined? :full_require_paths + loaded_gem_paths = Gem.loaded_specs.map {|n, s| s.full_require_paths} + loaded_gem_paths.flatten! + else + $LOAD_PATH.select do |p| + Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ } + end + end + end + def ui=(obj) Gem::DefaultUserInteraction.ui = obj end diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 0a5b3ea2c8..6c02af9370 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -98,22 +98,13 @@ module Bundler # handle 1.9 where system gems are always on the load path if defined?(::Gem) me = File.expand_path("../../", __FILE__) + me = /^#{Regexp.escape(me)}/ - # RubyGems 2.2+ can put binary extension into dedicated folders, - # therefore use RubyGems facilities to obtain their load paths. - if Gem::Specification.method_defined? :full_require_paths - loaded_gem_paths = Gem.loaded_specs.map do |n, s| - s.full_require_paths.none? {|path| File.expand_path(path) =~ /^#{Regexp.escape(me)}/} ? s.full_require_paths : [] - end - loaded_gem_paths.flatten! - - $LOAD_PATH.reject! {|p| loaded_gem_paths.delete(p) } - else - $LOAD_PATH.reject! do |p| - next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/ - p != File.dirname(__FILE__) && - Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ } - end + loaded_gem_paths = Bundler.rubygems.loaded_gem_paths + + $LOAD_PATH.reject! do |p| + next if File.expand_path(p) =~ me + loaded_gem_paths.delete(p) end $LOAD_PATH.uniq! end |