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

Class Method Details

.block_dir(output_root, block_id) ⇒ Pathname

Parameters:

  • output_root (String, Pathname)
  • block_id (String)

    verbatim block id (e.g. "ASCII", "CJK_Ext_A")

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • block_id (String)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • block_id (String)
  • cp_id (String)

    e.g. "U+0041"

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • block_id (String)
  • cp_id (String)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • block_id (String)
  • cp_id (String)

Returns:

  • (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.

Parameters:

  • cp (Integer)

Returns:

  • (String)


40
41
42
# File 'lib/ucode/repo/paths.rb', line 40

def cp_id(cp)
  format("U+%04X", cp)
end

.glyph_filenameString

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.

Returns:

  • (String)


31
32
33
# File 'lib/ucode/repo/paths.rb', line 31

def glyph_filename
  GLYPH_FILENAME
end

.labels_index_path(output_root) ⇒ Pathname

Parameters:

  • output_root (String, Pathname)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • plane_number (Integer)

Returns:

  • (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

Parameters:

  • output_root (String, Pathname)
  • script_code (String)

Returns:

  • (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.

Parameters:

  • path (Pathname)

Returns:

  • (Pathname)


124
125
126
# File 'lib/ucode/repo/paths.rb', line 124

def tmp_path(path)
  path.parent.join("#{path.basename}.tmp")
end