class Capsium::Registry
A static package registry: a directory or a static https base URL holding an index.json plus .cap files stored relative to the registry root, so any static host (GitHub Pages, S3, nginx) can serve it. Index shape:
{ "packages": { "<guid>": { "name": "story-of-claire",
"versions": { "1.0.0": { "file": "story-of-claire-1.0.0.cap",
"sha256": "<hex>", "size": 642047 } } } } }
Registry.fetch(ref) returns the implementation for a reference: a Local directory (read-write) or a Remote http(s) base URL (read-only). Both resolve and install; only Local pushes.
Constants
- ENV_VAR
- Entry
-
One indexed version of a registry package.
- INDEX_FILE
Public Class Methods
() → Registry?
Source
# File lib/capsium/registry.rb, line 72 def default ref = ENV.fetch(ENV_VAR, nil) ref.nil? || ref.empty? ? nil : fetch(ref) end
The registry named by the CAPSIUM_REGISTRY environment variable, or nil when unset.
(String? ref) → Registry
Source
# File lib/capsium/registry.rb, line 61 def fetch(ref) if ref.nil? || ref.to_s.empty? raise RegistryNotConfiguredError, "no registry configured (pass --registry or set #{ENV_VAR})" end ref.to_s.match?(%r{\Ahttps?://}) ? Remote.new(ref.to_s) : Local.new(ref.to_s) end
The registry at the given reference: a Local directory or a Remote http(s) base URL. Raises RegistryNotConfiguredError when no reference is given.
Public Instance Methods
(String guid, ?String constraint, store: Package::Store | String store) → String
Source
# File lib/capsium/registry.rb, line 104 def install(guid, constraint = "*", store:) entry = resolve(guid, constraint) with_entry_file(entry) do |path| verify_checksum!(entry, path) store_for(store).install(path, guid: entry.guid, file_name: entry.cap_file_name) end end
Resolves the newest satisfying version, fetches its .cap (verifying the sha256 declared in the index) and installs it into the package store as “<name>-<version>.cap”. Returns the installed store path.
() → String
Source
# File lib/capsium/registry.rb, line 84 def location = raise(NotImplementedError)
Where this registry lives (directory path or base URL), for messages and reports.
(String cap_path) → Entry
Source
# File lib/capsium/registry.rb, line 113 def push(_cap_path) raise RegistryError, "registry is read-only: #{location}" end
(String guid, ?String constraint) → Entry
Source
# File lib/capsium/registry.rb, line 89 def resolve(guid, constraint = "*") listing = packages[guid] raise PackageNotFoundError, "no package #{guid} in registry #{location}" if listing.nil? versions = listing_versions(guid, listing) range = Package::VersionRange.parse(constraint) satisfying = versions.keys.select { |version| range.satisfied_by?(version) } raise_unsatisfiable(guid, constraint, versions) if satisfying.empty? entry_for(guid, listing, satisfying.max) end
The newest indexed version of the package GUID satisfying the semver constraint (default “*”). Raises PackageNotFoundError or UnsatisfiableConstraintError.