Class: Fontisan::CldrCli
- Inherits:
-
Thor
- Object
- Thor
- Fontisan::CldrCli
- Defined in:
- lib/fontisan/cli/cldr_cli.rb
Overview
Thor subcommand for managing the local CLDR (Common Locale Data
Repository) cache used by fontisan audit for per-language coverage.
fontisan cldr download [VERSION] fetch + index CLDR exemplars
fontisan cldr status show what's cached
fontisan cldr path [VERSION] print local cache path
fontisan cldr list list known versions
fontisan cldr remove VERSION delete a cached version
With no arguments, download resolves the configured default version
(see lib/fontisan/config/cldr.yml).
Instance Method Summary collapse
- #download(version = nil) ⇒ Object
- #list ⇒ Object
- #path(version = nil) ⇒ Object
- #remove(version) ⇒ Object
- #status ⇒ Object
Instance Method Details
#download(version = nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fontisan/cli/cldr_cli.rb', line 24 def download(version = nil) intent = resolve_intent(version, [:latest]) actual = Cldr::VersionResolver.resolve(intent) Cldr::Downloader.download(actual, force: [:force]) Cldr::IndexBuilder.build(actual) unless index_present?(actual) puts "CLDR #{actual} ready at: #{Cldr::CacheManager.version_dir(actual)}" rescue Cldr::Error => e warn "ERROR: #{e.}" exit 1 end |
#list ⇒ Object
54 55 56 |
# File 'lib/fontisan/cli/cldr_cli.rb', line 54 def list Cldr::Config.known_versions.each { |v| puts v } end |
#path(version = nil) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/fontisan/cli/cldr_cli.rb', line 45 def path(version = nil) actual = Cldr::VersionResolver.resolve(version) puts Cldr::CacheManager.version_dir(actual) rescue Cldr::UnknownVersionError => e warn "ERROR: #{e.}" exit 1 end |
#remove(version) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/fontisan/cli/cldr_cli.rb', line 59 def remove(version) Cldr::VersionResolver.validate!(version) unless Cldr::CacheManager.cached?(version) warn "Version #{version} is not cached; nothing to remove." return end Cldr::CacheManager.remove_version(version) puts "Removed CLDR #{version}." rescue Cldr::UnknownVersionError => e warn "ERROR: #{e.}" exit 1 end |
#status ⇒ Object
37 38 39 40 41 42 |
# File 'lib/fontisan/cli/cldr_cli.rb', line 37 def status cached = Cldr::CacheManager.cached_versions puts "Default version: #{Cldr::Config.default_version}" puts "Cache root: #{Cldr::CacheManager.root}" puts "Cached versions: #{cached.empty? ? '(none)' : cached.join(', ')}" end |