diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-05-31 13:15:29 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-05-31 15:09:30 -0500 |
commit | ec759435f85e81a9899f3781699650928682c589 (patch) | |
tree | 5d10bb71d2f4bc49dcc392c839c6b22ad0716a23 | |
parent | cacccfb05541ee4da9254b864b95d6dc7804593e (diff) | |
download | bundler-ec759435f85e81a9899f3781699650928682c589.tar.gz |
[Inline] Install when necessaryseg-inline-install-when-needed
The RubyGems change just means setting remote! will always cause specs to be fetched remotely
-rw-r--r-- | lib/bundler/inline.rb | 17 | ||||
-rw-r--r-- | lib/bundler/source/rubygems.rb | 1 | ||||
-rw-r--r-- | spec/runtime/inline_spec.rb | 15 |
3 files changed, 29 insertions, 4 deletions
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index 1ad78c61d1..b6bddda5dd 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -48,8 +48,17 @@ def gemfile(install = false, options = {}, &gemfile) def definition.lock(*); end definition.validate_ruby! - if install - Bundler.ui = ui + missing_specs = proc do + begin + !definition.missing_specs.empty? + rescue Bundler::GemNotFound + definition.instance_variable_set(:@index, nil) + true + end + end + + Bundler.ui = ui if install + if install || missing_specs.call Bundler::Installer.install(Bundler.root, definition, :system => true) Bundler::Installer.post_install_messages.each do |name, message| Bundler.ui.info "Post-install message from #{name}:\n#{message}" @@ -58,7 +67,7 @@ def gemfile(install = false, options = {}, &gemfile) runtime = Bundler::Runtime.new(nil, definition) runtime.setup.require - +ensure bundler_module = class << Bundler; self; end - bundler_module.send(:define_method, :root, old_root) + bundler_module.send(:define_method, :root, old_root) if old_root end diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb index d8ca36e3f9..44fdfbdecb 100644 --- a/lib/bundler/source/rubygems.rb +++ b/lib/bundler/source/rubygems.rb @@ -27,6 +27,7 @@ module Bundler end def remote! + @specs = nil @allow_remote = true end diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index 47851430e5..870a3ffd57 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -140,4 +140,19 @@ describe "bundler/inline#gemfile" do expect(out).to match("OKAY") expect(exitstatus).to be_zero if exitstatus end + + it "installs quietly if necessary when the install option is not set" do + script <<-RUBY + gemfile do + source "file://#{gem_repo1}" + gem "rack" + end + + puts RACK + RUBY + + expect(out).to eq("1.0.0") + expect(err).to be_empty + expect(exitstatus).to be_zero if exitstatus + end end |