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)


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

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)


70
71
72
# File 'lib/ucode/repo/paths.rb', line 70

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)


76
77
78
# File 'lib/ucode/repo/paths.rb', line 76

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)


47
48
49
# File 'lib/ucode/repo/paths.rb', line 47

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)


63
64
65
# File 'lib/ucode/repo/paths.rb', line 63

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)


55
56
57
# File 'lib/ucode/repo/paths.rb', line 55

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)


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

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

.labels_index_path(output_root) ⇒ Pathname

Parameters:

  • output_root (String, Pathname)

Returns:

  • (Pathname)


102
103
104
# File 'lib/ucode/repo/paths.rb', line 102

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)


108
109
110
# File 'lib/ucode/repo/paths.rb', line 108

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)


96
97
98
# File 'lib/ucode/repo/paths.rb', line 96

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)


83
84
85
# File 'lib/ucode/repo/paths.rb', line 83

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)


90
91
92
# File 'lib/ucode/repo/paths.rb', line 90

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)


116
117
118
# File 'lib/ucode/repo/paths.rb', line 116

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