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 =

Signature:

  • Integer

Returns:

  • (Integer)
1
IDENTIFIER =

Signature:

  • String

Returns:

  • (String)
"generation"
ROOT_KEYS =

Signature:

  • Array[String]

Returns:

  • (Array[String])
%w[ibex_manifest schema_version input options artifacts].freeze
INPUT_KEYS =

Signature:

  • Array[String]

Returns:

  • (Array[String])
%w[root sha256 files].freeze
FILE_KEYS =

Signature:

  • Array[String]

Returns:

  • (Array[String])
%w[path sha256 bytesize].freeze
ARTIFACT_KEYS =

Signature:

  • Array[String]

Returns:

  • (Array[String])
%w[kind path sha256 bytesize].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.render(artifacts, source_records:, options:) ⇒ Object

RBS:

  • (ArtifactSet artifacts, source_records: Array[GenerationInput], options: Hash[String, untyped]) -> String



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(options),
    "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.

RBS:

  • (String source, ?verify_artifacts: bool) -> Hash[String, untyped]



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.message}"
end

.validate_file(path, verify_artifacts: true) ⇒ Object

RBS:

  • (String path, ?verify_artifacts: bool) -> Hash[String, untyped]



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.message}"
end

Instance Method Details

#self?.artifact_entryHash[String, untyped]

RBS:

  • (Artifact artifact) -> Hash[String, untyped]

Parameters:

Returns:

  • (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.

RBS:

  • (Hash[untyped, untyped] value, Array[String] expected, String label) -> void

Parameters:

  • value (Hash[untyped, untyped])
  • expected (Array[String])
  • label (String)


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_digestString

RBS:

  • (Array[Hash[String, untyped]] files) -> String

Parameters:

  • files (Array[Hash[String, untyped]])

Returns:

  • (String)


32
# File 'sig/ibex/generation_manifest.rbs', line 32

def self?.input_digest: (Array[Hash[String, untyped]] files) -> String

#self?.renderString

RBS:

  • (ArtifactSet artifacts, source_records: Array[GenerationInput], options: Hash[String, untyped]) -> String

Parameters:

Returns:

  • (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_hashHash[String, untyped]

RBS:

  • (Hash[String, untyped] value) -> Hash[String, untyped]

Parameters:

  • value (Hash[String, untyped])

Returns:

  • (Hash[String, untyped])


35
# File 'sig/ibex/generation_manifest.rbs', line 35

def self?.sorted_hash: (Hash[String, untyped] value) -> Hash[String, untyped]

#self?.validateHash[String, untyped]

Validate the manifest shape and, by default, every published artifact digest.

RBS:

  • (String source, ?verify_artifacts: bool) -> Hash[String, untyped]

Parameters:

  • source (String)
  • verify_artifacts: (Boolean)

Returns:

  • (Hash[String, untyped])


23
# File 'sig/ibex/generation_manifest.rbs', line 23

def self?.validate: (String source, ?verify_artifacts: bool) -> Hash[String, untyped]

#self?.validate_digestvoid

This method returns an undefined value.

RBS:

  • (untyped digest, String label) -> void

Parameters:

  • digest (Object)
  • label (String)


59
# File 'sig/ibex/generation_manifest.rbs', line 59

def self?.validate_digest: (untyped digest, String label) -> void

#self?.validate_documentvoid

This method returns an undefined value.

RBS:

  • (untyped document) -> void

Parameters:

  • document (Object)


38
# File 'sig/ibex/generation_manifest.rbs', line 38

def self?.validate_document: (untyped document) -> void

#self?.validate_entriesvoid

This method returns an undefined value.

RBS:

  • (Array[untyped] entries, String label, ?require_kind: bool) -> void

Parameters:

  • entries (Array[untyped])
  • label (String)
  • require_kind: (Boolean)


47
# File 'sig/ibex/generation_manifest.rbs', line 47

def self?.validate_entries: (Array[untyped] entries, String label, ?require_kind: bool) -> void

#self?.validate_entryvoid

This method returns an undefined value.

RBS:

  • (untyped entry, String label, bool require_kind) -> void

Parameters:

  • entry (Object)
  • label (String)
  • require_kind (Boolean)


50
# File 'sig/ibex/generation_manifest.rbs', line 50

def self?.validate_entry: (untyped entry, String label, bool require_kind) -> void

#self?.validate_fileHash[String, untyped]

RBS:

  • (String path, ?verify_artifacts: bool) -> Hash[String, untyped]

Parameters:

  • path (String)
  • verify_artifacts: (Boolean)

Returns:

  • (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_identityvoid

This method returns an undefined value.

RBS:

  • (Hash[untyped, untyped] document) -> void

Parameters:

  • document (Hash[untyped, untyped])


41
# File 'sig/ibex/generation_manifest.rbs', line 41

def self?.validate_identity: (Hash[untyped, untyped] document) -> void

#self?.validate_inputvoid

This method returns an undefined value.

RBS:

  • (untyped input) -> void

Parameters:

  • input (Object)


44
# File 'sig/ibex/generation_manifest.rbs', line 44

def self?.validate_input: (untyped input) -> void

#self?.validate_kindvoid

This method returns an undefined value.

RBS:

  • (untyped kind, String label) -> void

Parameters:

  • kind (Object)
  • label (String)


56
# File 'sig/ibex/generation_manifest.rbs', line 56

def self?.validate_kind: (untyped kind, String label) -> void

#self?.validate_pathvoid

This method returns an undefined value.

RBS:

  • (untyped path, String label) -> void

Parameters:

  • path (Object)
  • label (String)


53
# File 'sig/ibex/generation_manifest.rbs', line 53

def self?.validate_path: (untyped path, String label) -> void

#self?.verify_entriesvoid

This method returns an undefined value.

RBS:

  • (Array[untyped] entries) -> void

Parameters:

  • entries (Array[untyped])


65
# File 'sig/ibex/generation_manifest.rbs', line 65

def self?.verify_entries: (Array[untyped] entries) -> void