Class: Ucode::Repo::Writers::ManifestWriter

Inherits:
Object
  • Object
show all
Includes:
AtomicWrites
Defined in:
lib/ucode/repo/writers/manifest_writer.rb

Overview

Writes output/manifest.json. The generated_at timestamp is preserved across no-op re-runs (same content keys → keep old timestamp) so the byte content is byte-idempotent.

One of the eight per-concern writers split out from AggregateWriter — see Candidate 5 of the 2026-06-29 review.

Instance Method Summary collapse

Methods included from AtomicWrites

#same_content?, #to_pretty_json, #write_atomic

Constructor Details

#initialize(output_root:, ucd_version:, codepoint_count:, glyph_count:) ⇒ ManifestWriter

Returns a new instance of ManifestWriter.

Parameters:

  • output_root (Pathname)
  • ucd_version (String)
  • codepoint_count (Integer)
  • glyph_count (Integer)


37
38
39
40
41
42
# File 'lib/ucode/repo/writers/manifest_writer.rb', line 37

def initialize(output_root:, ucd_version:, codepoint_count:, glyph_count:)
  @output_root = output_root
  @ucd_version = ucd_version
  @codepoint_count = codepoint_count
  @glyph_count = glyph_count
end

Instance Method Details

#writeInteger

Returns 1 if written, 0 otherwise.

Returns:

  • (Integer)

    1 if written, 0 otherwise



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/ucode/repo/writers/manifest_writer.rb', line 45

def write
  path = Paths.manifest_path(@output_root)
  content = {
    "ucd_version"     => @ucd_version,
    "codepoint_count" => @codepoint_count,
    "glyph_count"     => @glyph_count,
    "schema_version"  => SCHEMA_VERSION,
  }
  ts = preserved_or_new_timestamp(path, content)
  payload = content.merge("generated_at" => ts)
  write_atomic(path, to_pretty_json(payload)) ? 1 : 0
end