class Bundler::GemInstaller

Attributes

force[R]
installer[R]
spec[R]
standalone[R]
worker[R]

Public Class Methods

new(spec, installer, standalone = false, worker = 0, force = false) click to toggle source
# File bundler/installer/gem_installer.rb, line 7
def initialize(spec, installer, standalone = false, worker = 0, force = false)
  @spec = spec
  @installer = installer
  @standalone = standalone
  @worker = worker
  @force = force
end

Public Instance Methods

install_from_spec() click to toggle source
# File bundler/installer/gem_installer.rb, line 15
def install_from_spec
  post_install_message = spec_settings ? install_with_settings : install
  Bundler.ui.debug "#{worker}:  #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
  generate_executable_stubs
  return true, post_install_message
rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError
  raise
rescue Errno::ENOSPC
  return false, out_of_space_message
rescue Bundler::BundlerError, Gem::InstallError, Bundler::APIResponseInvalidDependenciesError => e
  return false, specific_failure_message(e)
end

Private Instance Methods

failure_message() click to toggle source
# File bundler/installer/gem_installer.rb, line 37
def failure_message
  install_error_message
end
generate_executable_stubs() click to toggle source
# File bundler/installer/gem_installer.rb, line 66
def generate_executable_stubs
  return if Bundler.feature_flag.forget_cli_options?
  return if Bundler.settings[:inline]
  if Bundler.settings[:bin] && standalone
    installer.generate_standalone_bundler_executable_stubs(spec)
  elsif Bundler.settings[:bin]
    installer.generate_bundler_executable_stubs(spec, :force => true)
  end
end
install() click to toggle source
# File bundler/installer/gem_installer.rb, line 53
def install
  spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings))
end
install_error_message() click to toggle source
# File bundler/installer/gem_installer.rb, line 41
def install_error_message
  "An error occurred while installing #{spec.name} (#{spec.version}), and Bundler cannot continue."
end
install_with_settings() click to toggle source
# File bundler/installer/gem_installer.rb, line 57
def install_with_settings
  # Build arguments are global, so this is mutexed
  Bundler.rubygems.install_with_build_args([spec_settings]) { install }
end
out_of_space_message() click to toggle source
# File bundler/installer/gem_installer.rb, line 62
def out_of_space_message
  "#{install_error_message}\nYour disk is out of space. Free some space to be able to install your bundle."
end
spec_settings() click to toggle source
# File bundler/installer/gem_installer.rb, line 45
def spec_settings
  # Fetch the build settings, if there are any
  if settings = Bundler.settings["build.#{spec.name}"]
    require "shellwords"
    Shellwords.shellsplit(settings)
  end
end
specific_failure_message(e) click to toggle source
# File bundler/installer/gem_installer.rb, line 30
def specific_failure_message(e)
  message = "#{e.class}: #{e.message}\n"
  message += "  " + e.backtrace.join("\n  ") + "\n\n"
  message = message.lines.first + Bundler.ui.add_color(message.lines.drop(1).join, :clear)
  message + Bundler.ui.add_color(failure_message, :red)
end