Class: Ucode::Glyphs::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/pipeline.rb

Overview

Assembles the per-block specs that Writer#write_all drains.

Owns three pieces of orchestration that Commands::GlyphsCommand used to carry inline:

- block loading from {Cache.ucd_dir}/Blocks.txt (with an optional
block filter)
- PDF fetcher construction (with monolith fallback)
- the per-block page-map heuristic (per-block PDFs are page 1 =
title, page 2 = first chart page starting at the block's first
codepoint; true for most BMP blocks; multi-page blocks need a
richer resolver — mismatches yield placeholder SVGs only, never
wrong glyphs)

The Command stays a thin wrapper that prints the experimental warning and wires the writer. See Candidate 3 of the 2026-06-29 architecture review.

Defined Under Namespace

Classes: Spec

Constant Summary collapse

DEFAULT_MONOLITH_PATH =

Path to the monolith fallback file when no per-block PDF is on disk yet. Overridable for tests.

"CodeCharts.pdf"
DEFAULT_PAGE_MAP_CACHE =

Cache path for the page-map corpus. Overridable for tests.

"data/codecharts_page_map.json"

Instance Method Summary collapse

Constructor Details

#initialize(version:, block_filter: nil, monolith_path: DEFAULT_MONOLITH_PATH, page_map_cache: DEFAULT_PAGE_MAP_CACHE) ⇒ Pipeline

Returns a new instance of Pipeline.

Parameters:

  • version (String)

    resolved UCD version (callers must resolve via VersionResolver.resolve first)

  • block_filter (Array<String>, nil) (defaults to: nil)

    block ids to limit to; nil = every block

  • monolith_path (String, Pathname, nil) (defaults to: DEFAULT_MONOLITH_PATH)

    fallback monolith

  • page_map_cache (String, Pathname) (defaults to: DEFAULT_PAGE_MAP_CACHE)

    cache for the page map



45
46
47
48
49
50
51
52
# File 'lib/ucode/glyphs/pipeline.rb', line 45

def initialize(version:, block_filter: nil,
               monolith_path: DEFAULT_MONOLITH_PATH,
               page_map_cache: DEFAULT_PAGE_MAP_CACHE)
  @version = version
  @block_filter = block_filter
  @monolith_path = monolith_path
  @page_map_cache = page_map_cache
end

Instance Method Details

#build_specs(force: false) ⇒ Array<Spec>

Load every block from the cached Blocks.txt (filtered by @block_filter when set) and pair each one with a fetched PDF path and a page map. Blocks whose PDF cannot be fetched are silently dropped — the placeholder pass downstream covers them.

Parameters:

  • force (Boolean) (defaults to: false)

    re-fetch PDFs even when cached

Returns:



61
62
63
64
65
# File 'lib/ucode/glyphs/pipeline.rb', line 61

def build_specs(force: false)
  blocks = load_blocks
  fetcher = build_fetcher(blocks)
  blocks.map { |block| spec_for(block, fetcher, force) }.compact
end