Class: Ucode::Glyphs::SourceConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/glyphs/source_config.rb,
lib/ucode/glyphs/source_config/gap_report.rb,
lib/ucode/glyphs/source_config/coverage_assertion.rb

Overview

Loads the curated Tier 1 font map from config/unicode17_universal_glyph_set.yml into a typed Models::GlyphSourceMap.

This is the policy half of the 4-tier resolver (TODO 23): "which font wins for which block, this Unicode version". The resolver mechanics live in Resolver + Source; the per-version curation lives in the YAML.

Block ids in the YAML use the canonical underscore form ("Basic_Latin", "CJK_Unified_Ideographs_Extension_J") — same convention as Parsers::Blocks and the rest of the codebase. Never slugified beyond whitespace collapse.

Loader semantics:

  • Missing file → exist? returns false; map is an empty GlyphSourceMap; all queries return empty.
  • Empty map: section → same as missing file.
  • Malformed YAML → raises (the curator must fix the file).

Defined Under Namespace

Classes: CoverageAssertion, GapReport

Constant Summary collapse

DEFAULT_PATH =

Default location of the curated Tier 1 font map. Public so the canonical build + universal set commands can reference it when no override is supplied. Keeping it on the class (not an instance attr) lets callers use it without constructing a SourceConfig first.

Pathname.new("config/unicode17_universal_glyph_set.yml")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: DEFAULT_PATH) ⇒ SourceConfig

Returns a new instance of SourceConfig.

Parameters:

  • path (String, Pathname) (defaults to: DEFAULT_PATH)

    path to the YAML config file.



45
46
47
# File 'lib/ucode/glyphs/source_config.rb', line 45

def initialize(path: DEFAULT_PATH)
  @path = Pathname.new(path)
end

Instance Attribute Details

#pathPathname (readonly)

Returns the resolved config file path.

Returns:

  • (Pathname)

    the resolved config file path



50
51
52
# File 'lib/ucode/glyphs/source_config.rb', line 50

def path
  @path
end

Class Method Details

.load(yaml_path = DEFAULT_PATH) ⇒ Ucode::Models::GlyphSourceMap

Class-method shortcut: load and return the typed map. Useful for one-shot scripts that don't need to query exist? first.

Parameters:

  • yaml_path (String, Pathname) (defaults to: DEFAULT_PATH)

Returns:



84
85
86
# File 'lib/ucode/glyphs/source_config.rb', line 84

def self.load(yaml_path = DEFAULT_PATH)
  new(path: yaml_path).map
end

Instance Method Details

#configured_block_idsArray<String>

Returns block_ids with at least one Tier 1 source configured.

Returns:

  • (Array<String>)

    block_ids with at least one Tier 1 source configured.



75
76
77
# File 'lib/ucode/glyphs/source_config.rb', line 75

def configured_block_ids
  map.configured_block_ids
end

#exist?Boolean

Returns true if the config file exists on disk.

Returns:

  • (Boolean)

    true if the config file exists on disk



53
54
55
# File 'lib/ucode/glyphs/source_config.rb', line 53

def exist?
  @path.exist?
end

#fonts_for(block_id) ⇒ Array<Ucode::Models::GlyphSource>

Returns sources for this block in priority order; empty when unconfigured.

Parameters:

  • block_id (String)

    verbatim block id (underscore form)

Returns:



69
70
71
# File 'lib/ucode/glyphs/source_config.rb', line 69

def fonts_for(block_id)
  map.sources_for(block_id)
end

#mapUcode::Models::GlyphSourceMap

The loaded typed map. Memoized on first access. An empty Models::GlyphSourceMap when the file is missing or has no map: section.



62
63
64
# File 'lib/ucode/glyphs/source_config.rb', line 62

def map
  @map ||= load_map
end