Class: Bundler::CompactIndexClient::Cache
- Inherits:
-
Object
- Object
- Bundler::CompactIndexClient::Cache
- Defined in:
- lib/bundler/compact_index_client/cache.rb
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
Instance Method Summary collapse
- #info(name, remote_checksum = nil) ⇒ Object
-
#initialize(directory, fetcher = nil) ⇒ Cache
constructor
A new instance of Cache.
- #names ⇒ Object
- #reset! ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(directory, fetcher = nil) ⇒ Cache
Returns a new instance of Cache.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bundler/compact_index_client/cache.rb', line 10 def initialize(directory, fetcher = nil) @directory = Pathname.new(directory). @updater = Updater.new(fetcher) if fetcher @mutex = Thread::Mutex.new @endpoints = Set.new @info_root = mkdir("info") @special_characters_info_root = mkdir("info-special-characters") @info_etag_root = mkdir("info-etags") end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
8 9 10 |
# File 'lib/bundler/compact_index_client/cache.rb', line 8 def directory @directory end |
Instance Method Details
#info(name, remote_checksum = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/bundler/compact_index_client/cache.rb', line 29 def info(name, remote_checksum = nil) path = info_path(name) if remote_checksum && remote_checksum != SharedHelpers.checksum_for_file(path, :MD5) fetch("info/#{name}", path, info_etag_path(name)) else Bundler::CompactIndexClient.debug { "update skipped info/#{name} (#{remote_checksum ? "versions index checksum is nil" : "versions index checksum matches local"})" } read(path) end end |
#names ⇒ Object
21 22 23 |
# File 'lib/bundler/compact_index_client/cache.rb', line 21 def names fetch("names", names_path, names_etag_path) end |
#reset! ⇒ Object
40 41 42 |
# File 'lib/bundler/compact_index_client/cache.rb', line 40 def reset! @mutex.synchronize { @endpoints.clear } end |
#versions ⇒ Object
25 26 27 |
# File 'lib/bundler/compact_index_client/cache.rb', line 25 def versions fetch("versions", versions_path, versions_etag_path) end |