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 preferred 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 latest_cache_data latest_cache_file latest_system_cache_file latest_system_cache_file latest_user_cache_file latest_user_cache_file read_all_cache_data read_cache_data refresh reset reset_cache_data reset_cache_file reset_cache_for search search search_with_source search_with_source set_cache_data system_cache_file system_cache_file try_file update user_cache_file user_cache_file write_cache

### Included Modules

Gem::UserInteraction

### Public Class methods

cache(all = false)

The singleton Gem::SourceInfoCache. If `all` is true, a full refresh will be performed if the singleton instance is being initialized.

cache_data()
latest_system_cache_file()

The name of the system cache file.

latest_user_cache_file()

The name of the latest user cache file.

reset()

Reset all singletons, discarding any changes.

search(*args)

Search all source indexes. See Gem::SourceInfoCache#search.

search_with_source(*args)

Search all source indexes returning the source_uri. See Gem::SourceInfoCache#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.

### Public Instance methods

cache_data()

The most recent cache data.

cache_file()

The name of the cache file.

flush()

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

latest_cache_data()
latest_cache_file()

The name of the latest cache file.

latest_system_cache_file()

The name of the latest system cache file.

latest_user_cache_file()

The name of the latest user cache file.

read_all_cache_data()

Merges the complete cache file into this Gem::SourceInfoCache.

read_cache_data(file)

Reads cached data from `file`.

refresh(all)

Refreshes each source in the cache from its repository. If `all` is false, only latest gems are updated.

reset_cache_data()
reset_cache_file()

Force cache file to be reset, useful for integration testing of rubygems

reset_cache_for(url, cache_data)
search(pattern, platform_only = false, all = false)

Searches all source indexes. See Gem::SourceIndex#search for details on `pattern` and `platform_only`. If `all` is set to true, the full index will be loaded before searching.

search_with_source(pattern, only_platform = false, all = 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.

try_file(path)

Determine if `path` is a candidate for a cache file. Returns `path` if it is, nil if not.

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 files.

[Validate]