diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-01 23:29:38 +0000 |
commit | be7b5929126cb3e696ef222339237faba9b8fe5a (patch) | |
tree | 51eae376f93c09bc82dde5a657a91df2c89062e4 /lib/bundler/rubygems_integration.rb | |
parent | ae49dbd392083f69026f2a0fff4a1d5f42d172a7 (diff) |
Update bundled bundler to 1.16.0.
* lib/bundler, spec/bundler: Merge bundler-1.16.0.
* common.mk: rspec examples of bundler-1.16.0 needs require option.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/bundler/rubygems_integration.rb')
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 84 |
1 files changed, 57 insertions, 27 deletions
diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index c3e16e086c..0f16b6231d 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + require "monitor" require "rubygems" require "rubygems/config_file" @@ -84,6 +85,19 @@ module Bundler spec.respond_to?(:default_gem?) && spec.default_gem? end + def spec_matches_for_glob(spec, glob) + return spec.matches_for_glob(glob) if spec.respond_to?(:matches_for_glob) + + spec.load_paths.map do |lp| + Dir["#{lp}/#{glob}#{suffix_pattern}"] + end.flatten(1) + end + + def spec_extension_dir(spec) + return unless spec.respond_to?(:extension_dir) + spec.extension_dir + end + def stub_set_spec(stub, spec) stub.instance_variable_set(:@spec, spec) end @@ -158,6 +172,10 @@ module Bundler Gem.post_reset_hooks end + def suffix_pattern + Gem.suffix_pattern + end + def gem_cache gem_path.map {|p| File.expand_path("cache", p) } end @@ -165,7 +183,7 @@ module Bundler def spec_cache_dirs @spec_cache_dirs ||= begin dirs = gem_path.map {|dir| File.join(dir, "specifications") } - dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in Rubygems 2.0.3 or earlier + dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in RubyGems 2.0.3 or earlier dirs.uniq.select {|dir| File.directory? dir } end end @@ -179,7 +197,7 @@ module Bundler end def repository_subdirectories - %w(cache doc gems specifications) + %w[cache doc gems specifications] end def clear_paths @@ -190,8 +208,12 @@ module Bundler Gem.bin_path(gem, bin, ver) end + def path_separator + File::PATH_SEPARATOR + end + def preserve_paths - # this is a no-op outside of Rubygems 1.8 + # this is a no-op outside of RubyGems 1.8 yield end @@ -212,6 +234,10 @@ module Bundler Gem.load_plugins if Gem.respond_to?(:load_plugins) end + def load_plugin_files(files) + Gem.load_plugin_files(files) if Gem.respond_to?(:load_plugin_files) + end + def ui=(obj) Gem::DefaultUserInteraction.ui = obj end @@ -233,9 +259,9 @@ module Bundler {} # if we can't download them, there aren't any end - # TODO: This is for older versions of Rubygems... should we support the + # TODO: This is for older versions of RubyGems... should we support the # X-Gemfile-Source header on these old versions? - # Maybe the newer implementation will work on older Rubygems? + # Maybe the newer implementation will work on older RubyGems? # It seems difficult to keep this implementation and still send the header. def fetch_all_remote_specs(remote) old_sources = Bundler.rubygems.sources @@ -273,6 +299,7 @@ module Bundler def spec_from_gem(path, policy = nil) require "rubygems/security" + require "bundler/psyched_yaml" gem_from_path(path, security_policies[policy]).spec rescue Gem::Package::FormatError raise GemspecError, "Could not read gem at #{path}. It may be corrupted." @@ -306,7 +333,7 @@ module Bundler end def security_policy_keys - %w(High Medium Low AlmostNo No).map {|level| "#{level}Security" } + %w[High Medium Low AlmostNo No].map {|level| "#{level}Security" } end def security_policies @@ -377,9 +404,8 @@ module Bundler raise e end - # TODO: delete this in 2.0, it's a backwards compatibility shim - # see https://github.com/bundler/bundler/issues/5102 - kernel_class.send(:public, :gem) + # backwards compatibility shim, see https://github.com/bundler/bundler/issues/5102 + kernel_class.send(:public, :gem) if Bundler.feature_flag.setup_makes_kernel_gem_public? end end @@ -434,9 +460,9 @@ module Bundler raise Gem::Exception, "no default executable for #{spec.full_name}" unless exec_name ||= spec.default_executable - unless spec.name == name - Bundler::SharedHelpers.major_deprecation \ - "Bundler is using a binstub that was created for a different gem.\n" \ + unless spec.name == gem_name + Bundler::SharedHelpers.major_deprecation 2, + "Bundler is using a binstub that was created for a different gem (#{spec.name}).\n" \ "You should run `bundle binstub #{gem_name}` " \ "to work around a system/bundle conflict." end @@ -476,7 +502,7 @@ module Bundler redefine_method(gem_class, :refresh) {} end - # Replace or hook into Rubygems to provide a bundlerized view + # Replace or hook into RubyGems to provide a bundlerized view # of the world. def replace_entrypoints(specs) specs_by_name = specs.reduce({}) do |h, s| @@ -492,8 +518,8 @@ module Bundler Gem.clear_paths end - # This backports the correct segment generation code from Rubygems 1.4+ - # by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7. + # This backports the correct segment generation code from RubyGems 1.4+ + # by monkeypatching it into the method in RubyGems 1.3.6 and 1.3.7. def backport_segment_generation redefine_method(Gem::Version, :segments) do @segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s| @@ -512,7 +538,7 @@ module Bundler end # This backports base_dir which replaces installation path - # Rubygems 1.8+ + # RubyGems 1.8+ def backport_base_dir redefine_method(Gem::Specification, :base_dir) do return Gem.dir unless loaded_from @@ -581,7 +607,7 @@ module Bundler end end - # Rubygems 1.4 through 1.6 + # RubyGems 1.4 through 1.6 class Legacy < RubygemsIntegration def initialize super @@ -592,7 +618,7 @@ module Bundler end def stub_rubygems(specs) - # Rubygems versions lower than 1.7 use SourceIndex#from_gems_in + # RubyGems versions lower than 1.7 use SourceIndex#from_gems_in source_index_class = (class << Gem::SourceIndex; self; end) redefine_method(source_index_class, :from_gems_in) do |*args| Gem::SourceIndex.new.tap do |source_index| @@ -624,7 +650,7 @@ module Bundler end end - # Rubygems versions 1.3.6 and 1.3.7 + # RubyGems versions 1.3.6 and 1.3.7 class Ancient < Legacy def initialize super @@ -632,7 +658,7 @@ module Bundler end end - # Rubygems 1.7 + # RubyGems 1.7 class Transitional < Legacy def stub_rubygems(specs) stub_source_index(specs) @@ -646,7 +672,7 @@ module Bundler end end - # Rubygems 1.8.5-1.8.19 + # RubyGems 1.8.5-1.8.19 class Modern < RubygemsIntegration def stub_rubygems(specs) Gem::Specification.all = specs @@ -667,9 +693,9 @@ module Bundler end end - # Rubygems 1.8.0 to 1.8.4 + # RubyGems 1.8.0 to 1.8.4 class AlmostModern < Modern - # Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever + # RubyGems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever # you call Gem::Installer#install with an :install_dir set. We have to # change it back for our sudo mode to work. def preserve_paths @@ -680,9 +706,9 @@ module Bundler end end - # Rubygems 1.8.20+ + # RubyGems 1.8.20+ class MoreModern < Modern - # Rubygems 1.8.20 and adds the skip_validation parameter, so that's + # RubyGems 1.8.20 and adds the skip_validation parameter, so that's # when we start passing it through. def build(spec, skip_validation = false) require "rubygems/builder" @@ -690,7 +716,7 @@ module Bundler end end - # Rubygems 2.0 + # RubyGems 2.0 class Future < RubygemsIntegration def stub_rubygems(specs) Gem::Specification.all = specs @@ -767,6 +793,10 @@ module Bundler def install_with_build_args(args) yield end + + def path_separator + Gem.path_separator + end end # RubyGems 2.1.0 @@ -855,7 +885,7 @@ module Bundler RubygemsIntegration::Transitional.new elsif RubygemsIntegration.provides?(">= 1.4.0") RubygemsIntegration::Legacy.new - else # Rubygems 1.3.6 and 1.3.7 + else # RubyGems 1.3.6 and 1.3.7 RubygemsIntegration::Ancient.new end end |