summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-08-03 15:55:17 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-08-04 18:11:16 -0500
commit0dec895db65758c44690eecfb2d40b1acfcd55f9 (patch)
tree1f81aa509b52a1c164e1197ba0b72e0e3721501a
parent7fb0e91d9b7def611e2867bd41d8300c06594fde (diff)
downloadbundler-0dec895db65758c44690eecfb2d40b1acfcd55f9.tar.gz
[Installer] Move post-install messages to be an instance attribute
-rw-r--r--lib/bundler/cli/install.rb4
-rw-r--r--lib/bundler/inline.rb4
-rw-r--r--lib/bundler/installer.rb11
-rw-r--r--lib/bundler/installer/parallel_installer.rb10
4 files changed, 14 insertions, 15 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index e8a3aba2f3..5c7b8c5b0b 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -68,7 +68,7 @@ module Bundler
definition = Bundler.definition
definition.validate_ruby!
- Installer.install(Bundler.root, definition, options)
+ installer = Installer.install(Bundler.root, definition, options)
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.settings[:frozen]
Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
@@ -83,7 +83,7 @@ module Bundler
end
unless Bundler.settings["ignore_messages"]
- Installer.post_install_messages.to_a.each do |name, msg|
+ installer.post_install_messages.to_a.each do |name, msg|
print_post_install_message(name, msg) unless Bundler.settings["ignore_messages.#{name}"]
end
end
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index 6f3cd6c132..dcaf22944c 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -60,8 +60,8 @@ def gemfile(install = false, options = {}, &gemfile)
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|
+ installer = Bundler::Installer.install(Bundler.root, definition, :system => true)
+ installer.post_install_messages.each do |name, message|
Bundler.ui.info "Post-install message from #{name}:\n#{message}"
end
end
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 402d7fb611..aa0c5f1c8e 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -9,12 +9,13 @@ require "bundler/installer/gem_installer"
module Bundler
class Installer
class << self
- attr_accessor :post_install_messages, :ambiguous_gems
+ attr_accessor :ambiguous_gems
- Installer.post_install_messages = {}
Installer.ambiguous_gems = []
end
+ attr_reader :post_install_messages
+
# Begins the installation process for Bundler.
# For more information see the #run method on this class.
def self.install(root, definition, options = {})
@@ -26,6 +27,7 @@ module Bundler
def initialize(root, definition)
@root = root
@definition = definition
+ @post_install_messages = {}
end
# Runs the install procedures for a specific Gemfile.
@@ -192,7 +194,10 @@ module Bundler
end
def install_in_parallel(size, standalone, force = false)
- ParallelInstaller.call(self, @definition.specs, size, standalone, force)
+ spec_installations = ParallelInstaller.call(self, @definition.specs, size, standalone, force)
+ spec_installations.each do |installation|
+ post_install_messages[installation.name] = installation.post_install_message if installation.has_post_install_message?
+ end
end
def create_bundle_path
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 18bfe0897c..5b0138cb4a 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -91,6 +91,7 @@ module Bundler
enqueue_specs
process_specs until @specs.all?(&:installed?) || @specs.any?(&:failed?)
handle_error if @specs.any?(&:failed?)
+ @specs
ensure
worker_pool && worker_pool.stop
end
@@ -118,17 +119,10 @@ module Bundler
# dequeue.
def process_specs
spec = worker_pool.deq
- unless spec.failed?
- spec.state = :installed
- collect_post_install_message spec if spec.has_post_install_message?
- end
+ spec.state = :installed unless spec.failed?
enqueue_specs
end
- def collect_post_install_message(spec)
- Bundler::Installer.post_install_messages[spec.name] = spec.post_install_message
- end
-
def handle_error
errors = @specs.select(&:failed?).map(&:error)
if exception = errors.find {|e| e.is_a?(Bundler::Error) }