Class: Gem::Installer

Class | Gem::Installer
In: | lib/rubygems/installer.rb
Parent: | Object

The installer class processes RubyGem .gem files and installs the files contained in the .gem into the Gem.path.

Gem::Installer does the work of putting files in all the right places on the filesystem including unpacking the gem into its gem dir, installing the gemspec in the specifications dir, storing the cached gem in the cache dir, and installing either wrappers or symlinks for executables.

The installer fires pre and post install hooks. Hooks can be added either through a rubygems_plugin.rb file in an installed gem or via a rubygems/defaults/#{RUBY_ENGINE}.rb or rubygems/defaults/operating_system.rb file. See Gem.pre_install and Gem.post_install for details.

### Methods

app_script_text build_extensions ensure_dependency exec_format extract_files formatted_program_filename generate_bin generate_bin_script generate_bin_symlink generate_windows_script install installation_satisfies_dependency? new shebang unpack windows_stub_script write_spec

### Included Modules

Gem::UserInteraction Gem::RequirePathsBuilder

### Classes and Modules

Class Gem::Installer::ExtensionBuildError

### Attributes

bin_dir | [R] | The directory a gem‘s executables will be installed into
exec_format | [W] |
gem_home | [R] | The gem repository the gem will be installed into
home_install_warning | [RW] | True if we‘ve warned about ~/.gems install
path_warning | [RW] | True if we‘ve warned about PATH not including Gem.bindir
spec | [R] | The Gem::Specification for the gem being installed

### Public Class methods

exec_format()

Defaults to use Ruby‘s program prefix and suffix.

new(gem, options={})

Constructs an Installer instance that will install the gem located at `gem`. `options` is a Hash with the following keys:

:env_shebang: | Use /usr/bin/env in bin wrappers.
:force: | Overrides all version checks and security policy checks, except for a signed-gems-only policy.
:ignore_dependencies: | Don‘t raise if a dependency is missing.
:install_dir: | The directory to install the gem into.
:format_executable: | Format the executable the same as the ruby executable. If your ruby is ruby18, foo_exec will be installed as foo_exec18.
:security_policy: | Use the specified security policy. See Gem::Security
:wrappers: | Install wrappers if true, symlinks if false.

### Public Instance methods

app_script_text(bin_file_name)

Return the text for an application file.

build_extensions()

Builds extensions. Valid types of extensions are extconf.rb files, configure scripts and rakefiles or mkrf_conf files.

ensure_dependency(spec, dependency)

Ensure that the dependency is satisfied by the current installation of gem. If it is not an exception is raised.

spec : | Gem::Specification
dependency : | Gem::Dependency

extract_files()

Reads the file index and extracts each file into the gem directory.

Ensures that files can‘t be installed outside the gem directory.

formatted_program_filename(filename)

Prefix and suffix the program filename the same as ruby.

generate_bin()
generate_bin_script(filename, bindir)

Creates the scripts to run the applications in the gem.

generate_bin_symlink(filename, bindir)

Creates the symlinks to run the applications in the gem. Moves the symlink if the gem being installed has a newer version.

generate_windows_script(bindir, filename)

Creates windows .bat files for easy running of commands

install()

Installs the gem and returns a loaded Gem::Specification for the installed gem.

The gem will be installed with the following structure:

      @gem_home/
        cache/<gem-version>.gem #=> a cached copy of the installed gem
        gems/<gem-version>/... #=> extracted files
        specifications/<gem-version>.gemspec #=> the Gem::Specification

installation_satisfies_dependency?(dependency)

True if the gems in the source_index satisfy `dependency`.

shebang(bin_file_name)

Generates a #! line for `bin_file_name`‘s wrapper copying arguments if necessary.

unpack(directory)

Unpacks the gem into the given directory.

windows_stub_script(bindir, bin_file_name)

return the stub script text used to launch the true ruby script

write_spec()

Writes the .gemspec specification (in Ruby) to the gem home‘s specifications directory.

[Validate]