class Capsium::Package::DependencyResolver
Orchestrates metadata.dependencies resolution against a package store: circularity checks plus store lookup, with a registry (Capsium::Registry) as install fallback for store misses. Package loads the resolved .cap itself (recursively, with an extended chain).
Attributes
Public Class Methods
(Store | String? store, ?registry: (Capsium::Registry | String)? registry) → void
Source
# File lib/capsium/package/dependency_resolver.rb, line 38 def initialize(store, registry: nil) if store.nil? raise DependencyError, "metadata.dependencies declared but no package store " \ "configured (set CAPSIUM_STORE or pass store:)" end @store = store.is_a?(Store) ? store : Store.new(store.to_s) @registry = if registry.nil? || registry.is_a?(Capsium::Registry) registry else Capsium::Registry.fetch(registry) end @registry ||= Capsium::Registry.default end
Public Instance Methods
(String guid, String range, chain: Array[String] chain) → String
Source
# File lib/capsium/package/dependency_resolver.rb, line 61 def resolve_path(guid, range, chain:) if chain.include?(guid) raise CircularDependencyError, "circular dependency: #{(chain + [guid]).join(' -> ')}" end @store.find(guid, range) rescue DependencyNotFoundError => e resolve_from_registry(guid, range, e) end
The newest store .cap satisfying the dependency. Falls back to installing from the configured registry when the store has no package for the GUID. Raises CircularDependencyError when the GUID is already being resolved up-chain, DependencyNotFoundError when neither the store nor a registry provides it and UnsatisfiableDependencyError when no available version satisfies the range.