Class: Gembrew::ArchiveStore

Inherits:
Object
  • Object
show all
Defined in:
lib/gembrew/archive_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cache_path:, reporter: Reporter.new, command_runner: nil) ⇒ ArchiveStore

Returns a new instance of ArchiveStore.



12
13
14
15
16
17
# File 'lib/gembrew/archive_store.rb', line 12

def initialize(cache_path:, reporter: Reporter.new, command_runner: nil)
  @cache_path = Pathname(cache_path)
  @reporter = reporter
  @command_runner = command_runner || method(:run_command)
  @cache_path.mkpath
end

Instance Attribute Details

#cache_pathObject (readonly)

Returns the value of attribute cache_path.



10
11
12
# File 'lib/gembrew/archive_store.rb', line 10

def cache_path
  @cache_path
end

Instance Method Details

#fetch(name, version, download_path, index: nil, total: nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gembrew/archive_store.rb', line 19

def fetch(name, version, download_path, index: nil, total: nil)
  if (path = locally_cached(name, version))
    report :rubygems_cache, name, version, index: index, total: total
    return path
  end

  if version && (path = gembrew_cached(name, version))
    report :gembrew_cache, name, version, index: index, total: total
    return path
  end

  download name, version, Pathname(download_path), index: index, total: total
end