Class: Capsium::Package
- Inherits:
-
Object
- Object
- Capsium::Package
- Includes:
- Composition, Preparation, Verification
- Defined in:
- sig/capsium/package.rbs,
lib/capsium/package.rb,
lib/capsium/package/store.rb,
lib/capsium/package/bundle.rb,
lib/capsium/package/cipher.rb,
lib/capsium/package/routes.rb,
lib/capsium/package/signer.rb,
lib/capsium/package/dataset.rb,
lib/capsium/package/storage.rb,
lib/capsium/package/testing.rb,
lib/capsium/package/version.rb,
lib/capsium/package/manifest.rb,
lib/capsium/package/metadata.rb,
lib/capsium/package/open_pgp.rb,
lib/capsium/package/security.rb,
lib/capsium/package/validator.rb,
lib/capsium/package/composition.rb,
lib/capsium/package/merged_view.rb,
lib/capsium/package/preparation.rb,
lib/capsium/package/verification.rb,
lib/capsium/package/routes_config.rb,
lib/capsium/package/authentication.rb,
lib/capsium/package/storage_config.rb,
lib/capsium/package/testing/report.rb,
lib/capsium/package/manifest_config.rb,
lib/capsium/package/metadata_config.rb,
lib/capsium/package/open_pgp_cipher.rb,
lib/capsium/package/open_pgp_signer.rb,
lib/capsium/package/security_config.rb,
lib/capsium/package/testing/context.rb,
lib/capsium/package/encryption_config.rb,
lib/capsium/package/testing/file_test.rb,
lib/capsium/package/testing/test_case.rb,
lib/capsium/package/testing/route_test.rb,
lib/capsium/package/testing/test_suite.rb,
lib/capsium/package/dependency_resolver.rb,
lib/capsium/package/testing/config_test.rb,
lib/capsium/package/authentication_config.rb,
lib/capsium/package/testing/data_validation_test.rb,
sig/capsium/package/store.rbs,
sig/capsium/package/bundle.rbs,
sig/capsium/package/cipher.rbs,
sig/capsium/package/routes.rbs,
sig/capsium/package/signer.rbs,
sig/capsium/package/dataset.rbs,
sig/capsium/package/storage.rbs,
sig/capsium/package/testing.rbs,
sig/capsium/package/version.rbs,
sig/capsium/package/manifest.rbs,
sig/capsium/package/metadata.rbs,
sig/capsium/package/open_pgp.rbs,
sig/capsium/package/security.rbs,
sig/capsium/package/validator.rbs,
sig/capsium/package/composition.rbs,
sig/capsium/package/merged_view.rbs,
sig/capsium/package/preparation.rbs,
sig/capsium/package/verification.rbs,
sig/capsium/package/routes_config.rbs,
sig/capsium/package/authentication.rbs,
sig/capsium/package/storage_config.rbs,
sig/capsium/package/testing/report.rbs,
sig/capsium/package/manifest_config.rbs,
sig/capsium/package/metadata_config.rbs,
sig/capsium/package/open_pgp_cipher.rbs,
sig/capsium/package/open_pgp_signer.rbs,
sig/capsium/package/security_config.rbs,
sig/capsium/package/testing/context.rbs,
sig/capsium/package/encryption_config.rbs,
sig/capsium/package/testing/file_test.rbs,
sig/capsium/package/testing/test_case.rbs,
sig/capsium/package/testing/route_test.rbs,
sig/capsium/package/testing/test_suite.rbs,
sig/capsium/package/dependency_resolver.rbs,
sig/capsium/package/testing/config_test.rbs,
sig/capsium/package/authentication_config.rbs,
sig/capsium/package/testing/data_validation_test.rbs
Overview
A Capsium package loaded from a directory or a .cap file (ARCHITECTURE.md section 1).
Defined Under Namespace
Modules: Composition, OpenPgp, Preparation, Testing, Verification Classes: Authentication, AuthenticationConfig, AuthenticationData, BasicAuthConfig, Bundle, Cipher, CircularDependencyError, Dataset, DatasetConfig, DependencyError, DependencyNotFoundError, DependencyResolver, DependencyVisibilityError, DigitalSignatures, EncryptionConfig, EncryptionEnvelope, IntegrityChecks, LayerConfig, Manifest, ManifestConfig, MergedView, Metadata, MetadataData, OAuth2Config, OpenPgpCipher, OpenPgpSigner, Repository, ResolvedDependency, Resource, ResponseRewrite, Route, Routes, RoutesConfig, Security, SecurityConfig, SecurityData, Signer, Storage, StorageConfig, StorageData, Store, UnsatisfiableDependencyError, Validator, Version, VersionRange
Constant Summary collapse
- MANIFEST_FILE =
"manifest.json"- METADATA_FILE =
"metadata.json"- STORAGE_FILE =
"storage.json"- ROUTES_FILE =
"routes.json"- SECURITY_FILE =
"security.json"- SIGNATURE_FILE =
"signature.sig"- AUTHENTICATION_FILE =
"authentication.json"- CONTENT_DIR =
"content"- DATA_DIR =
"data"
Instance Attribute Summary collapse
-
#authentication ⇒ Authentication
readonly
Returns the value of attribute authentication.
-
#load_type ⇒ Symbol
readonly
Returns the value of attribute load_type.
-
#manifest ⇒ Manifest
readonly
Returns the value of attribute manifest.
-
#metadata ⇒ Metadata
readonly
Returns the value of attribute metadata.
-
#name ⇒ String
readonly
Returns the value of attribute name.
-
#path ⇒ String
readonly
Returns the value of attribute path.
-
#resolved_dependencies ⇒ Array[ResolvedDependency]
readonly
Returns the value of attribute resolved_dependencies.
-
#routes ⇒ Routes
readonly
Returns the value of attribute routes.
-
#security ⇒ Security
readonly
Returns the value of attribute security.
-
#storage ⇒ Storage
readonly
Returns the value of attribute storage.
Instance Method Summary collapse
-
#cap_file_path ⇒ String?
The .cap file this package was loaded from, or nil when loaded from a directory.
-
#cleanup ⇒ void
Removes the temporary extraction directories of the package and its resolved dependencies; a no-op for directory loads.
- #content_files ⇒ Array[String]
- #datasets ⇒ Array[Dataset]
-
#initialize(path, load_type: nil, decryption_key: nil, store: nil, registry: nil, dependency_chain: [], bundle: nil) ⇒ Object
constructor
Loads a package directory or .cap file.
- #load_package ⇒ void
-
#merged_view(exported_only: false, extra_layers: []) ⇒ MergedView
The merged content view across the storage layers (ARCHITECTURE.md section 5a); exported_only gives the dependent-package view (section 4a).
- #solidify ⇒ void
Methods included from Preparation
#decompress_cap_file, #decrypt_cap_file, #determine_load_type, #encrypted?, #prepare_package
Methods included from Composition
#dependency_for, #dependency_views, #resolve_dependencies, #validate_dependency_reference, #validate_dependency_references!
Methods included from Verification
#signed?, #verify_integrity, #verify_integrity!, #verify_signature, #verify_signature!
Constructor Details
#initialize(path, load_type: nil, decryption_key: nil, store: nil, registry: nil, dependency_chain: [], bundle: nil) ⇒ Object
Loads a package directory or .cap file. Composite packages
(metadata.dependencies, ARCHITECTURE.md section 4a) resolve against
the package store given as store (directory path or Store) or via
CAPSIUM_STORE, falling back to the registry given as registry
or via CAPSIUM_REGISTRY when the store has no package for a
dependency GUID. dependency_chain is internal: the ancestor GUIDs
used for circular-dependency detection during recursive resolution.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/capsium/package.rb', line 88 def initialize(path, load_type: nil, decryption_key: nil, store: nil, registry: nil, dependency_chain: [], bundle: nil) @decryption_key = decryption_key @original_path = Pathname.new(path). @path = prepare_package(@original_path).to_s @load_type = load_type || determine_load_type(path) create_package_structure load_package @name = .name @resolved_dependencies = resolve_dependencies(store, registry, dependency_chain, bundle) validate_dependency_references! verify_integrity! verify_signature! end |
Instance Attribute Details
#authentication ⇒ Authentication (readonly)
Returns the value of attribute authentication.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def authentication @authentication end |
#load_type ⇒ Symbol (readonly)
Returns the value of attribute load_type.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def load_type @load_type end |
#manifest ⇒ Manifest (readonly)
Returns the value of attribute manifest.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def manifest @manifest end |
#metadata ⇒ Metadata (readonly)
Returns the value of attribute metadata.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def @metadata end |
#name ⇒ String (readonly)
Returns the value of attribute name.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def name @name end |
#path ⇒ String (readonly)
Returns the value of attribute path.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def path @path end |
#resolved_dependencies ⇒ Array[ResolvedDependency] (readonly)
Returns the value of attribute resolved_dependencies.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def resolved_dependencies @resolved_dependencies end |
#routes ⇒ Routes (readonly)
Returns the value of attribute routes.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def routes @routes end |
#security ⇒ Security (readonly)
Returns the value of attribute security.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def security @security end |
#storage ⇒ Storage (readonly)
Returns the value of attribute storage.
64 65 66 |
# File 'lib/capsium/package.rb', line 64 def storage @storage end |
Instance Method Details
#cap_file_path ⇒ String?
The .cap file this package was loaded from, or nil when loaded from a directory.
151 152 153 |
# File 'lib/capsium/package.rb', line 151 def cap_file_path @original_path.to_s if load_type == :cap_file end |
#cleanup ⇒ void
This method returns an undefined value.
Removes the temporary extraction directories of the package and its resolved dependencies; a no-op for directory loads.
50 51 52 53 |
# File 'sig/capsium/package.rbs', line 50 def cleanup @resolved_dependencies.each { |dependency| dependency.package.cleanup } FileUtils.remove_entry(@path) if @path != @original_path.to_s && File.directory?(@path) end |
#content_files ⇒ Array[String]
155 156 157 |
# File 'lib/capsium/package.rb', line 155 def content_files Dir.glob(File.join(content_path, "**", "*")).select { |file| File.file?(file) } end |
#datasets ⇒ Array[Dataset]
127 |
# File 'lib/capsium/package.rb', line 127 def datasets = storage.datasets |
#load_package ⇒ void
This method returns an undefined value.
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/capsium/package.rb', line 110 def load_package # Mandatory @metadata = Metadata.new() # Optional @manifest = Manifest.new(manifest_path) @storage = Storage.new(storage_path) @routes = Routes.new(routes_path, @manifest, @storage) @security = Security.new(security_path) @authentication = Authentication.new(authentication_path) end |
#merged_view(exported_only: false, extra_layers: []) ⇒ MergedView
The merged content view across the storage layers (ARCHITECTURE.md section 5a); exported_only gives the dependent-package view (section 4a). Resolved dependencies act as read-only layers below all own layers. extra_layers stack above everything (the reactor's writable overlay).
134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/capsium/package.rb', line 134 def merged_view(exported_only: false, extra_layers: []) unless extra_layers.empty? return MergedView.new(@path, storage: @storage, manifest: @manifest, dependency_views: dependency_views, exported_only: exported_only, extra_layers: extra_layers) end @merged_views ||= {} @merged_views[exported_only] ||= MergedView.new(@path, storage: @storage, manifest: @manifest, dependency_views: dependency_views, exported_only: exported_only) end |
#solidify ⇒ void
This method returns an undefined value.
103 104 105 106 107 108 |
# File 'lib/capsium/package.rb', line 103 def solidify @manifest.save_to_file @metadata.save_to_file @routes.save_to_file @storage.save_to_file unless @storage.empty? end |