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 lib/bundler/installer/gem_installer.rb, line 6
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 lib/bundler/installer/gem_installer.rb, line 14
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
  post_install_message

rescue Errno::ENOSPC
  raise Bundler::InstallError, out_of_space_message
rescue => e
  handle_exception(e)
end

Private Instance Methods

failure_message() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 28
def failure_message
  return install_error_message if spec.source.options["git"]
  "#{install_error_message}\n#{gem_install_message}"
end
gem_install_message() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 37
def gem_install_message
  "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling."
end
generate_executable_stubs() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 69
def generate_executable_stubs
  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
handle_exception(e) click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 41
def handle_exception(e)
  # if install hook failed or gem signature is bad, just die
  raise e if e.is_a?(Bundler::InstallHookError) || e.is_a?(Bundler::SecurityError)
  # other failure, likely a native extension build failure
  Bundler.ui.info ""
  Bundler.ui.warn "#{e.class}: #{e.message}"
  Bundler.ui.debug e.backtrace.join("\n")
  raise Bundler::InstallError, failure_message
end
install() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 56
def install
  spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone)
end
install_error_message() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 33
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 lib/bundler/installer/gem_installer.rb, line 60
def install_with_settings
  # Build arguments are global, so this is mutexed
  Bundler.rubygems.with_build_args([spec_settings]) { install }
end
out_of_space_message() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 65
def out_of_space_message
  "Your disk is out of space. Free some space to be able to install your bundle."
end
spec_settings() click to toggle source
# File lib/bundler/installer/gem_installer.rb, line 51
def spec_settings
  # Fetch the build settings, if there are any
  Bundler.settings["build.#{spec.name}"]
end