Module: Ibex::GenerationManifest
- Defined in:
- lib/ibex/generation_manifest.rb,
sig/ibex/generation_manifest.rbs
Overview
Deterministic description of one published parser generation. rubocop:disable Metrics/ModuleLength -- manifest schema validation is kept in one auditable unit.
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, json_value]
- #self?.exact_keys! ⇒ void
- #self?.input_digest ⇒ String
- #self?.render ⇒ String
- #self?.sorted_hash ⇒ Hash[String, Object?]
-
#self?.validate ⇒ Hash[String, json_value]
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, json_value]
- #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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ibex/generation_manifest.rb', line 24 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.
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ibex/generation_manifest.rb', line 42 def validate(source, verify_artifacts: true) document = JSON.parse(source) #: Object? validate_document(document) document_hash = document #: Hash[String, json_value] artifacts = document_hash.fetch("artifacts") #: Array[Object?] verify_entries(artifacts) if verify_artifacts document_hash 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
54 55 56 57 58 |
# File 'lib/ibex/generation_manifest.rb', line 54 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, json_value]
32 |
# File 'sig/ibex/generation_manifest.rbs', line 32
def self?.artifact_entry: (Artifact artifact) -> Hash[String, json_value]
|
#self?.exact_keys! ⇒ void
This method returns an undefined value.
65 |
# File 'sig/ibex/generation_manifest.rbs', line 65
def self?.exact_keys!: (Hash[Object?, Object?] value, Array[String] expected, String label) -> void
|
#self?.input_digest ⇒ String
35 |
# File 'sig/ibex/generation_manifest.rbs', line 35
def self?.input_digest: (Array[Hash[String, json_value]] files) -> String
|
#self?.render ⇒ String
22 |
# File 'sig/ibex/generation_manifest.rbs', line 22
def self?.render: (ArtifactSet artifacts, source_records: Array[GenerationInput], options: Hash[String, Object?]) -> String
|
#self?.sorted_hash ⇒ Hash[String, Object?]
38 |
# File 'sig/ibex/generation_manifest.rbs', line 38
def self?.sorted_hash: (Hash[String, Object?] value) -> Hash[String, Object?]
|
#self?.validate ⇒ Hash[String, json_value]
Validate the manifest shape and, by default, every published artifact digest.
26 |
# File 'sig/ibex/generation_manifest.rbs', line 26
def self?.validate: (String source, ?verify_artifacts: bool) -> Hash[String, json_value]
|
#self?.validate_digest ⇒ void
This method returns an undefined value.
62 |
# File 'sig/ibex/generation_manifest.rbs', line 62
def self?.validate_digest: (Object? digest, String label) -> void
|
#self?.validate_document ⇒ void
This method returns an undefined value.
41 |
# File 'sig/ibex/generation_manifest.rbs', line 41
def self?.validate_document: (Object? document) -> void
|
#self?.validate_entries ⇒ void
This method returns an undefined value.
50 |
# File 'sig/ibex/generation_manifest.rbs', line 50
def self?.validate_entries: (Array[Object?] entries, String label, ?require_kind: bool) -> void
|
#self?.validate_entry ⇒ void
This method returns an undefined value.
53 |
# File 'sig/ibex/generation_manifest.rbs', line 53
def self?.validate_entry: (Object? entry, String label, bool require_kind) -> void
|
#self?.validate_file ⇒ Hash[String, json_value]
29 |
# File 'sig/ibex/generation_manifest.rbs', line 29
def self?.validate_file: (String path, ?verify_artifacts: bool) -> Hash[String, json_value]
|
#self?.validate_identity ⇒ void
This method returns an undefined value.
44 |
# File 'sig/ibex/generation_manifest.rbs', line 44
def self?.validate_identity: (Hash[Object?, Object?] document) -> void
|
#self?.validate_input ⇒ void
This method returns an undefined value.
47 |
# File 'sig/ibex/generation_manifest.rbs', line 47
def self?.validate_input: (Object? input) -> void
|
#self?.validate_kind ⇒ void
This method returns an undefined value.
59 |
# File 'sig/ibex/generation_manifest.rbs', line 59
def self?.validate_kind: (Object? kind, String label) -> void
|
#self?.validate_path ⇒ void
This method returns an undefined value.
56 |
# File 'sig/ibex/generation_manifest.rbs', line 56
def self?.validate_path: (Object? path, String label) -> void
|
#self?.verify_entries ⇒ void
This method returns an undefined value.
68 |
# File 'sig/ibex/generation_manifest.rbs', line 68
def self?.verify_entries: (Array[Object?] entries) -> void
|