Module | Gem
In: | lib/rubygems/builder.rb lib/rubygems/command.rb lib/rubygems/commands/rdoc_command.rb lib/rubygems/commands/search_command.rb lib/rubygems/commands/uninstall_command.rb
lib/rubygems/command_manager.rb
lib/rubygems/defaults.rb
lib/rubygems/digest/digest_adapter.rb
lib/rubygems/digest/sha1.rb
lib/rubygems/digest/sha2.rb
lib/rubygems/doc_manager.rb
lib/rubygems/format.rb
lib/rubygems/gem_openssl.rb
lib/rubygems/gem_runner.rb
lib/rubygems/old_format.rb
lib/rubygems/require_paths_builder.rb
lib/rubygems/rubygems_version.rb
lib/rubygems/source_index.rb
lib/rubygems/specification.rb
lib/rubygems/user_interaction.rb
lib/rubygems/validator.rb
lib/rubygems.rb

Main module to hold all RubyGem classes/modules.

### Methods

_dump _load activate add_bindir add_dependency add_dependency_with_type add_development_dependency add_runtime_dependency all_load_paths array_attribute array_attributes assign_defaults attribute attribute_alias_singular attribute_defaults attribute_names attributes available? binary_mode bindir clear_paths config_file configuration configuration= datadir default_bindir default_dir default_exec_format default_path default_sources default_system_source_cache_dir default_user_source_cache_dir default_value deflate dependent_gems development_dependencies dir ensure_gem_subdirectories ensure_ssl_available file_name find_all_satisfiers from_yaml full_gem_path full_name gunzip gzip has_rdoc? has_test_suite? has_unit_tests? inflate installation_path latest_load_paths lib_files list load load_path_insert_index loaded? manage_gems mark_version marshal_version new normalize normalize_yaml_input overwrite_accessor path platforms platforms= prefix read_binary read_only refresh required_attribute required_attribute? required_attributes required_location ruby ruby_code ruby_version runtime_dependencies same_attributes? satisfies_requirement? searcher sort_obj source_index sources ssl_available? suffix_pattern suffixes test_suite_file test_suite_file= to_ruby to_s use_paths user_home validate win_platform?

### Classes and Modules

Module Gem::Commands
Module Gem::DefaultUserInteraction
Module Gem::Ext
Module Gem::InstallUpdateOptions
Module Gem::LocalRemoteOptions
Module Gem::Package
Module Gem::RequirePathsBuilder
Module Gem::SSL
Module Gem::Security
Module Gem::UserInteraction
Module Gem::VersionOption
Class Gem::Builder
Class Gem::Command
Class Gem::CommandLineError
Class Gem::CommandManager
Class Gem::ConfigFile
Class Gem::ConsoleUI
Class Gem::Dependency
Class Gem::DependencyError
Class Gem::DependencyInstaller
Class Gem::DependencyList
Class Gem::DependencyRemovalException
Class Gem::DigestAdapter
Class Gem::DocManager
Class Gem::DocumentError
Class Gem::EndOfYAMLException
Class Gem::Exception
Class Gem::FakeFetcher
Class Gem::FileOperations
Class Gem::FilePermissionError
Class Gem::Format
Class Gem::FormatException
Class Gem::GemNotFoundException
Class Gem::GemNotInHomeException
Class Gem::GemPathSearcher
Class Gem::GemRunner
Class Gem::Indexer
Class Gem::InstallError
Class Gem::Installer
Class Gem::InvalidSpecificationException
Class Gem::LoadError
Class Gem::OldFormat
Class Gem::OperationNotSupportedError
Class Gem::Platform
Class Gem::RemoteError
Class Gem::RemoteFetcher
Class Gem::RemoteInstallationCancelled
Class Gem::RemoteInstallationSkipped
Class Gem::RemoteSourceException
Class Gem::Requirement
Class Gem::Server
Class Gem::SilentUI
Class Gem::SourceIndex
Class Gem::SourceInfoCache
Class Gem::SourceInfoCacheEntry
Class Gem::SpecFetcher
Class Gem::StreamUI
Class Gem::SystemExitException
Class Gem::Uninstaller
Class Gem::Validator
Class Gem::VerificationError
Class Gem::Version

### Constants

SHA1 | = | Digest::SHA1
SHA1 | = | DigestAdapter.new(Digest::SHA1)
SHA256 | = | Digest::SHA256
SHA256 | = | DigestAdapter.new(Digest::SHA256)
RubyGemsVersion | = | '1.2.0'
ConfigMap | = | {} unless defined?(ConfigMap)
RbConfig | = | Config unless defined? ::RbConfig
DIRECTORIES | = | %w[cache doc gems specifications] unless defined?(DIRECTORIES)
MUTEX | = | Mutex.new
RubyGemsPackageVersion | = | RubyGemsVersion
WIN_PATTERNS | = | [ /bccwin/i, /cygwin/i, /djgpp/i, /mingw/i, /mswin/i, /wince/i, ] |  | An Array of Regexps that match windows ruby platforms.
MARSHAL_SPEC_DIR | = | "quick/Marshal.#{Gem.marshal_version}/"
YAML_SPEC_DIR | = | 'quick/'

