lib/bundler/rubygems_integration.rb in bundler-1.9.10 vs lib/bundler/rubygems_integration.rb in bundler-1.10.0.pre

- old
+ new

@@ -129,10 +129,23 @@ def preserve_paths # this is a no-op outside of Rubygems 1.8 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 def ext_lock @@ -202,11 +215,11 @@ def build_gem(gem_dir, spec) build(spec) end def download_gem(spec, uri, path) - uri = Bundler::Source.mirror_for(uri) + uri = Bundler.settings.mirror_for(uri) fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy]) fetcher.download(spec, uri, path) end def security_policy_keys @@ -536,11 +549,11 @@ hash end def download_gem(spec, uri, path) require 'resolv' - uri = Bundler::Source.mirror_for(uri) + uri = Bundler.settings.mirror_for(uri) proxy, dns = configuration[:http_proxy], Resolv::DNS.new fetcher = Gem::RemoteFetcher.new(proxy, dns) fetcher.download(spec, uri, path) end @@ -559,16 +572,24 @@ def repository_subdirectories Gem::REPOSITORY_SUBDIRECTORIES end end + # RubyGems 2.1.0 class MoreFuture < Future def initialize super backport_ext_builder_monitor end + def all_specs + require 'bundler/remote_specification' + Gem::Specification.stubs.map do |stub| + StubSpecification.from_stub(stub) + end + end + def backport_ext_builder_monitor require 'rubygems/ext' Gem::Ext::Builder.class_eval do if !const_defined?(:CHDIR_MONITOR) @@ -584,13 +605,19 @@ def ext_lock Gem::Ext::Builder::CHDIR_MONITOR end - def find_name(name) - Gem::Specification.stubs.find_all do |spec| - spec.name == name - end.map(&:to_spec) + if Gem::Specification.respond_to?(:stubs_for) + def find_name(name) + Gem::Specification.stubs_for(name).map(&:to_spec) + end + else + def find_name(name) + Gem::Specification.stubs.find_all do |spec| + spec.name == name + end.map(&:to_spec) + end end end end