diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-03 15:15:31 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-14 10:29:52 -0500 |
commit | 9e1e5e1273e929543b5d6ed43df108dd4fb8ea25 (patch) | |
tree | 72daeefaf7f3589d2943ffca03b2782ee9cc4b32 | |
parent | ddcca6254cc4e63cbb25b78f8ec93462fa56249c (diff) | |
download | bundler-9e1e5e1273e929543b5d6ed43df108dd4fb8ea25.tar.gz |
[Installer] Load plugin files from path gems
-rw-r--r-- | lib/bundler/installer.rb | 12 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 8 | ||||
-rw-r--r-- | spec/install/gemfile/path_spec.rb | 23 |
3 files changed, 42 insertions, 1 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb index efad66e202..813edbcda9 100644 --- a/lib/bundler/installer.rb +++ b/lib/bundler/installer.rb @@ -162,13 +162,23 @@ module Bundler # that said, it's a rare situation (other than rake), and parallel # installation is SO MUCH FASTER. so we let people opt in. def install(options) - Bundler.rubygems.load_plugins + load_plugins force = options["force"] jobs = 1 jobs = [Bundler.settings[:jobs].to_i - 1, 1].max if can_install_in_parallel? install_in_parallel jobs, options[:standalone], force end + def load_plugins + Bundler.rubygems.load_plugins + + requested_path_gems = @definition.requested_specs.select {|s| s.source.is_a?(Source::Path) } + path_plugin_files = requested_path_gems.map do |spec| + spec.matches_for_glob("rubygems_plugin#{Bundler.rubygems.suffix_pattern}") + end.flatten + Bundler.rubygems.load_plugin_files(path_plugin_files) + end + def ensure_specs_are_compatible! system_ruby = Bundler::RubyVersion.system rubygems_version = Gem::Version.create(Gem::VERSION) diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 8b7ed19465..7bd49a5cfb 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -158,6 +158,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 @@ -212,6 +216,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 diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb index 49dda37aee..e76d5c486e 100644 --- a/spec/install/gemfile/path_spec.rb +++ b/spec/install/gemfile/path_spec.rb @@ -590,5 +590,28 @@ RSpec.describe "bundle install with explicit source paths" do :requires => [lib_path("install_hooks.rb")] expect(out).to include("failed for foo-1.0") end + + it "loads plugins from the path gem" do + foo_file = home("foo_plugin_loaded") + bar_file = home("bar_plugin_loaded") + expect(foo_file).not_to be_file + expect(bar_file).not_to be_file + + build_lib "foo" do |s| + s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{foo_file}')") + end + + build_git "bar" do |s| + s.write("lib/rubygems_plugin.rb", "FileUtils.touch('#{bar_file}')") + end + + install_gemfile! <<-G + gem "foo", :path => "#{lib_path("foo-1.0")}" + gem "bar", :path => "#{lib_path("bar-1.0")}" + G + + expect(foo_file).to be_file + expect(bar_file).to be_file + end end end |