Class: Capsium::Registry::Local
- Inherits:
-
Registry
- Object
- Registry
- Capsium::Registry::Local
- Defined in:
- lib/capsium/registry/local.rb,
sig/capsium/registry/local.rbs
Overview
A static registry in a local directory (read-write).
Instance Attribute Summary collapse
-
#dir ⇒ String
readonly
Returns the value of attribute dir.
Instance Method Summary collapse
-
#initialize(dir) ⇒ Local
constructor
A new instance of Local.
- #location ⇒ String
-
#push(cap_path) ⇒ Entry
Validates cap_path, copies it into the registry and records it in index.json.
Constructor Details
#initialize(dir) ⇒ Local
Returns a new instance of Local.
16 17 18 19 20 21 22 23 |
# File 'lib/capsium/registry/local.rb', line 16 def initialize(dir) super() if File.exist?(dir) && !File.directory?(dir) raise InvalidRegistryError, "registry path is not a directory: #{dir}" end @dir = dir end |
Instance Attribute Details
#dir ⇒ String (readonly)
Returns the value of attribute dir.
14 15 16 |
# File 'lib/capsium/registry/local.rb', line 14 def dir @dir end |
Instance Method Details
#location ⇒ String
25 |
# File 'lib/capsium/registry/local.rb', line 25 def location = dir |
#push(cap_path) ⇒ Entry
Validates cap_path, copies it into the registry and records it in index.json. Returns the recorded Entry.
31 32 33 34 35 36 37 38 |
# File 'lib/capsium/registry/local.rb', line 31 def push(cap_path) validate_package!(cap_path) entry = build_entry((cap_path), cap_path) FileUtils.mkdir_p(dir) atomic_copy(cap_path, File.join(dir, entry.file)) record(entry) entry end |