Module: Ucode::Glyphs::UniversalSet::Idempotency

Includes:
Repo::AtomicWrites
Included in:
Builder, CoverageReport, ManifestWriter, Validator
Defined in:
lib/ucode/glyphs/universal_set/idempotency.rb

Overview

Idempotency + path helpers for the universal set build.

TODO 24 specifies "a codepoint whose source font mtime + content hash are unchanged is skipped." The content-hash half is exactly Repo::AtomicWrites#write_atomic — byte-identical payloads are a no-op. The mtime half is a future optimization (skip the resolver call entirely when the font hasn't changed); for now, byte-comparison gives semantic correctness, which is the load-bearing property.

This module centralizes the universal-set write semantic so future mtime-based short-circuitting lands in one place. The Builder and ManifestWriter mix this in.

Instance Method Summary collapse

Methods included from Repo::AtomicWrites

#same_content?, #to_pretty_json, #write_atomic

Instance Method Details

#by_block_report_path(output_root) ⇒ Pathname

Parameters:

  • output_root (Pathname)

Returns:

  • (Pathname)


74
75
76
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 74

def by_block_report_path(output_root)
  Pathname.new(output_root).join(REPORTS_DIR, BY_BLOCK_REPORT)
end

#by_tier_report_path(output_root) ⇒ Pathname

Parameters:

  • output_root (Pathname)

Returns:

  • (Pathname)


68
69
70
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 68

def by_tier_report_path(output_root)
  Pathname.new(output_root).join(REPORTS_DIR, BY_TIER_REPORT)
end

#gaps_report_path(output_root) ⇒ Pathname

Parameters:

  • output_root (Pathname)

Returns:

  • (Pathname)


80
81
82
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 80

def gaps_report_path(output_root)
  Pathname.new(output_root).join(REPORTS_DIR, GAPS_REPORT)
end

#glyph_path(output_root, cp_id) ⇒ Pathname

Returns <output_root>/glyphs/<cp_id>.svg.

Parameters:

  • output_root (Pathname)
  • cp_id (String)

Returns:

  • (Pathname)

    <output_root>/glyphs/<cp_id>.svg



56
57
58
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 56

def glyph_path(output_root, cp_id)
  Pathname.new(output_root).join(GLYPHS_DIR, "#{cp_id}.svg")
end

#manifest_path(output_root) ⇒ Pathname

Parameters:

  • output_root (Pathname)

Returns:

  • (Pathname)


62
63
64
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 62

def manifest_path(output_root)
  Pathname.new(output_root).join(MANIFEST_FILENAME)
end

#write_glyph(output_root, cp_id, svg) ⇒ Boolean

Write the SVG payload to the canonical glyphs/<id>.svg path if-and-only-if the content changed. Returns true when the file was written; false when skipped (byte-identical).

Parameters:

  • output_root (Pathname)
  • cp_id (String)

    e.g. "U+0041"

  • svg (String)

Returns:

  • (Boolean)


49
50
51
# File 'lib/ucode/glyphs/universal_set/idempotency.rb', line 49

def write_glyph(output_root, cp_id, svg)
  write_atomic(glyph_path(output_root, cp_id), svg)
end