1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
require 'rubygems'
require 'rubygems/source_index'
require 'rubygems/remote_fetcher'
##
# Entries held by a SourceInfoCache.
class Gem::SourceInfoCacheEntry
##
# The source index for this cache entry.
attr_reader :source_index
##
# The size of the source entry. Used to determine if the source index has
# changed.
attr_reader :size
##
# Create a cache entry.
def initialize(si, size)
@source_index = si || Gem::SourceIndex.new({})
@size = size
@all = false
end
def refresh(source_uri, all)
begin
marshal_uri = URI.join source_uri.to_s, "Marshal.#{Gem.marshal_version}"
remote_size = Gem::RemoteFetcher.fetcher.fetch_size marshal_uri
rescue Gem::RemoteSourceException
yaml_uri = URI.join source_uri.to_s, 'yaml'
remote_size = Gem::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
def ==(other) # :nodoc:
self.class === other and
@size == other.size and
@source_index == other.source_index
end
end
|