Class: Ucode::Glyphs::SourceConfig
- Inherits:
-
Object
- Object
- Ucode::Glyphs::SourceConfig
- 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;mapis an emptyGlyphSourceMap; 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
-
#path ⇒ Pathname
readonly
The resolved config file path.
Class Method Summary collapse
-
.load(yaml_path = DEFAULT_PATH) ⇒ Ucode::Models::GlyphSourceMap
Class-method shortcut: load and return the typed map.
Instance Method Summary collapse
-
#configured_block_ids ⇒ Array<String>
Block_ids with at least one Tier 1 source configured.
-
#exist? ⇒ Boolean
True if the config file exists on disk.
-
#fonts_for(block_id) ⇒ Array<Ucode::Models::GlyphSource>
Sources for this block in priority order; empty when unconfigured.
-
#initialize(path: DEFAULT_PATH) ⇒ SourceConfig
constructor
A new instance of SourceConfig.
-
#map ⇒ Ucode::Models::GlyphSourceMap
The loaded typed map.
Constructor Details
#initialize(path: DEFAULT_PATH) ⇒ SourceConfig
Returns a new instance of SourceConfig.
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
#path ⇒ Pathname (readonly)
Returns 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.
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_ids ⇒ Array<String>
Returns 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.
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.
69 70 71 |
# File 'lib/ucode/glyphs/source_config.rb', line 69 def fonts_for(block_id) map.sources_for(block_id) end |
#map ⇒ Ucode::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 |