Sha256: 76c7f4441960f39f3bef4d968f59807c7e35fdb19b44589c2406d5d1a98a6f07

Contents?: true

Size: 1.18 KB

Versions: 9

Compression:

Stored size: 1.18 KB

Contents

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 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

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
shoesgem-0.1514.0 shoes/ruby/lib/rubygems/source_info_cache_entry.rb
shoesgem-0.1480.0 shoes/ruby/lib/rubygems/source_info_cache_entry.rb
shoesgem-0.1469.0 shoes/ruby/lib/rubygems/source_info_cache_entry.rb
shoesgem-0.1424.0 shoes/ruby/lib/rubygems/source_info_cache_entry.rb
rubygems-update-1.1.0 lib/rubygems/source_info_cache_entry.rb
rubygems-update-1.3.0 lib/rubygems/source_info_cache_entry.rb
rubygems-update-1.2.0 lib/rubygems/source_info_cache_entry.rb
rubygems-update-1.3.1 lib/rubygems/source_info_cache_entry.rb
rubygems-update-1.1.1 lib/rubygems/source_info_cache_entry.rb