Class: Gem::Guardian::ArtifactStore

Inherits:
Object
  • Object
show all
Defined in:
lib/gem/guardian/artifact_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, cache_dir: File.join(Dir.tmpdir, "gem-guardian")) ⇒ ArtifactStore

Returns a new instance of ArtifactStore.



9
10
11
12
# File 'lib/gem/guardian/artifact_store.rb', line 9

def initialize(client:, cache_dir: File.join(Dir.tmpdir, "gem-guardian"))
  @client = client
  @cache_dir = cache_dir
end

Instance Method Details

#path_for(dependency) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/gem/guardian/artifact_store.rb', line 14

def path_for(dependency)
  FileUtils.mkdir_p(@cache_dir)
  path = File.join(@cache_dir, dependency.gem_filename)
  return path if File.file?(path)

  @client.download_gem(dependency, path)
end