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. Three subactions: ucd, unihan, charts.

Thin shell over ‘Ucode::Fetch::*`. The command layer’s job is to resolve the version intent and format the result; the fetcher does the network I/O.

Instance Method Summary collapse

Instance Method Details

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

Returns { version:, downloaded: }.

Parameters:

  • version_intent (nil, :default, :latest, String)
  • block_first_cps (Array<Integer>, nil) (defaults to: nil)

    nil = all known blocks

  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, downloaded: }



42
43
44
45
46
47
48
49
# File 'lib/ucode/commands/fetch.rb', line 42

def fetch_charts(version_intent, block_first_cps: nil, force: false)
  version = VersionResolver.resolve(version_intent)
  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_ucd(version_intent, force: false) ⇒ Hash

Returns { version:, ucd_dir: }.

Parameters:

  • version_intent (nil, :default, :latest, String)
  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, ucd_dir: }



21
22
23
24
25
26
# File 'lib/ucode/commands/fetch.rb', line 21

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

#fetch_unihan(version_intent, force: false) ⇒ Hash

Returns { version:, unihan_dir: }.

Parameters:

  • version_intent (nil, :default, :latest, String)
  • force (Boolean) (defaults to: false)

Returns:

  • (Hash)

    { version:, unihan_dir: }



31
32
33
34
35
36
# File 'lib/ucode/commands/fetch.rb', line 31

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