Class: Ucode::Commands::FetchCommand

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

Overview

ucode fetch — downloads UCD/Unihan/Code-Charts sources into the per-version cache, plus the specialist Tier 1 fonts referenced by the curated source config.

Thin shell over Ucode::Fetch::*. The command takes a resolved version string; CLI callers resolve via VersionResolver.resolve once and thread it through. See Candidate 4 of the 2026-06-29 architecture review.

Instance Method Summary collapse

Instance Method Details

#fetch_charts(version, block_first_cps: nil, force: false) ⇒ Hash

Returns { version:, downloaded: }.

Parameters:

  • version (String)

    resolved UCD version

  • block_first_cps (Array<Integer>, nil) (defaults to: nil)

    nil = all known blocks

  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, downloaded: }



47
48
49
50
51
52
53
# File 'lib/ucode/commands/fetch.rb', line 47

def fetch_charts(version, block_first_cps: nil, force: false)
  Cache.ensure_version_dir!(version)

  cps = block_first_cps || default_block_first_cps(version)
  count = Fetch::CodeCharts.call(version, block_first_cps: cps, force: force)
  { version: version, downloaded: count }
end

#fetch_fonts(manifest_path: nil, only_label: nil, allow_proprietary: false, dry_run: false) ⇒ Hash

Fetch specialist Tier 1 fonts listed in the manifest. Returns a structured summary; per-font detail lives on the returned results array (one Fetch::FontFetcher::Result per entry).

Parameters:

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

    defaults to config/specialist_fonts.yml.

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

    restrict to one label.

  • allow_proprietary (Boolean) (defaults to: false)

    required for non-OFL entries.

  • dry_run (Boolean) (defaults to: false)

    plan only; no network or disk writes.

Returns:

  • (Hash)

    { manifest:, total:, downloaded:, skipped:, failed:, local:, planned:, results: }



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/ucode/commands/fetch.rb', line 66

def fetch_fonts(manifest_path: nil, only_label: nil, allow_proprietary: false,
                dry_run: false)
  path = Pathname.new(manifest_path || DEFAULT_SPECIALIST_FONTS_MANIFEST)
  results = Fetch::SpecialistFontFetcher.new(
    manifest_path: path,
    allow_proprietary: allow_proprietary,
    dry_run: dry_run,
  ).call(only_label: only_label)

  { manifest: path.to_s,
    total: results.size,
    downloaded: results.count(&:downloaded?),
    skipped: results.count(&:skipped?),
    failed: results.count(&:failed?),
    local: results.count(&:local?),
    planned: results.count(&:planned?),
    results: results }
end

#fetch_ucd(version, force: false) ⇒ Hash

Returns { version:, ucd_dir: }.

Parameters:

  • version (String)

    resolved UCD version

  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, ucd_dir: }



28
29
30
31
32
# File 'lib/ucode/commands/fetch.rb', line 28

def fetch_ucd(version, force: false)
  Cache.ensure_version_dir!(version)
  path = Fetch::UcdZip.call(version, force: force)
  { version: version, ucd_dir: path }
end

#fetch_unihan(version, force: false) ⇒ Hash

Returns { version:, unihan_dir: }.

Parameters:

  • version (String)

    resolved UCD version

  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, unihan_dir: }



37
38
39
40
41
# File 'lib/ucode/commands/fetch.rb', line 37

def fetch_unihan(version, force: false)
  Cache.ensure_version_dir!(version)
  path = Fetch::UnihanZip.call(version, force: force)
  { version: version, unihan_dir: path }
end