### External Aliases

== | -> | eql?

### Attributes

loaded_specs | [R] |
ssl_available | [W] | Set the value of the ssl_available flag.

### Public Class methods

_load(str)

Load custom marshal format, re-initializing defaults as needed

activate(gem, *version_requirements)

Activates an installed gem matching `gem`. The gem must satisfy `version_requirements`.

Returns true if the gem is activated, false if it is already loaded, or an exception otherwise.

Gem#activate adds the library paths in `gem` to $LOAD_PATH. Before a Gem is activated its required Gems are activated. If the version information is omitted, the highest version Gem of the supplied name is loaded. If a Gem is not found that meets the version requirements or a required Gem is not found, a Gem::LoadError is raised.

More information on version requirements can be found in the Gem::Requirement and Gem::Version documentation.

all_load_paths()

An Array of all possible load paths for all versions of all gems in the Gem installation.

array_attribute(name)

Same as :attribute, but ensures that values assigned to the attribute are array values by applying :to_a to the value.

array_attributes()
attribute(name, default=nil)

Used to specify the name and default value of a specification attribute. The side effects are:

- the name and default value are added to the @@attributes list and @@default_value map
- a standard writer method (`attribute=`) is created
- a non-standard _reader method (`attribute`) is created

The reader method behaves like this:

      def attribute
        @attribute ||= (copy of default value)
      end

This allows lazy initialization of attributes to their default values.

attribute_alias_singular(singular, plural)

Defines a singular version of an existing plural attribute (i.e. one whose value is expected to be an array). This means just creating a helper method that takes a single value and appends it to the array. These are created for convenience, so that in a spec, one can write

      s.require_path = 'mylib'

instead of

      s.require_paths = ['mylib']

That above convenience is available courtesy of

      attribute_alias_singular :require_path, :require_paths

attribute_defaults()
attribute_names()

————————- Convenience class methods.

attributes(*args)

Shortcut for creating several attributes at once (each with a default value of `nil`).

available?(gem, *requirements)

See if a given gem is available.

binary_mode()

The mode needed to read a file as straight binary.

bindir(install_dir=Gem.dir)

The path where gem executables are to be installed.

clear_paths()

Reset the `dir` and `path` values. The next time `dir` or `path` is requested, the values will be calculated from scratch. This is mainly used by the unit tests to provide test isolation.

config_file()

The path to standard location of the user‘s .gemrc file.

configuration()

The standard configuration object for gems.

configuration=(config)

Use the given configuration object (which implements the ConfigFile protocol) as the standard configuration object.

datadir(gem_name)

The path the the data directory specified by the gem name. If the package is not available as a gem, return nil.

default_bindir()

The default directory for binaries

default_dir()

Default home directory path to be used if an alternate value is not specified in the environment.

default_exec_format()

Deduce Ruby‘s —program-prefix and —program-suffix from its install name.

default_path()

Default gem path.

default_sources()

An Array of the default sources that come with RubyGems.

default_system_source_cache_dir()

The default system-wide source info cache directory.

default_user_source_cache_dir()

The default user-specific source info cache directory.

default_value(name)
deflate(data)

A Zlib::Deflate.deflate wrapper

dir()

The path where gems are to be installed.

ensure_gem_subdirectories(gemdir)

Quietly ensure the named Gem directory contains all the proper subdirectories. If we can‘t create a directory due to a permission problem, then we will silently continue.

ensure_ssl_available()

Ensure that SSL is available. Throw an exception if it is not.

from_yaml(input)

Special loader for YAML files. When a Specification object is loaded from a YAML file, it bypasses the normal Ruby object initialization routine (initialize). This method makes up for that and deals with gems of different ages.

‘input’ can be anything that YAML.load() accepts: String or IO.

gunzip(data)

Zlib::GzipReader wrapper that unzips `data`.

gzip(data)

Zlib::GzipWriter wrapper that zips `data`.

inflate(data)

A Zlib::Inflate#inflate wrapper

latest_load_paths()

Return a list of all possible load paths for the latest version for all gems in the Gem installation.

list()

A list of Specification instances that have been defined in this Ruby instance.

load(filename)
load_path_insert_index()

The index to insert activated gem paths into the $LOAD_PATH.

Defaults to the site lib directory unless gem_prelude.rb has loaded paths, then it inserts the activated gem‘s paths before the gem_prelude.rb paths so you can override the gem_prelude.rb default $LOAD_PATH paths.

manage_gems()

manage_gems is useless and deprecated. Don‘t call it anymore.

marshal_version()

The version of the Marshal format for your Ruby.

new() {|self if block_given?| ...}

