Class: Gem::Guardian::ArtifactStore
- Inherits:
-
Object
- Object
- Gem::Guardian::ArtifactStore
- Defined in:
- lib/gem/guardian/artifact_store.rb
Overview
Stores downloaded gem artifacts in a local cache directory.
Instance Method Summary collapse
-
#initialize(client:, cache_dir: File.join(Dir.tmpdir, "gem-guardian")) ⇒ ArtifactStore
constructor
A new instance of ArtifactStore.
-
#path_for(dependency) ⇒ Object
Returns the local path for +dependency+, downloading it if needed.
Constructor Details
#initialize(client:, cache_dir: File.join(Dir.tmpdir, "gem-guardian")) ⇒ ArtifactStore
Returns a new instance of ArtifactStore.
12 13 14 15 |
# File 'lib/gem/guardian/artifact_store.rb', line 12 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
Returns the local path for +dependency+, downloading it if needed.
18 19 20 21 22 23 24 |
# File 'lib/gem/guardian/artifact_store.rb', line 18 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 |