Class: Ucode::Audit::BlockAggregator

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

Overview

Produces one Models::Audit::BlockSummary per touched Unicode block for a font's cmap codepoint set, compared against a CoverageReference.

Pure transformation: takes a reference + the font's codepoint list, returns BlockSummary. No I/O beyond the reference's lookups, no mutation of inputs.

The "assigned" set for a block comes from reference.entries_for_block(name). For a UcdOnlyReference that's every codepoint in the block's UCD ranges. For a UniversalSetReference it's every codepoint the universal glyph set built a glyph for in that block — each entry carries tier + source provenance that gets attached to the missing-codepoint list (TODO 25).

Instance Method Summary collapse

Constructor Details

#initialize(reference) ⇒ BlockAggregator

Returns a new instance of BlockAggregator.

Parameters:

  • reference (CoverageReference, Ucode::Database, nil)

    pluggable baseline. For backwards compatibility a raw Ucode::Database is still accepted and wrapped in a UcdOnlyReference at construction time. When nil, #call returns an empty array.



26
27
28
# File 'lib/ucode/audit/block_aggregator.rb', line 26

def initialize(reference)
  @reference = coerce_reference(reference)
end

Instance Method Details

#call(codepoints) ⇒ Array<Models::Audit::BlockSummary>

Returns sorted by first_cp.

Parameters:

  • codepoints (Enumerable<Integer>)

Returns:



32
33
34
35
36
37
38
# File 'lib/ucode/audit/block_aggregator.rb', line 32

def call(codepoints)
  return [] if @reference.nil? || codepoints.empty?

  grouped = group_by_block(codepoints)
  grouped.filter_map { |name, covered| build_summary(name, covered) }
    .sort_by(&:first_cp)
end