Class: Gem::SourceIndex

Class | Gem::SourceIndex
In: | lib/rubygems/source_index.rb
Parent: | Object

The SourceIndex object indexes all the gems available from a particular source (e.g. a list of gem directories, or a remote source). A SourceIndex maps a gem full name to a gem specification.

NOTE: | The class used to be named Cache, but that became confusing when cached source fetchers where introduced. The constant Gem::Cache is an alias for this class to allow old YAMLized source index objects to load properly.

### Methods

add_spec add_specs all_gems dump each find_name from_gems_in from_installed_gems gem_signature index_signature installed_spec_directories latest_specs length load_gems_in load_specification new outdated prerelease_gems prerelease_specs refresh! released_gems released_specs remove_spec search size specification update

### Included Modules

Enumerable Gem::UserInteraction Gem::UserInteraction

### Attributes

spec_dirs | [RW] | Directories to use to refresh this SourceIndex when calling refresh!

### Public Class methods

from_gems_in(*spec_dirs)

Creates a new SourceIndex from the ruby format gem specifications in `spec_dirs`.

from_installed_gems(*deprecated)

Factory method to construct a source index instance for a given path.

deprecated: | If supplied, from_installed_gems will act just like `from_gems_in`. This argument is deprecated and is provided just for backwards compatibility, and should not generally be used.
return: | SourceIndex instance

installed_spec_directories()

Returns a list of directories from Gem.path that contain specifications.

load_specification(file_name)

Loads a ruby-format specification from `file_name` and returns the loaded spec.

new(specifications={})

Constructs a source index instance from the provided specifications, which is a Hash of gem full names and Gem::Specifications.

### Public Instance methods

add_spec(gem_spec, name = gem_spec.full_name)

Add a gem specification to the source index.

add_specs(*gem_specs)

Add gem specifications to the source index.

all_gems()

TODO: remove method

dump()
each() {|gem.full_name, gem| ...}

Iterate over the specifications in the source index.

find_name(gem_name, version_requirement = Gem::Requirement.default)

Find a gem by an exact match on the short name.

gem_signature(gem_full_name)

The signature for the given gem specification.

index_signature()

The signature for the source index. Changes in the signature indicate a change in the index.

latest_specs()

Returns an Array specifications for the latest released versions of each gem in this index.

length()

Alias for size

load_gems_in(*spec_dirs)

Reconstruct the source index from the specifications in `spec_dirs`.

outdated()

Returns an Array of Gem::Specifications that are not up to date.

prerelease_gems()
prerelease_specs()

An array including only the prerelease gemspecs

refresh!()

Replaces the gems in the source index from specifications in the directories this source index was created from. Raises an exception if this source index wasn‘t created from a directory (via from_gems_in or from_installed_gems, or having spec_dirs set).

released_gems()
released_specs()

An array including only the released gemspecs

remove_spec(full_name)

Remove a gem specification named `full_name`.

search(gem_pattern, platform_only = false)

Search for a gem by Gem::Dependency `gem_pattern`. If `only_platform` is true, only gems matching Gem::Platform.local will be returned. An Array of matching Gem::Specification objects is returned.

For backwards compatibility, a String or Regexp pattern may be passed as `gem_pattern`, and a Gem::Requirement for `platform_only`. This behavior is deprecated and will be removed.

size()
specification(full_name)

The gem specification given a full gem spec name.

update(source_uri, all)

Updates this SourceIndex from `source_uri`. If `all` is false, only the latest gems are fetched.

[Validate]