Class: Gem::SourceInfoCacheEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/rubygems/source_info_cache_entry.rb

Overview

Entrys held by a SourceInfoCache.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(si, size) ⇒ SourceInfoCacheEntry

Create a cache entry.



18
19
20
21
# File 'lib/rubygems/source_info_cache_entry.rb', line 18

def initialize(si, size)
  @source_index = si || Gem::SourceIndex.new({})
  @size = size
end

Instance Attribute Details

#sizeObject (readonly)

The size of the of the source entry. Used to determine if the source index has changed.



15
16
17
# File 'lib/rubygems/source_info_cache_entry.rb', line 15

def size
  @size
end

#source_indexObject (readonly)

The source index for this cache entry.



11
12
13
# File 'lib/rubygems/source_info_cache_entry.rb', line 11

def source_index
  @source_index
end

Instance Method Details

#refresh(source_uri) ⇒ Object



23
24
25
26
27
28
# File 'lib/rubygems/source_info_cache_entry.rb', line 23

def refresh(source_uri)
  remote_size = Gem::RemoteFetcher.fetcher.fetch_size source_uri + '/yaml'
  return if @size == remote_size # HACK bad check, local cache not YAML
  @source_index.update source_uri
  @size = remote_size
end