2 require 'rubygems/source_index'
3 require 'rubygems/remote_fetcher'
6 # Entries held by a SourceInfoCache.
8 class Gem::SourceInfoCacheEntry
11 # The source index for this cache entry.
13 attr_reader :source_index
16 # The size of the of the source entry. Used to determine if the
17 # source index has changed.
22 # Create a cache entry.
24 def initialize(si, size)
25 @source_index = si || Gem::SourceIndex.new({})
30 def refresh(source_uri, all)
32 marshal_uri = URI.join source_uri.to_s, "Marshal.#{Gem.marshal_version}"
33 remote_size = Gem::RemoteFetcher.fetcher.fetch_size marshal_uri
34 rescue Gem::RemoteSourceException
35 yaml_uri = URI.join source_uri.to_s, 'yaml'
36 remote_size = Gem::RemoteFetcher.fetcher.fetch_size yaml_uri
39 # TODO Use index_signature instead of size?
40 return false if @size == remote_size and @all
42 updated = @source_index.update source_uri, all
49 def ==(other) # :nodoc:
50 self.class === other and
51 @size == other.size and
52 @source_index == other.source_index