Class: Ucode::Glyphs::UniversalSet::PreBuildCheck

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

Overview

Pre-flight validation for a universal-set build. Runs the three checks TODO 31 specifies:

  1. Source config loads cleanly. SourceConfig.new(path:) returns a map without raising, and the file exists.
  2. All fonts present. Every source in the map resolves to a file on disk (kind=path) or via fontist's index (kind=fontist, install: false). Missing fonts are listed.
  3. Coverage assertion runs. TODO 29's CoverageAssertion walks every assigned codepoint; gaps are surfaced but do not abort (expected for residual curation cases).

The check raises UniversalSetPreBuildError when missing_fonts is non-empty or the config fails to load. The CLI catches this and renders the failing checks; the build never starts with known-bad inputs.

Instance Method Summary collapse

Constructor Details

#initialize(source_config_path:, database:, cmaps: nil, font_locator: RealFonts::FontLocator.new) ⇒ PreBuildCheck

Returns a new instance of PreBuildCheck.

Parameters:

  • source_config_path (String, Pathname)
  • database (Ucode::Database)

    open database for the target Unicode version. Used by CoverageAssertion.

  • cmaps (#covers?) (defaults to: nil)

    defaults to RealFonts::CmapCache. Injectable for testing (e.g. StaticCmaps).

  • font_locator (#locate) (defaults to: RealFonts::FontLocator.new)

    defaults to a fresh FontLocator. Injectable for testing.



51
52
53
54
55
56
57
# File 'lib/ucode/glyphs/universal_set/pre_build_check.rb', line 51

def initialize(source_config_path:, database:, cmaps: nil,
               font_locator: RealFonts::FontLocator.new)
  @source_config_path = Pathname.new(source_config_path)
  @database = database
  @cmaps = cmaps || RealFonts::CmapCache.new
  @font_locator = font_locator
end

Instance Method Details

#callPreBuildReport

Returns:

Raises:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ucode/glyphs/universal_set/pre_build_check.rb', line 62

def call
  report = build_report
  unless report.ok?
    raise Ucode::UniversalSetPreBuildError.new(
      "pre-build validation failed",
      context: {
        source_config_path: @source_config_path.to_s,
        missing_fonts: report.missing_fonts,
        config_loaded: report.config_loaded,
      },
    )
  end

  report
end