Module: Ucode::Unicode::MetadataWriter
- Defined in:
- lib/ucode/unicode/metadata_writer.rb
Overview
Generates frozen Ruby metadata modules from UCD text files.
Pure logic: takes a UCD directory path and a version string, returns the Ruby source for a metadata module. The CLI command (EmitMetadataCommand) writes the output to disk.
This is the build-time tool that produces the frozen constants consumers query at runtime via Catalog. Run it when a new Unicode version is adopted:
bin/ucode fetch ucd 18.0.0
bin/ucode emit-metadata --version 18.0.0
# commit the generated file + add to SUPPORTED_VERSIONS
Class Method Summary collapse
-
.generate(ucd_dir:, version:) ⇒ String
Ruby source for the metadata module.
-
.version_to_filename(version) ⇒ String
E.g.
-
.version_to_module(version) ⇒ String
E.g.
Class Method Details
.generate(ucd_dir:, version:) ⇒ String
Returns Ruby source for the metadata module.
30 31 32 33 34 35 36 37 38 |
# File 'lib/ucode/unicode/metadata_writer.rb', line 30 def generate(ucd_dir:, version:) assigned_count, by_plane = compute_assigned(ucd_dir) blocks = parse_blocks(ucd_dir) mod_name = version_to_module(version) build_source(version: version, mod_name: mod_name, assigned_count: assigned_count, by_plane: by_plane, blocks: blocks) end |
.version_to_filename(version) ⇒ String
Returns e.g. "v17_0_0".
42 43 44 |
# File 'lib/ucode/unicode/metadata_writer.rb', line 42 def version_to_filename(version) "v#{version.tr('.', '_').downcase}" end |
.version_to_module(version) ⇒ String
Returns e.g. "V17_0_0".
48 49 50 |
# File 'lib/ucode/unicode/metadata_writer.rb', line 48 def version_to_module(version) "V#{version.tr('.', '_')}" end |