ruby-win32/lib/ruby/site_ruby/1.8/rubygems/source_info_cache.rb
# The most recent cache data.
The most recent cache data.
The most recent cache data .
def cache_data
    return @cache_data if @cache_data
    cache_file 
    begin
      data = File.open cache_file, 'rb' do |fp| fp.read end
      @cache_data = Marshal.load data
      @cache_data.each do |url, sice|
        next unless sice.is_a?(Hash)
        update
        cache = sice['cache']
        size  = sice['size']
        if cache.is_a?(Gem::SourceIndex) and size.is_a?(Numeric) then
          new_sice = Gem::SourceInfoCacheEntry.new cache, size
          @cache_data[url] = new_sice
        else 
          reset_cache_for(url)
        end
      end
      @cache_data
    rescue => e
      if Gem.configuration.really_verbose then
        say "Exception during cache_data handling: #{ex.class} - #{ex}"
        say "Cache file was: #{cache_file}"
        say "\t#{e.backtrace.join "\n\t"}"
      end
      reset_cache_data
    end
  end
def cache_data return @cache_data if @cache_data cache_file begin data = File . open cache_file , 'rb' do | fp | fp . read end @cache_data = Marshal . load data @cache_data . each do | url , sice | next unless sice . is_a? ( Hash ) update cache = sice [ 'cache' ] size = sice [ 'size' ] if cache . is_a? ( Gem :: SourceIndex ) and size . is_a? ( Numeric ) then new_sice = Gem :: SourceInfoCacheEntry . new cache , size @cache_data [ url ] = new_sice else reset_cache_for ( url ) end end @cache_data rescue => e if Gem . configuration . really_verbose then say "Exception during cache_data handling: #{ex.class} - #{ex}" say "Cache file was: #{cache_file}" say "\t#{e.backtrace.join "\n\t"}" end reset_cache_data end end
The most recent cache data.
The most recent cache data .
# HACK writable check # Marshal loads 30-40% faster from a String, and 2MB on 20061116 is small # irreperable, force refetch.