diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-10 07:48:56 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-10 07:48:56 +0000 |
commit | fbf59bdbea63efd34ccc144e648467d2f52e7345 (patch) | |
tree | 244f0e7ae112cc7dd135e5d1ac24e6c70ba71b4a /lib/rubygems/source_info_cache_entry.rb | |
parent | 7a4aad75356496559460041a6c063bdb736c7236 (diff) | |
download | ruby-fbf59bdbea63efd34ccc144e648467d2f52e7345.tar.gz |
Import RubyGems trunk revision 1493.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/source_info_cache_entry.rb')
-rw-r--r-- | lib/rubygems/source_info_cache_entry.rb | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/rubygems/source_info_cache_entry.rb b/lib/rubygems/source_info_cache_entry.rb new file mode 100644 index 0000000000..02e03ca9db --- /dev/null +++ b/lib/rubygems/source_info_cache_entry.rb @@ -0,0 +1,46 @@ +require 'rubygems' +require 'rubygems/source_index' +require 'rubygems/remote_fetcher' + +## +# Entrys held by a SourceInfoCache. + +class Gem::SourceInfoCacheEntry + + # The source index for this cache entry. + attr_reader :source_index + + # The size of the 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 + end + + def refresh(source_uri) + 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 + + return false if @size == remote_size # TODO Use index_signature instead of size? + updated = @source_index.update source_uri + @size = remote_size + + updated + end + + def ==(other) # :nodoc: + self.class === other and + @size == other.size and + @source_index == other.source_index + end + +end + |