Module: Ucode::Repo::Paths
- Defined in:
- lib/ucode/repo/paths.rb
Overview
Pure functions describing the on-disk layout of the output tree.
The only code that knows the path conventions. Site generator, CLI, glyph writer, and fontisan adapter all go through here.
All methods are pure: no I/O, no global state, no side effects. Returns Pathname instances so callers can compose further.
Class Method Summary collapse
- .block_dir(output_root, block_id) ⇒ Pathname
- .block_metadata_path(output_root, block_id) ⇒ Pathname
- .blocks_index_path(output_root) ⇒ Pathname
- .codepoint_dir(output_root, block_id, cp_id) ⇒ Pathname
- .codepoint_glyph_path(output_root, block_id, cp_id) ⇒ Pathname
- .codepoint_json_path(output_root, block_id, cp_id) ⇒ Pathname
-
.cp_id(cp) ⇒ String
Format an integer codepoint as the canonical "U+XXXX" id used everywhere (paths, JSON, cross-references).
-
.glyph_filename ⇒ String
The fixed filename every codepoint's SVG glyph is written to (relative to the codepoint's own directory).
- .labels_index_path(output_root) ⇒ Pathname
- .manifest_path(output_root) ⇒ Pathname
- .names_index_path(output_root) ⇒ Pathname
- .plane_metadata_path(output_root, plane_number) ⇒ Pathname
- .script_metadata_path(output_root, script_code) ⇒ Pathname
-
.tmp_path(path) ⇒ Pathname
Temporary path for atomic writes — same directory as
path, so rename stays within one filesystem.
Class Method Details
.block_dir(output_root, block_id) ⇒ Pathname
47 48 49 |
# File 'lib/ucode/repo/paths.rb', line 47 def block_dir(output_root, block_id) Pathname(output_root).join(BLOCKS_DIR, block_id) end |
.block_metadata_path(output_root, block_id) ⇒ Pathname
78 79 80 |
# File 'lib/ucode/repo/paths.rb', line 78 def (output_root, block_id) block_dir(output_root, block_id).join(INDEX_FILENAME) end |
.blocks_index_path(output_root) ⇒ Pathname
84 85 86 |
# File 'lib/ucode/repo/paths.rb', line 84 def blocks_index_path(output_root) Pathname(output_root).join(BLOCKS_DIR, INDEX_FILENAME) end |
.codepoint_dir(output_root, block_id, cp_id) ⇒ Pathname
55 56 57 |
# File 'lib/ucode/repo/paths.rb', line 55 def codepoint_dir(output_root, block_id, cp_id) block_dir(output_root, block_id).join(cp_id) end |
.codepoint_glyph_path(output_root, block_id, cp_id) ⇒ Pathname
71 72 73 |
# File 'lib/ucode/repo/paths.rb', line 71 def codepoint_glyph_path(output_root, block_id, cp_id) codepoint_dir(output_root, block_id, cp_id).join(GLYPH_FILENAME) end |
.codepoint_json_path(output_root, block_id, cp_id) ⇒ Pathname
63 64 65 |
# File 'lib/ucode/repo/paths.rb', line 63 def codepoint_json_path(output_root, block_id, cp_id) codepoint_dir(output_root, block_id, cp_id).join(INDEX_FILENAME) end |
.cp_id(cp) ⇒ String
Format an integer codepoint as the canonical "U+XXXX" id used everywhere (paths, JSON, cross-references). Always at least 4 hex digits, uppercase, no extra padding.
40 41 42 |
# File 'lib/ucode/repo/paths.rb', line 40 def cp_id(cp) format("U+%04X", cp) end |
.glyph_filename ⇒ String
The fixed filename every codepoint's SVG glyph is written to (relative to the codepoint's own directory). Exposed so the Glyph model bundle records the same string the layout uses.
31 32 33 |
# File 'lib/ucode/repo/paths.rb', line 31 def glyph_filename GLYPH_FILENAME end |
.labels_index_path(output_root) ⇒ Pathname
110 111 112 |
# File 'lib/ucode/repo/paths.rb', line 110 def labels_index_path(output_root) Pathname(output_root).join(INDEX_DIR, "labels.json") end |
.manifest_path(output_root) ⇒ Pathname
116 117 118 |
# File 'lib/ucode/repo/paths.rb', line 116 def manifest_path(output_root) Pathname(output_root).join("manifest.json") end |
.names_index_path(output_root) ⇒ Pathname
104 105 106 |
# File 'lib/ucode/repo/paths.rb', line 104 def names_index_path(output_root) Pathname(output_root).join(INDEX_DIR, "names.json") end |
.plane_metadata_path(output_root, plane_number) ⇒ Pathname
91 92 93 |
# File 'lib/ucode/repo/paths.rb', line 91 def (output_root, plane_number) Pathname(output_root).join(PLANES_DIR, "#{plane_number}.json") end |
.script_metadata_path(output_root, script_code) ⇒ Pathname
98 99 100 |
# File 'lib/ucode/repo/paths.rb', line 98 def (output_root, script_code) Pathname(output_root).join(SCRIPTS_DIR, "#{script_code}.json") end |
.tmp_path(path) ⇒ Pathname
Temporary path for atomic writes — same directory as path,
so rename stays within one filesystem.
124 125 126 |
# File 'lib/ucode/repo/paths.rb', line 124 def tmp_path(path) path.parent.join("#{path.basename}.tmp") end |