Class: Insika::Parity::Criterion
- Inherits:
-
Object
- Object
- Insika::Parity::Criterion
- Defined in:
- lib/insika/parity/criterion.rb
Overview
C5 — the frozen criterion, parsed from the deployment's criterion file. The prose a human reads and the yaml block the machine applies are the SAME file, so there is exactly one place to edit — and the file's WHOLE bytes are hashed, so an edit to the rationale invalidates the frozen rule too, which is correct: the rationale is what makes the numbers reviewable.
Strict by construction: a missing key or an unknown key is refused at load
(ValidationError), and no key has a default — a number the machine filled in
is a number nobody pre-registered.
Defined Under Namespace
Classes: Rule
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
Class Method Summary collapse
-
.load(path) ⇒ Object
Reads the file, extracts the FIRST ```yaml fence, validates STRICTLY.
Instance Method Summary collapse
-
#initialize(rule:, path:, sha:) ⇒ Criterion
constructor
A new instance of Criterion.
- #to_h ⇒ Object
Constructor Details
#initialize(rule:, path:, sha:) ⇒ Criterion
Returns a new instance of Criterion.
29 30 31 32 33 |
# File 'lib/insika/parity/criterion.rb', line 29 def initialize(rule:, path:, sha:) @rule = rule @path = path @sha = sha end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
27 28 29 |
# File 'lib/insika/parity/criterion.rb', line 27 def path @path end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
27 28 29 |
# File 'lib/insika/parity/criterion.rb', line 27 def rule @rule end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
27 28 29 |
# File 'lib/insika/parity/criterion.rb', line 27 def sha @sha end |
Class Method Details
.load(path) ⇒ Object
Reads the file, extracts the FIRST ```yaml fence, validates STRICTLY. Raises Insika::ConfigError when the file is absent or has no block; Insika::ValidationError on an unknown or missing key.
38 39 40 41 42 43 44 |
# File 'lib/insika/parity/criterion.rb', line 38 def self.load(path) bytes = read_bytes(path) block = extract_yaml_block(bytes) parsed = YAML.safe_load(block, permitted_classes: [], aliases: false) rule = build_rule(parsed) new(rule: rule, path: path, sha: "sha256:#{Digest::SHA256.hexdigest(bytes)}") end |
Instance Method Details
#to_h ⇒ Object
46 |
# File 'lib/insika/parity/criterion.rb', line 46 def to_h = @rule.to_h |