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) ⇒ GemInstaller

[ GitHub ]

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

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

Instance Attribute Details

#force (readonly)

[ GitHub ]

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

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

#installer (readonly)

[ GitHub ]

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

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

#spec (readonly)

[ GitHub ]

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

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

#standalone (readonly)

[ GitHub ]

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

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

#worker (readonly)

[ GitHub ]

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

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

Instance Method Details

#failure_message (private)

[ GitHub ]

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

def failure_message
  return install_error_message if spec.source.options["git"]
  "#{install_error_message}\n#{gem_install_message}"
end

#gem_install_message (private)

[ GitHub ]

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

def gem_install_message
  source = spec.source
  return unless source.respond_to?(:remotes)

  if source.remotes.size == 1
    "Make sure that `gem install #{spec.name} -v '#{spec.version}' --source '#{source.remotes.first}'` succeeds before bundling."
  else
    "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling."
  end
end

#generate_executable_stubs (private)

[ GitHub ]

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

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 66

def install
  spec.source.install(spec, :force => force, :ensure_builtin_gems_cached => standalone, :build_args => Array(spec_settings))
end

#install_error_message (private)

[ GitHub ]

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

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 17

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, APIResponseMismatchError
  raise
rescue Errno::ENOSPC
  return false, out_of_space_message
rescue StandardError => e
  return false, specific_failure_message(e)
end

#install_with_settings (private)

[ GitHub ]

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

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

[ GitHub ]

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

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

[ GitHub ]

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

def spec_settings
  # Fetch the build settings, if there are any
  if settings = Bundler.settings["build.#{spec.name}"]
    Shellwords.shellsplit(settings)
  end
end

#specific_failure_message(e) (private)

[ GitHub ]

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

def specific_failure_message(e)
  message = "#{e.class}: #{e.message}\n"
  message += "  " + e.backtrace.join("\n  ") + "\n\n" if Bundler.ui.debug?
  message = message.lines.first + Bundler.ui.add_color(message.lines.drop(1).join, :clear)
  message + Bundler.ui.add_color(failure_message, :red)
end