Class: Ucode::Commands::Audit::CompareCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/commands/audit/compare_command.rb

Overview

ucode audit compare LEFT RIGHT — diff two audits.

Each of LEFT and RIGHT can be:

- A path to a font file (audited on-the-fly with
{Audit::FaceAuditor}).
- A path to a face audit directory — its `index.json` is
read for the precomputed report shape.
- A path to a saved `index.json` file directly.

Note: reading from disk only recovers the derived overview shape from Emitter::IndexEmitter, not a full AuditReport. The compare therefore uses the field subset that the overview shape preserves (identity + coverage totals). For a full-feature diff, audit both inputs fresh from their font paths.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#call(left, right, unicode_version: nil, output_file: nil) ⇒ Result

Parameters:

  • left (String)

    font path | audit dir | index.json path

  • right (String)

    same forms as left

  • unicode_version (String, nil) (defaults to: nil)
  • output_file (String, Pathname, nil) (defaults to: nil)

    write text to file (default: stdout, captured as text in the result)

Returns:



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ucode/commands/audit/compare_command.rb', line 40

def call(left, right, unicode_version: nil, output_file: nil)
  left_report = load_or_audit(left, unicode_version: unicode_version)
  right_report = load_or_audit(right, unicode_version: unicode_version)

  diff = Ucode::Audit::Differ.new(left_report, right_report).diff
  text = Ucode::Audit::Formatters::AuditDiffText.new(diff).render

  write_output(text, output_file) if output_file

  Result.new(left_source: left, right_source: right, diff: diff,
             text: text)
rescue StandardError => e
  Result.new(left_source: left, right_source: right,
             error: "#{e.class}: #{e.message}")
end