Module: Ucode::Fetch::UnihanZip
- Defined in:
- lib/ucode/fetch/unihan_zip.rb
Overview
Downloads Unihan.zip from unicode.org and unpacks it into ‘Cache.unihan_dir(version)`.
Class Method Summary collapse
Class Method Details
.call(version, force: false) ⇒ Pathname
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ucode/fetch/unihan_zip.rb', line 17 def call(version, force: false) Cache.ensure_version_dir!(version) target_dir = Cache.unihan_dir(version) marker = target_dir.join("Unihan_Readings.txt") return target_dir if marker.exist? && !force url = "#{Ucode.configuration.unihan_base_url}/#{version}#{URL_SUFFIX}" zip_path = Cache.version_dir(version).join("unihan.zip") Http.get(url, dest: zip_path) extract(zip_path, target_dir) zip_path.delete if zip_path.exist? target_dir end |