Class: Ucode::Audit::Differ

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

Overview

Computes a Models::Audit::AuditDiff between two AuditReports.

Pure: no I/O, no font parsing. Both reports must already be built — the CLI's compare command loads them from disk or audits fresh fonts before invoking the differ.

Comparison shape:

- Scalar fields: one {Models::Audit::FieldChange} per differing
field.
- Codepoint coverage: {Models::Audit::CodepointSetDiff} built
from the cmap range lists (expanded to integer sets for set
arithmetic, then re-coalesced to ranges for output).
- Structural inventories (features, scripts, blocks): simple
array set-diffs. ucode drops the CLDR languages diff that
fontisan carries (CLDR is out of scope here).

Constant Summary collapse

COMPARED_FIELDS =

Scalar AuditReport fields compared field-by-field. Excludes generated_at / source_sha256 / source_file (per-report identity), codepoints / codepoint_ranges (handled via CodepointSetDiff), and nested models (surfaced via structural add/remove lists).

%i[
  family_name subfamily_name full_name postscript_name version
  font_revision weight_class width_class italic bold panose
  total_codepoints total_glyphs
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(left_report, right_report) ⇒ Differ

Returns a new instance of Differ.

Parameters:



33
34
35
36
# File 'lib/ucode/audit/differ.rb', line 33

def initialize(left_report, right_report)
  @left = left_report
  @right = right_report
end

Instance Method Details

#diffModels::Audit::AuditDiff



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

def diff
  Models::Audit::AuditDiff.new(
    left_source: @left.source_file,
    right_source: @right.source_file,
    field_changes: field_changes,
    codepoints: codepoint_diff,
    added_features: set_diff(features(@right), features(@left)),
    removed_features: set_diff(features(@left), features(@right)),
    added_scripts: set_diff(scripts(@right), scripts(@left)),
    removed_scripts: set_diff(scripts(@left), scripts(@right)),
    added_blocks: set_diff(blocks(@right), blocks(@left)),
    removed_blocks: set_diff(blocks(@left), blocks(@right)),
  )
end