Module: Igniter::Contracts::Execution::BaselineValidators
- Defined in:
- lib/igniter/contracts/execution/baseline_validators.rb
Class Method Summary collapse
-
.validate_callables(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.validate_dependencies(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- .validate_effect_adapters(operations:, profile:) ⇒ Object
-
.validate_effect_dependencies(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.validate_effect_payload_builders(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.validate_outputs(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.validate_types(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
.validate_uniqueness(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
Class Method Details
.validate_callables(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 51 def validate_callables(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument missing = operations.select { |operation| operation.kind == :compute } .reject { |operation| operation.attributes[:callable].respond_to?(:call) } .map(&:name) return [] if missing.empty? [ValidationFinding.new( code: :missing_compute_callable, message: "compute nodes require a callable: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_dependencies(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 35 def validate_dependencies(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument available = operations.reject(&:output?).map(&:name) missing = operations.select { |operation| operation.kind == :compute } .flat_map { |operation| Array(operation.attributes[:depends_on]) } .map(&:to_sym) .reject { |name| available.include?(name) } .uniq return [] if missing.empty? [ValidationFinding.new( code: :missing_compute_dependencies, message: "compute dependencies are not defined: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_effect_adapters(operations:, profile:) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 93 def validate_effect_adapters(operations:, profile:) missing = operations.select { |operation| operation.kind == :effect } .map { |operation| operation.attributes[:using] } .reject { |effect_name| profile.supports_effect?(effect_name) } .uniq return [] if missing.empty? [ValidationFinding.new( code: :unknown_effect_adapters, message: "effect adapters are not registered in profile: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_effect_dependencies(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 64 def validate_effect_dependencies(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument available = operations.reject(&:output?).map(&:name) missing = operations.select { |operation| operation.kind == :effect } .flat_map { |operation| Array(operation.attributes[:depends_on]) } .map(&:to_sym) .reject { |name| available.include?(name) } .uniq return [] if missing.empty? [ValidationFinding.new( code: :missing_effect_dependencies, message: "effect dependencies are not defined: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_effect_payload_builders(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 80 def validate_effect_payload_builders(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument missing = operations.select { |operation| operation.kind == :effect } .reject { |operation| operation.attributes[:callable].respond_to?(:call) } .map(&:name) return [] if missing.empty? [ValidationFinding.new( code: :missing_effect_payload_builder, message: "effect nodes require a payload callable: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_outputs(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 21 def validate_outputs(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument available = operations.reject(&:output?).map(&:name) missing = operations.select(&:output?) .map(&:name) .reject { |name| available.include?(name) } return [] if missing.empty? [ValidationFinding.new( code: :missing_output_targets, message: "output targets are not defined: #{missing.map(&:to_s).join(", ")}", subjects: missing )] end |
.validate_types(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
107 108 109 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 107 def validate_types(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument [] end |
.validate_uniqueness(operations:, profile: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/igniter/contracts/execution/baseline_validators.rb', line 9 def validate_uniqueness(operations:, profile: nil) # rubocop:disable Lint/UnusedMethodArgument names = operations.reject(&:output?).map(&:name) duplicates = names.group_by(&:itself).select { |_name, entries| entries.length > 1 }.keys return [] if duplicates.empty? [ValidationFinding.new( code: :duplicate_node_names, message: "duplicate node names: #{duplicates.map(&:to_s).join(", ")}", subjects: duplicates )] end |