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/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/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/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/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/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/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, Preparation, Testing, Verification Classes: Authentication, AuthenticationConfig, AuthenticationData, BasicAuthConfig, Cipher, CircularDependencyError, Dataset, DatasetConfig, DependencyError, DependencyNotFoundError, DependencyResolver, DependencyVisibilityError, DigitalSignatures, EncryptionConfig, EncryptionEnvelope, IntegrityChecks, LayerConfig, Manifest, ManifestConfig, MergedView, Metadata, MetadataData, OAuth2Config, 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, dependency_chain: []) ⇒ Object
constructor
Loads a package directory or .cap file.
- #load_package ⇒ void
-
#merged_view(exported_only: false) ⇒ 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, dependency_chain: []) ⇒ 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. dependency_chain is internal: the ancestor GUIDs
used for circular-dependency detection during recursive resolution.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/capsium/package.rb', line 78 def initialize(path, load_type: nil, decryption_key: nil, store: nil, dependency_chain: []) @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, dependency_chain) validate_dependency_references! verify_integrity! verify_signature! end |
Instance Attribute Details
#authentication ⇒ Authentication (readonly)
Returns the value of attribute authentication.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def authentication @authentication end |
#load_type ⇒ Symbol (readonly)
Returns the value of attribute load_type.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def load_type @load_type end |
#manifest ⇒ Manifest (readonly)
Returns the value of attribute manifest.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def manifest @manifest end |
#metadata ⇒ Metadata (readonly)
Returns the value of attribute metadata.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def @metadata end |
#name ⇒ String (readonly)
Returns the value of attribute name.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def name @name end |
#path ⇒ String (readonly)
Returns the value of attribute path.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def path @path end |
#resolved_dependencies ⇒ Array[ResolvedDependency] (readonly)
Returns the value of attribute resolved_dependencies.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def resolved_dependencies @resolved_dependencies end |
#routes ⇒ Routes (readonly)
Returns the value of attribute routes.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def routes @routes end |
#security ⇒ Security (readonly)
Returns the value of attribute security.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 def security @security end |
#storage ⇒ Storage (readonly)
Returns the value of attribute storage.
60 61 62 |
# File 'lib/capsium/package.rb', line 60 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.
132 133 134 |
# File 'lib/capsium/package.rb', line 132 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.
46 47 48 49 |
# File 'sig/capsium/package.rbs', line 46 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]
136 137 138 |
# File 'lib/capsium/package.rb', line 136 def content_files Dir.glob(File.join(content_path, "**", "*")).select { |file| File.file?(file) } end |
#datasets ⇒ Array[Dataset]
117 |
# File 'lib/capsium/package.rb', line 117 def datasets = storage.datasets |
#load_package ⇒ void
This method returns an undefined value.
100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/capsium/package.rb', line 100 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) ⇒ 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.
122 123 124 125 126 127 128 |
# File 'lib/capsium/package.rb', line 122 def merged_view(exported_only: false) @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.
93 94 95 96 97 98 |
# File 'lib/capsium/package.rb', line 93 def solidify @manifest.save_to_file @metadata.save_to_file @routes.save_to_file @storage.save_to_file unless @storage.empty? end |