Class: Ibex::Impact::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/impact/report.rb

Overview

Builds the deterministic public impact-v1 document.

Instance Method Summary collapse

Constructor Details

#initialize(mode:, algorithm:, grammar:, before:, after:, seeds:, nodes:, symbol_kinds:, set_changes:, automaton:, actions:, coverage:, metadata_names: [], minimum: "info", warnings: []) ⇒ Report

rubocop:disable Metrics/ParameterLists



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ibex/impact/report.rb', line 33

def initialize(mode:, algorithm:, grammar:, before:, after:, seeds:, nodes:, symbol_kinds:, set_changes:,
               automaton:,
               actions:, coverage:, metadata_names: [], minimum: "info", warnings: [])
  @mode = mode
  @algorithm = algorithm
  @grammar = grammar
  @before = before
  @after = after
  @seeds = seeds
  @nodes = nodes
  @symbol_kinds = symbol_kinds
  @set_changes = set_changes
  @metadata_names = .uniq.sort
  @automaton = automaton #: Hash[Symbol, Object?]
  @actions = actions #: Array[Hash[Symbol, Object?]]
  @coverage = coverage #: Hash[Symbol, Object?]
  @minimum = minimum
  @warnings = warnings
end

Instance Method Details

#to_h(minimum: @minimum) ⇒ Object



55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ibex/impact/report.rb', line 55

def to_h(minimum: @minimum)
  symbols = symbol_documents(minimum)
  action_records = action_documents(minimum)
  {
    ibex_report: "impact", schema_version: 1, mode: @mode, algorithm: @algorithm,
    grammar_digest: { before: stable_grammar_digest(@before), after: stable_grammar_digest(@after) },
    seeds: @seeds.map { |seed| seed.slice(:symbol, :origin, :nullable_boundary) },
    symbols: symbols, automaton: @automaton, actions: action_records,
    coverage: coverage_document, warnings: stable_warnings,
    totals: totals(symbols, action_records, @automaton)
  }
end