Class: Ucode::Glyphs::UniversalSet::Builder

Inherits:
Object
  • Object
show all
Includes:
Idempotency
Defined in:
lib/ucode/glyphs/universal_set/builder.rb

Overview

Drains a codepoint stream through the 4-tier Resolver and produces the universal glyph set: one SVG per codepoint + manifest.json + reports.

This is the orchestrator described by TODO 24. It owns three concerns and only three:

1. Iterate the codepoint stream (single-threaded or worker
 pool, depending on `parallel_workers:`).
2. For each codepoint: resolve via the {Resolver}, write
 the SVG via {Idempotency}, route the outcome to the
 {ManifestAccumulator}.
3. After the drain: hand the manifest + per-block breakdown
 to the {ManifestWriter} for atomic emission.

The Builder is intentionally agnostic of how the codepoint stream is produced. The CLI command (TODO 24) constructs a Coordinator enumerator; tests construct a small Array. The Builder doesn't know about UCD text files, fontist, or PDFs — those live behind the Resolver.

Idempotency

SVG writes go through Idempotency#write_glyph, which uses Repo::AtomicWrites#write_atomic for byte-level idempotency. Re-running with the same resolver + SVG payloads produces zero file writes. The manifest is regenerated each run; its generated_at updates but its entries remain stable when content is unchanged.

Instance Method Summary collapse

Methods included from Idempotency

#by_block_report_path, #by_tier_report_path, #gaps_report_path, #glyph_path, #manifest_path, #write_glyph

Methods included from Repo::AtomicWrites

#same_content?, #to_pretty_json, #write_atomic

Constructor Details

#initialize(output_root:, resolver:, unicode_version:, ucode_version:, source_config_sha256:, parallel_workers: 1, block_filter: nil) ⇒ Builder

Returns a new instance of Builder.

Parameters:

  • output_root (String, Pathname)

    directory that will hold manifest.json, glyphs/, reports/.

  • resolver (Ucode::Glyphs::Resolver)
  • unicode_version (String)
  • ucode_version (String)
  • source_config_sha256 (String)

    hex digest of the YAML config that produced this build (recorded in the manifest so audits can detect drift).

  • parallel_workers (Integer) (defaults to: 1)

    size of the worker pool. Set to 1 (or less) for inline mode — used in tests.

  • block_filter (String, nil) (defaults to: nil)

    only build codepoints whose block_id matches this verbatim (canonical underscore form).



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ucode/glyphs/universal_set/builder.rb', line 56

def initialize(output_root:, resolver:, unicode_version:,
               ucode_version:, source_config_sha256:,
               parallel_workers: 1, block_filter: nil)
  @output_root = Pathname.new(output_root)
  @resolver = resolver
  @unicode_version = unicode_version
  @ucode_version = ucode_version
  @source_config_sha256 = source_config_sha256
  @parallel_workers = parallel_workers
  @block_filter = block_filter
end

Instance Method Details

#build(codepoints) ⇒ Pathname

Drain codepoints through the resolver and emit the manifest + reports. Returns the path to the written manifest.

Parameters:

Returns:

  • (Pathname)

    path to the written manifest.json



73
74
75
76
77
78
79
80
81
# File 'lib/ucode/glyphs/universal_set/builder.rb', line 73

def build(codepoints)
  accumulator = ManifestAccumulator.new(
    unicode_version: @unicode_version,
    ucode_version: @ucode_version,
    source_config_sha256: @source_config_sha256,
  )
  drain(codepoints, accumulator)
  write_outputs(accumulator)
end