Class: Ucode::Commands::EmitMetadataCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/ucode/commands/emit_metadata.rb

Overview

ucode emit-metadata — generates frozen Ruby metadata modules from cached UCD text files.

Run after ucode fetch ucd <version> to produce the metadata module that ships with the gem. The output is written to lib/ucode/unicode/metadata/<vXX_Y_Z>.rb and must be committed.

Instance Method Summary collapse

Instance Method Details

#call(version, gem_root: nil) ⇒ Hash

Returns { version:, path:, bytes:, blocks:, assigned_count: }.

Parameters:

  • version (String)

    e.g. "17.0.0"

  • gem_root (String, Pathname, nil) (defaults to: nil)

    gem root for output path resolution; defaults to the conventional location.

Returns:

  • (Hash)

    { version:, path:, bytes:, blocks:, assigned_count: }

Raises:



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ucode/commands/emit_metadata.rb', line 18

def call(version, gem_root: nil)
  ucd_dir = Cache.ucd_dir(version)
  raise Ucode::Error, "UCD not cached for #{version}. Run: ucode fetch ucd #{version}" unless ucd_dir.exist?

  source = Ucode::Unicode::MetadataWriter.generate(
    ucd_dir: ucd_dir, version: version,
  )

  out_path = resolve_output_path(version, gem_root)
  write_atomic(out_path, source)

   = Ucode::Unicode::MetadataWriter
  .version_to_module(version)
  {
    version: version,
    path: out_path.to_s,
    bytes: source.bytesize,
  }
end