Module: Ibex::GenerationManifest
- Defined in:
- lib/ibex/generation_manifest.rb,
sig/ibex/generation_manifest.rbs
Overview
Deterministic description of one published parser generation.
Constant Summary collapse
- SCHEMA_VERSION =
1- IDENTIFIER =
"generation"- ROOT_KEYS =
%w[ibex_manifest schema_version input options artifacts].freeze
- INPUT_KEYS =
%w[root sha256 files].freeze
- FILE_KEYS =
%w[path sha256 bytesize].freeze
- ARTIFACT_KEYS =
%w[kind path sha256 bytesize].freeze
Class Method Summary collapse
- .render(artifacts, source_records:, options:) ⇒ Object
-
.validate(source, verify_artifacts: true) ⇒ Object
Validate the manifest shape and, by default, every published artifact digest.
- .validate_file(path, verify_artifacts: true) ⇒ Object
Instance Method Summary collapse
- #self?.artifact_entry ⇒ Hash[String, untyped]
- #self?.exact_keys! ⇒ void
- #self?.input_digest ⇒ String
- #self?.render ⇒ String
- #self?.sorted_hash ⇒ Hash[String, untyped]
-
#self?.validate ⇒ Hash[String, untyped]
Validate the manifest shape and, by default, every published artifact digest.
- #self?.validate_digest ⇒ void
- #self?.validate_document ⇒ void
- #self?.validate_entries ⇒ void
- #self?.validate_entry ⇒ void
- #self?.validate_file ⇒ Hash[String, untyped]
- #self?.validate_identity ⇒ void
- #self?.validate_input ⇒ void
- #self?.validate_kind ⇒ void
- #self?.validate_path ⇒ void
- #self?.verify_entries ⇒ void
Class Method Details
.render(artifacts, source_records:, options:) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/ibex/generation_manifest.rb', line 20 def render(artifacts, source_records:, options:) files = source_records.map(&:to_h) document = { "ibex_manifest" => IDENTIFIER, "schema_version" => SCHEMA_VERSION, "input" => { "root" => files.fetch(0).fetch("path"), "sha256" => input_digest(files), "files" => files }, "options" => sorted_hash(), "artifacts" => artifacts.map { |artifact| artifact_entry(artifact) } } "#{JSON.pretty_generate(document)}\n" end |
.validate(source, verify_artifacts: true) ⇒ Object
Validate the manifest shape and, by default, every published artifact digest.
38 39 40 41 42 43 44 45 |
# File 'lib/ibex/generation_manifest.rb', line 38 def validate(source, verify_artifacts: true) document = JSON.parse(source) validate_document(document) verify_entries(document.fetch("artifacts")) if verify_artifacts document rescue JSON::ParserError, KeyError, TypeError, ArgumentError => e raise Ibex::Error, "(manifest):1:1: invalid generation manifest: #{e.}" end |
.validate_file(path, verify_artifacts: true) ⇒ Object
48 49 50 51 52 |
# File 'lib/ibex/generation_manifest.rb', line 48 def validate_file(path, verify_artifacts: true) validate(File.binread(path), verify_artifacts: verify_artifacts) rescue SystemCallError, ArgumentError => e raise Ibex::Error, "#{path}:1:1: cannot read generation manifest: #{e.}" end |
Instance Method Details
#self?.artifact_entry ⇒ Hash[String, untyped]
29 |
# File 'sig/ibex/generation_manifest.rbs', line 29
def self?.artifact_entry: (Artifact artifact) -> Hash[String, untyped]
|
#self?.exact_keys! ⇒ void
This method returns an undefined value.
62 |
# File 'sig/ibex/generation_manifest.rbs', line 62
def self?.exact_keys!: (Hash[untyped, untyped] value, Array[String] expected, String label) -> void
|
#self?.input_digest ⇒ String
32 |
# File 'sig/ibex/generation_manifest.rbs', line 32
def self?.input_digest: (Array[Hash[String, untyped]] files) -> String
|
#self?.render ⇒ String
19 |
# File 'sig/ibex/generation_manifest.rbs', line 19
def self?.render: (ArtifactSet artifacts, source_records: Array[GenerationInput], options: Hash[String, untyped]) -> String
|
#self?.sorted_hash ⇒ Hash[String, untyped]
35 |
# File 'sig/ibex/generation_manifest.rbs', line 35
def self?.sorted_hash: (Hash[String, untyped] value) -> Hash[String, untyped]
|
#self?.validate ⇒ Hash[String, untyped]
Validate the manifest shape and, by default, every published artifact digest.
23 |
# File 'sig/ibex/generation_manifest.rbs', line 23
def self?.validate: (String source, ?verify_artifacts: bool) -> Hash[String, untyped]
|
#self?.validate_digest ⇒ void
This method returns an undefined value.
59 |
# File 'sig/ibex/generation_manifest.rbs', line 59
def self?.validate_digest: (untyped digest, String label) -> void
|
#self?.validate_document ⇒ void
This method returns an undefined value.
38 |
# File 'sig/ibex/generation_manifest.rbs', line 38
def self?.validate_document: (untyped document) -> void
|
#self?.validate_entries ⇒ void
This method returns an undefined value.
47 |
# File 'sig/ibex/generation_manifest.rbs', line 47
def self?.validate_entries: (Array[untyped] entries, String label, ?require_kind: bool) -> void
|
#self?.validate_entry ⇒ void
This method returns an undefined value.
50 |
# File 'sig/ibex/generation_manifest.rbs', line 50
def self?.validate_entry: (untyped entry, String label, bool require_kind) -> void
|
#self?.validate_file ⇒ Hash[String, untyped]
26 |
# File 'sig/ibex/generation_manifest.rbs', line 26
def self?.validate_file: (String path, ?verify_artifacts: bool) -> Hash[String, untyped]
|
#self?.validate_identity ⇒ void
This method returns an undefined value.
41 |
# File 'sig/ibex/generation_manifest.rbs', line 41
def self?.validate_identity: (Hash[untyped, untyped] document) -> void
|
#self?.validate_input ⇒ void
This method returns an undefined value.
44 |
# File 'sig/ibex/generation_manifest.rbs', line 44
def self?.validate_input: (untyped input) -> void
|
#self?.validate_kind ⇒ void
This method returns an undefined value.
56 |
# File 'sig/ibex/generation_manifest.rbs', line 56
def self?.validate_kind: (untyped kind, String label) -> void
|
#self?.validate_path ⇒ void
This method returns an undefined value.
53 |
# File 'sig/ibex/generation_manifest.rbs', line 53
def self?.validate_path: (untyped path, String label) -> void
|
#self?.verify_entries ⇒ void
This method returns an undefined value.
65 |
# File 'sig/ibex/generation_manifest.rbs', line 65
def self?.verify_entries: (Array[untyped] entries) -> void
|