Class: Ucode::CodeChart::CoverageGapIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/code_chart/coverage_gap_index.rb

Overview

Lists Unicode blocks that have OFL coverage gaps — assigned codepoints no Tier 1 donor font covers. REQ R5's --coverage-gap-only flag.

Inputs

The index takes a coverage_by_block map ({block_id => [covered_codepoints]}) and a blocks lookup. For each block, it computes the gap (assigned − covered) and emits a GapAnalyzer::BlockGap when the gap is non-empty.

Reuse

Internally composes GapAnalyzer::Analyzer with a synthetic manifest (covering exactly the donor-supplied codepoints). No duplication of the gap-math; the OCP boundary is at GapAnalyzer.

Coverage source

The actual "is this codepoint covered by any OFL font?" lookup lives outside this class — callers pass in the coverage map. Future work: a Tier 1 CoverageCollector that walks fontist's known OFL sources and emits the coverage_by_block input. Until then, the caller supplies it (typically from a YAML file).

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(coverage_by_block:, blocks:, ucd_version:) ⇒ CoverageGapIndex

Returns a new instance of CoverageGapIndex.

Parameters:

  • coverage_by_block (Hash{String=>Array<Integer>})
  • blocks (Hash{String=>Ucode::Models::Block})
  • ucd_version (String)


47
48
49
50
51
# File 'lib/ucode/code_chart/coverage_gap_index.rb', line 47

def initialize(coverage_by_block:, blocks:, ucd_version:)
  @coverage_by_block = coverage_by_block
  @blocks = blocks
  @ucd_version = ucd_version
end

Class Method Details

.from_yaml(path, blocks:) ⇒ CoverageGapIndex

Parameters:

Returns:



104
105
106
107
108
109
110
111
# File 'lib/ucode/code_chart/coverage_gap_index.rb', line 104

def from_yaml(path, blocks:)
  data = YAML.safe_load(Pathname.new(path).read) || {}
  new(
    coverage_by_block: data.fetch("coverage", {}),
    blocks: blocks,
    ucd_version: data.fetch("ucd_version"),
  )
end

Instance Method Details

#each_gap_block {|block_gap| ... } ⇒ Enumerator, void

Yield Parameters:

Returns:

  • (Enumerator, void)


55
56
57
58
59
# File 'lib/ucode/code_chart/coverage_gap_index.rb', line 55

def each_gap_block(&)
  return enum_for(:each_gap_block) unless block_given?

  analyzer.each_block_gap(&)
end

#gap_blocksArray<Ucode::CodeChart::GapAnalyzer::BlockGap>



62
63
64
# File 'lib/ucode/code_chart/coverage_gap_index.rb', line 62

def gap_blocks
  analyzer.block_gaps
end

#total_missing_codepointsInteger

Returns:

  • (Integer)


67
68
69
# File 'lib/ucode/code_chart/coverage_gap_index.rb', line 67

def total_missing_codepoints
  analyzer.total_missing_codepoints
end