Class: Ace::Compressor::Atoms::RetentionReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/compressor/atoms/retention_reporter.rb

Constant Summary collapse

LITERAL_PROTECTED_TYPES =
%w[RULE CONSTRAINT CMD U].freeze
COUNT_PROTECTED_TYPES =
%w[CODE TABLE].freeze
STRUCTURED_TYPES =
%w[LIST PROBLEMS FILES TREE EXAMPLE].freeze
LOSS_MARKER_TYPES =
%w[LOSS EXAMPLE_REF REFUSAL FALLBACK].freeze

Instance Method Summary collapse

Instance Method Details

#compare(reference_content:, candidate_content:) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ace/compressor/atoms/retention_reporter.rb', line 12

def compare(reference_content:, candidate_content:)
  reference = parse(reference_content)
  candidate = parse(candidate_content)

  {
    "sections" => coverage_for_sections(reference, candidate),
    "protected" => coverage_for_protected(reference, candidate),
    "structured" => coverage_for_structured(reference, candidate),
    "loss_markers" => LOSS_MARKER_TYPES.to_h { |type| [type.downcase, candidate.fetch("counts").fetch(type, 0)] }
  }
end