Specification constructor. Assigns the default values to the attributes, adds this spec to the list of loaded specs (see Specification.list), and yields itself for further initialization.

normalize_yaml_input(input)

Make sure the yaml specification is properly formatted with dashes.

overwrite_accessor(name, &block)

Some attributes require special behaviour when they are accessed. This allows for that.

path()

Array of paths to search for Gems.

platforms()

Array of platforms this RubyGems supports.

platforms=(platforms)

Set array of platforms this RubyGems supports (primarily for testing).

prefix()

The directory prefix this RubyGems was installed at.

read_binary(path)

Safely read a file in binary mode on all platforms.

read_only(*names)

Sometimes we don‘t want the world to use a setter method for a particular attribute. `read_only` makes it private so we can still use it internally.

refresh()

Refresh source_index from disk and clear searcher.

required_attribute(*args)

Same as attribute above, but also records this attribute as mandatory.

required_attribute?(name)
required_attributes()
required_location(gemname, libfile, *version_constraints)
ruby()

The path to the running Ruby interpreter.

ruby_version()

A Gem::Version for the currently running ruby.

searcher()

The GemPathSearcher object used to search for matching installed gems.

source_index()

Returns the Gem::SourceIndex of specifications that are in the Gem.path

sources()

Returns an Array of sources to fetch remote gems from. If the sources list is empty, attempts to load the "sources" gem, then uses default_sources if it is not installed.

ssl_available?()

Is SSL (used by the signing commands) available on this platform?

suffix_pattern()

Glob pattern for require-able path suffixes.

suffixes()

Suffixes for require-able paths.

use_paths(home, paths=[])

Use the `home` and `paths` values for Gem.dir and Gem.path. Used mainly by the unit tests to provide environment isolation.

user_home()

The home directory for the user.

win_platform?()

Is this a windows platform?

### Public Instance methods

_dump(limit)

Dump only crucial instance variables.

add_bindir(executables)
add_dependency(gem, *requirements)

Alias for add_runtime_dependency

add_dependency_with_type(dependency, type, *requirements)
add_development_dependency(gem, *requirements)

Adds a development dependency to this Gem. For example,

      spec.add_development_dependency('jabber4r', '> 0.1', '<= 0.5')

Development dependencies aren‘t installed by default, and aren‘t activated when a gem is required.

gem: | [String or Gem::Dependency] The Gem name/dependency.
requirements: | [default=">= 0"] The version requirements.

add_runtime_dependency(gem, *requirements)

Adds a runtime dependency to this Gem. For example,

      spec.add_runtime_dependency('jabber4r', '> 0.1', '<= 0.5')

gem: | [String or Gem::Dependency] The Gem name/dependency.
requirements: | [default=">= 0"] The version requirements.

assign_defaults()

Each attribute has a default value (possibly nil). Here, we initialize all attributes to their default value. This is done through the accessor methods, so special behaviours will be honored. Furthermore, we take a copy of the default so each specification instance has its own empty arrays, etc.

dependent_gems()

Return a list of all gems that have a dependency on this gemspec. The list is structured with entries that conform to:

      [depending_gem, dependency, [list_of_gems_that_satisfy_dependency]]

return: | [Array] [[dependent_gem, dependency, [list_of_satisfiers]]]

development_dependencies()
file_name()

The default (generated) file name of the gem.

find_all_satisfiers(dep) {|gem| ...}
full_gem_path()

The full path to the gem (install path + full name).

full_name()

Returns the full name (name-version) of this Gem. Platform information is included (name-version-platform) if it is specified (and not the default Ruby platform).

has_rdoc?()
has_test_suite?()

Alias for has_unit_tests?

has_unit_tests?()
installation_path()

The directory that this gem was installed into.

lib_files()

Files in the Gem under one of the require_paths

loaded?()

Predicates ——————————————————

mark_version()

Sets the rubygems_version to Gem::RubyGemsVersion.

normalize()

Normalize the list of files so that:

- All file lists have redundancies removed.
- Files referenced in the extra_rdoc_files are included in the package file list.

Also, the summary and description are converted to a normal format.

ruby_code(obj)

Return a string containing a Ruby code representation of the given object.

runtime_dependencies()
same_attributes?(other)
satisfies_requirement?(dependency)

Checks if this Specification meets the requirement of the supplied dependency.

dependency: | [Gem::Dependency] the dependency to check
return: | [Boolean] true if dependency is met, otherwise false

sort_obj()

Comparison methods ———————————————

test_suite_file()

DEPRECATED gemspec attributes ———————————-

test_suite_file=(val)
to_ruby()

Returns a Ruby code representation of this specification, such that it can be eval‘ed and reconstruct the same specification later. Attributes that still have their default values are omitted.

to_s()
validate()

Checks that the specification contains all required fields, and does a very basic sanity check.

Raises InvalidSpecificationException if the spec does not pass the checks..

[Validate]