Class: Gem::SourceInfoCache

Class | Gem::SourceInfoCache
In: | lib/rubygems/source_info_cache.rb
Parent: | Object

SourceInfoCache stores a copy of the gem index for each gem source.

There are two possible cache locations, the system cache and the user cache:

- The system cache is prefered if it is writable or can be created.
- The user cache is used otherwise

Once a cache is selected, it will be used for all operations. SourceInfoCache will not switch between cache files dynamically.

Cache data is a Hash mapping a source URI to a SourceInfoCacheEntry.

### Methods

cache cache_data cache_data cache_file flush refresh reset_cache_data reset_cache_for search search search_with_source search_with_source set_cache_data system_cache_file system_cache_file update user_cache_file user_cache_file write_cache

### Included Modules

Gem::UserInteraction

### Public Class methods

cache()
cache_data()
search(pattern, platform_only = false)

Search all source indexes for `pattern`.

search_with_source(pattern, only_platform = false)

Search all source indexes for `pattern`. Only returns gems matching Gem.platforms when `only_platform` is true. See search_with_source.

system_cache_file()

The name of the system cache file. (class method)

user_cache_file()

The name of the user cache file. (class method)

### Public Instance methods

cache_data()

The most recent cache data.

cache_file()

The name of the cache file to be read

flush()

Write the cache to a local file (if it is dirty).

refresh()

Refreshes each source in the cache from its repository.

reset_cache_data()
reset_cache_for(url)
search(pattern, platform_only = false)

Searches all source indexes for `pattern`.

search_with_source(pattern, only_platform = false)

Searches all source indexes for `pattern`. If `only_platform` is true, only gems matching Gem.platforms will be selected. Returns an Array of pairs containing the Gem::Specification found and the source_uri it was found at.

set_cache_data(hash)

Set the source info cache data directly. This is mainly used for unit testing when we don‘t want to read a file system to grab the cached source index information. The `hash` should map a source URL into a SourceInfoCacheEntry.

system_cache_file()

The name of the system cache file.

update()

Mark the cache as updated (i.e. dirty).

user_cache_file()

The name of the user cache file.

write_cache()

Write data to the proper cache.

[Validate]