Class: LibGems::SourceInfoCacheEntry
- Inherits:
-
Object
- Object
- LibGems::SourceInfoCacheEntry
- Defined in:
- lib/libgems/source_info_cache_entry.rb
Overview
Entries held by a SourceInfoCache.
Instance Attribute Summary collapse
-
#size ⇒ Object
readonly
The size of the source entry.
-
#source_index ⇒ Object
readonly
The source index for this cache entry.
Instance Method Summary collapse
-
#==(other) ⇒ Object
:nodoc:.
-
#initialize(si, size) ⇒ SourceInfoCacheEntry
constructor
Create a cache entry.
- #refresh(source_uri, all) ⇒ Object
Constructor Details
#initialize(si, size) ⇒ SourceInfoCacheEntry
Create a cache entry.
24 25 26 27 28 |
# File 'lib/libgems/source_info_cache_entry.rb', line 24 def initialize(si, size) @source_index = si || LibGems::SourceIndex.new({}) @size = size @all = false end |
Instance Attribute Details
#size ⇒ Object (readonly)
The size of the source entry. Used to determine if the source index has changed.
19 20 21 |
# File 'lib/libgems/source_info_cache_entry.rb', line 19 def size @size end |
#source_index ⇒ Object (readonly)
The source index for this cache entry.
13 14 15 |
# File 'lib/libgems/source_info_cache_entry.rb', line 13 def source_index @source_index end |
Instance Method Details
#==(other) ⇒ Object
:nodoc:
49 50 51 52 53 |
# File 'lib/libgems/source_info_cache_entry.rb', line 49 def ==(other) # :nodoc: self.class === other and @size == other.size and @source_index == other.source_index end |
#refresh(source_uri, all) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/libgems/source_info_cache_entry.rb', line 30 def refresh(source_uri, all) begin marshal_uri = URI.join source_uri.to_s, "Marshal.#{LibGems.marshal_version}" remote_size = LibGems::RemoteFetcher.fetcher.fetch_size marshal_uri rescue LibGems::RemoteSourceException yaml_uri = URI.join source_uri.to_s, 'yaml' remote_size = LibGems::RemoteFetcher.fetcher.fetch_size yaml_uri end # TODO Use index_signature instead of size? return false if @size == remote_size and @all updated = @source_index.update source_uri, all @size = remote_size @all = all updated end |