Module: Fontisan::Cldr::IndexBuilder
- Defined in:
- lib/fontisan/cldr/index_builder.rb
Overview
Builds the per-language codepoint index from a cached CLDR JSON archive and persists it as a YAML file for future Index loads.
Walks every main/<lang>/characters.json file under the cached
archive, extracts exemplarCharacters (plus auxiliary and index
sets when present), parses each via UnicodeSetParser, and unions
the result into a single codepoint set per language.
Class Method Summary collapse
-
.build(version) ⇒ Index
Build + persist the languages index for a cached version.
-
.build_from_exemplars(exemplars_by_lang) ⇒ Index
Pure: build an Index from a hash of
language => exemplar_string.
Class Method Details
.build(version) ⇒ Index
Build + persist the languages index for a cached version.
19 20 21 22 23 24 25 |
# File 'lib/fontisan/cldr/index_builder.rb', line 19 def build(version) entries = collect_from_cache(version) CacheManager.index_dir(version).mkpath index = Index.new(entries) index.save(CacheManager.languages_index_path(version)) index end |
.build_from_exemplars(exemplars_by_lang) ⇒ Index
Pure: build an Index from a hash of language => exemplar_string.
30 31 32 33 34 35 |
# File 'lib/fontisan/cldr/index_builder.rb', line 30 def build_from_exemplars(exemplars_by_lang) entries = exemplars_by_lang.transform_values do |set_str| set_str.nil? ? Set.new : Set.new(UnicodeSetParser.call(set_str)) end Index.new(entries) end |