Class: Ucode::Commands::BlockFeedCommand

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

Overview

ucode block-feed — emit a compact per-block Unicode data feed from ucode's canonical output tree.

Reads ucode's output/ and produces three artifacts at the target directory:

<target>/unicode-blocks.json
<target>/unicode-version.json
<target>/unicode/blocks/<slug>.json

Each per-block file contains the codepoints in that block with their compact Unicode metadata (name, general category, script, combining class, bidi class, mirrored flag). Block slugs are derived from the block name via the standard slug algorithm.

Defined Under Namespace

Classes: Result

Instance Method Summary collapse

Instance Method Details

#call(ucode_output_root:, block_feed_output_root:, unicode_version: nil) ⇒ Result

Parameters:

  • ucode_output_root (String, Pathname)

    ucode's output/ (must contain blocks/index.json, blocks//index.json, index/labels.json).

  • block_feed_output_root (String, Pathname)

    target directory.

  • unicode_version (String, nil) (defaults to: nil)

    UCD version to stamp on unicode-version.json. Defaults to the version recorded in ucode's manifest.json.

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/ucode/commands/block_feed.rb', line 38

def call(ucode_output_root:, block_feed_output_root:, unicode_version: nil)
  ucode_root = Pathname.new(ucode_output_root)
  feed_root = Pathname.new(block_feed_output_root)
  version = unicode_version || manifest_version(ucode_root)

  emitter = Repo::BlockFeedEmitter.new(ucode_root, feed_root)
  outcome = emitter.emit(ucd_version: version)

  Result.new(
    ucode_output_root: ucode_root.to_s,
    block_feed_output_root: feed_root.to_s,
    unicode_version: version,
    blocks_written: outcome[:blocks_written],
    codepoints_written: outcome[:codepoints_written],
    unicode_blocks_path: outcome[:unicode_blocks_path],
    unicode_version_path: outcome[:unicode_version_path],
  )
end