Class: Gemstash::Storage
- Inherits:
-
Object
- Object
- Gemstash::Storage
- Extended by:
- Env::Helper
- Defined in:
- lib/gemstash/storage.rb
Overview
The entry point into the storage engine for storing cached gems, specs, and private gems.
Defined Under Namespace
Classes: VersionTooNew
Constant Summary collapse
- VERSION =
1
Class Method Summary collapse
-
.for(name) ⇒ Gemstash::Storage
Fetch a base entry in the storage engine.
-
.metadata ⇒ Hash
Read the global metadata for Gemstash and the storage engine.
Instance Method Summary collapse
-
#for(child) ⇒ Gemstash::Storage
Fetch a nested entry from this instance in the storage engine.
-
#initialize(folder, root: true) ⇒ Storage
constructor
This object should not be constructed directly, but instead via Storage.for and #for.
-
#resource(id) ⇒ Gemstash::Resource
Fetch the resource with the given
id
within this storage.
Constructor Details
Class Method Details
.for(name) ⇒ Gemstash::Storage
Fetch a base entry in the storage engine.
51 52 53 |
# File 'lib/gemstash/storage.rb', line 51 def self.for(name) new(gemstash_env.base_file(name)) end |
.metadata ⇒ Hash
Read the global metadata for Gemstash and the storage engine. If the metadata hasn’t been stored yet, it will be created.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/gemstash/storage.rb', line 59 def self. file = gemstash_env.base_file("metadata.yml") unless File.exist?(file) File.write(file, { storage_version: Gemstash::Storage::VERSION, gemstash_version: Gemstash::VERSION }.to_yaml) end YAML.load_file(file) end |
Instance Method Details
#for(child) ⇒ Gemstash::Storage
Fetch a nested entry from this instance in the storage engine.
43 44 45 |
# File 'lib/gemstash/storage.rb', line 43 def for(child) Storage.new(File.join(@folder, child), root: false) end |
#resource(id) ⇒ Gemstash::Resource
Fetch the resource with the given id
within this storage.
35 36 37 |
# File 'lib/gemstash/storage.rb', line 35 def resource(id) Resource.new(@folder, id) end |