123456789_123456789_123456789_123456789_123456789_

Class: Bundler::GemInstaller

Relationships & Source Files
Inherits: Object
Defined in: lib/bundler/installer/gem_installer.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(spec, installer, standalone = false, worker = 0, force = false, local = false) ⇒ GemInstaller

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 7

def initialize(spec, installer, standalone = false, worker = 0, force = false, local = false)
  @spec = spec
  @installer = installer
  @standalone = standalone
  @worker = worker
  @force = force
  @local = local
end

Instance Attribute Details

#force (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

#installer (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

#local (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

#spec (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

#standalone (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

#worker (readonly)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 5

attr_reader :spec, :standalone, :worker, :force, :local, :installer

Instance Method Details

#failure_message (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 38

def failure_message
  install_error_message
end

#generate_executable_stubs (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 75

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 (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 54

def install
  spec.source.install(
    spec,
    force: force,
    local: local,
    build_args: Array(spec_settings),
    previous_spec: previous_spec,
  )
end

#install_error_message (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 42

def install_error_message
  "An error occurred while installing #{spec.name} (#{spec.version}), and Bundler cannot continue."
end

#install_from_spec

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 16

def install_from_spec
  post_install_message = install
  Bundler.ui.debug "#{worker}:  #{spec.name} (#{spec.version}) from #{spec.loaded_from}"
  generate_executable_stubs
  [true, post_install_message]
rescue Bundler::InstallHookError, Bundler::SecurityError, Bundler::APIResponseMismatchError, Bundler::InsecureInstallPathError
  raise
rescue Errno::ENOSPC
  [false, out_of_space_message]
rescue Bundler::BundlerError, Gem::InstallError => e
  [false, specific_failure_message(e)]
end

#out_of_space_message (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 71

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

#previous_spec (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 64

def previous_spec
  locked_gems = installer.definition.locked_gems
  return unless locked_gems

  locked_gems.specs.find {|s| s.name == spec.name }
end

#spec_settings (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 46

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) (private)

[ GitHub ]

  
# File 'lib/bundler/installer/gem_installer.rb', line 31

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