Class: Capsium::Registry::Local

Inherits:
Registry
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(dir) ⇒ Local

Returns a new instance of Local.

Parameters:

  • dir (String)


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

#dirString (readonly)

Returns the value of attribute dir.

Returns:

  • (String)


14
15
16
# File 'lib/capsium/registry/local.rb', line 14

def dir
  @dir
end

Instance Method Details

#locationString

Returns:

  • (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.

Parameters:

  • cap_path (String)

Returns:



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