Class: Ucode::Repo::Writers::IndexesWriter
- Inherits:
-
Object
- Object
- Ucode::Repo::Writers::IndexesWriter
- Includes:
- AtomicWrites
- Defined in:
- lib/ucode/repo/writers/indexes_writer.rb
Overview
Writes the three lookup indexes:
output/index/names.json (cp_id → name)
output/index/labels.json (cp_id → {name, gc, sc, cc, bc, mir})
output/index/codepoint_to_block.json (cp_id → block_id)
One of the eight per-concern writers split out from AggregateWriter — see Candidate 5 of the 2026-06-29 review.
Instance Method Summary collapse
-
#initialize(output_root:, names:, labels:, cp_to_block:) ⇒ IndexesWriter
constructor
A new instance of IndexesWriter.
-
#write ⇒ Integer
Number of index files written (always 3 when the directory is reachable).
Methods included from AtomicWrites
#same_content?, #to_pretty_json, #write_atomic
Constructor Details
#initialize(output_root:, names:, labels:, cp_to_block:) ⇒ IndexesWriter
Returns a new instance of IndexesWriter.
25 26 27 28 29 30 |
# File 'lib/ucode/repo/writers/indexes_writer.rb', line 25 def initialize(output_root:, names:, labels:, cp_to_block:) @output_root = output_root @names = names @labels = labels @cp_to_block = cp_to_block end |
Instance Method Details
#write ⇒ Integer
Returns number of index files written (always 3 when the directory is reachable).
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ucode/repo/writers/indexes_writer.rb', line 34 def write count = 0 count += 1 if write_atomic(Paths.names_index_path(@output_root), to_pretty_json(@names)) count += 1 if write_atomic(Paths.labels_index_path(@output_root), to_pretty_json(@labels)) count += 1 if write_atomic(codepoint_to_block_path, to_pretty_json(@cp_to_block)) count end |