Class: Igniter::Contracts::Assembly::Profile
- Inherits:
-
Object
- Object
- Igniter::Contracts::Assembly::Profile
- Defined in:
- lib/igniter/contracts/assembly/profile.rb
Instance Attribute Summary collapse
-
#diagnostics_contributors ⇒ Object
readonly
Returns the value of attribute diagnostics_contributors.
-
#dsl_keywords ⇒ Object
readonly
Returns the value of attribute dsl_keywords.
-
#effects ⇒ Object
readonly
Returns the value of attribute effects.
-
#executors ⇒ Object
readonly
Returns the value of attribute executors.
-
#fingerprint ⇒ Object
readonly
Returns the value of attribute fingerprint.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#normalizers ⇒ Object
readonly
Returns the value of attribute normalizers.
-
#pack_manifests ⇒ Object
readonly
Returns the value of attribute pack_manifests.
-
#runtime_handlers ⇒ Object
readonly
Returns the value of attribute runtime_handlers.
-
#validators ⇒ Object
readonly
Returns the value of attribute validators.
Class Method Summary collapse
- .build_from(kernel) ⇒ Object
- .fingerprint_for(payload) ⇒ Object
- .serialize_for_fingerprint(value) ⇒ Object
Instance Method Summary collapse
- #declared_registry_keys(registry) ⇒ Object
- #dsl_keyword(name) ⇒ Object
- #effect(name) ⇒ Object
- #executor(name) ⇒ Object
-
#initialize(nodes:, dsl_keywords:, validators:, normalizers:, runtime_handlers:, diagnostics_contributors:, pack_manifests:, effects:, executors:, fingerprint:) ⇒ Profile
constructor
A new instance of Profile.
- #node_class(kind) ⇒ Object
- #pack_manifest(name) ⇒ Object
- #pack_names ⇒ Object
- #provided_capabilities ⇒ Object
- #required_capabilities ⇒ Object
- #runtime_handler(kind) ⇒ Object
- #supports_effect?(name) ⇒ Boolean
- #supports_executor?(name) ⇒ Boolean
- #supports_node_kind?(kind) ⇒ Boolean
Constructor Details
#initialize(nodes:, dsl_keywords:, validators:, normalizers:, runtime_handlers:, diagnostics_contributors:, pack_manifests:, effects:, executors:, fingerprint:) ⇒ Profile
Returns a new instance of Profile.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 62 def initialize(nodes:, dsl_keywords:, validators:, normalizers:, runtime_handlers:, diagnostics_contributors:, pack_manifests:, effects:, executors:, fingerprint:) @nodes = nodes @dsl_keywords = dsl_keywords @validators = validators @normalizers = normalizers @runtime_handlers = runtime_handlers @diagnostics_contributors = diagnostics_contributors @pack_manifests = pack_manifests @effects = effects @executors = executors @fingerprint = fingerprint freeze end |
Instance Attribute Details
#diagnostics_contributors ⇒ Object (readonly)
Returns the value of attribute diagnostics_contributors.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def diagnostics_contributors @diagnostics_contributors end |
#dsl_keywords ⇒ Object (readonly)
Returns the value of attribute dsl_keywords.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def dsl_keywords @dsl_keywords end |
#effects ⇒ Object (readonly)
Returns the value of attribute effects.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def effects @effects end |
#executors ⇒ Object (readonly)
Returns the value of attribute executors.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def executors @executors end |
#fingerprint ⇒ Object (readonly)
Returns the value of attribute fingerprint.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def fingerprint @fingerprint end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def nodes @nodes end |
#normalizers ⇒ Object (readonly)
Returns the value of attribute normalizers.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def normalizers @normalizers end |
#pack_manifests ⇒ Object (readonly)
Returns the value of attribute pack_manifests.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def pack_manifests @pack_manifests end |
#runtime_handlers ⇒ Object (readonly)
Returns the value of attribute runtime_handlers.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def runtime_handlers @runtime_handlers end |
#validators ⇒ Object (readonly)
Returns the value of attribute validators.
9 10 11 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 9 def validators @validators end |
Class Method Details
.build_from(kernel) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 20 def self.build_from(kernel) payload = { nodes: kernel.nodes.to_h.freeze, dsl_keywords: kernel.dsl_keywords.to_h.freeze, validators: kernel.validators.entries.freeze, normalizers: kernel.normalizers.entries.freeze, runtime_handlers: kernel.runtime_handlers.to_h.freeze, diagnostics_contributors: kernel.diagnostics_contributors.entries.freeze, pack_manifests: kernel.pack_manifests.dup.freeze, effects: kernel.effects.to_h.freeze, executors: kernel.executors.to_h.freeze } new(**payload, fingerprint: fingerprint_for(payload)) end |
.fingerprint_for(payload) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 36 def self.fingerprint_for(payload) normalized = payload.map do |key, value| serialized = serialize_for_fingerprint(value) [key.to_s, serialized] end Digest::SHA256.hexdigest(normalized.inspect) end |
.serialize_for_fingerprint(value) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 45 def self.serialize_for_fingerprint(value) case value when Hash value.map { |entry_key, entry_value| [entry_key.to_s, entry_value.inspect] } when Array value.map do |entry| if entry.respond_to?(:key) && entry.respond_to?(:value) [entry.key.to_s, entry.value.inspect] else entry.inspect end end else value.inspect end end |
Instance Method Details
#declared_registry_keys(registry) ⇒ Object
125 126 127 128 129 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 125 def declared_registry_keys(registry) pack_manifests .flat_map { |manifest| manifest.declared_keys_for(registry) } .uniq end |
#dsl_keyword(name) ⇒ Object
81 82 83 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 81 def dsl_keyword(name) dsl_keywords.fetch(name.to_sym) end |
#effect(name) ⇒ Object
89 90 91 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 89 def effect(name) effects.fetch(name.to_sym) end |
#executor(name) ⇒ Object
93 94 95 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 93 def executor(name) executors.fetch(name.to_sym) end |
#node_class(kind) ⇒ Object
77 78 79 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 77 def node_class(kind) nodes.fetch(kind.to_sym) end |
#pack_manifest(name) ⇒ Object
113 114 115 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 113 def pack_manifest(name) pack_manifests.find { |manifest| manifest.name == name.to_sym } end |
#pack_names ⇒ Object
109 110 111 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 109 def pack_names pack_manifests.map(&:name) end |
#provided_capabilities ⇒ Object
117 118 119 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 117 def provided_capabilities pack_manifests.flat_map(&:provides_capabilities).uniq end |
#required_capabilities ⇒ Object
121 122 123 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 121 def required_capabilities pack_manifests.flat_map(&:requires_capabilities).uniq end |
#runtime_handler(kind) ⇒ Object
85 86 87 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 85 def runtime_handler(kind) runtime_handlers.fetch(kind.to_sym) end |
#supports_effect?(name) ⇒ Boolean
101 102 103 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 101 def supports_effect?(name) effects.key?(name.to_sym) end |
#supports_executor?(name) ⇒ Boolean
105 106 107 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 105 def supports_executor?(name) executors.key?(name.to_sym) end |
#supports_node_kind?(kind) ⇒ Boolean
97 98 99 |
# File 'lib/igniter/contracts/assembly/profile.rb', line 97 def supports_node_kind?(kind) nodes.key?(kind.to_sym) end |