class TwitterCldr::Resources::TimezonesImporter
Private Instance Methods
execute()
click to toggle source
# File lib/twitter_cldr/resources/timezones_importer.rb, line 24 def execute locales = Set.new finish = -> (locale, *) do locales.add(locale) STDOUT.write "\rImported #{locale}, #{locales.size} of #{params[:locales].size} total" end Parallel.each(params[:locales], in_processes: Etc.nprocessors, finish: finish) do |locale| import_locale(locale) locales << locale end puts '' end
import_locale(locale)
click to toggle source
# File lib/twitter_cldr/resources/timezones_importer.rb, line 40 def import_locale(locale) data = requirements[:cldr].merge_each_ancestor(locale) do |ancestor_locale| TimezoneData.new(ancestor_locale, requirements[:cldr]).to_h end data = remove_empties(data) output_file = File.join(output_path, locale.to_s, 'timezones.yml') File.open(output_file, 'w:utf-8') do |output| output.write( TwitterCldr::Utils::YAML.dump( TwitterCldr::Utils.deep_symbolize_keys(locale => data), use_natural_symbols: true ) ) end end
output_path()
click to toggle source
# File lib/twitter_cldr/resources/timezones_importer.rb, line 80 def output_path params.fetch(:output_path) end
remove_empties(h)
click to toggle source
“If a given short metazone form is known NOT to be understood in a given locale and the parent locale has this value such that it would normally be inherited, the inheritance of this value can be explicitly disabled by use of the 'no inheritance marker' as the value, which is 3 simultaneous empty set characters ( U+2205 ).”
www.unicode.org/reports/tr35/tr35-dates.html#Metazone_Names
# File lib/twitter_cldr/resources/timezones_importer.rb, line 66 def remove_empties(h) h.delete_if do |_k, v| v == '∅∅∅' end h.each_pair do |_k, v| remove_empties(v) if v.is_a?(Hash) end h.delete_if do |_k, v| v.is_a?(Hash) && v.empty? end end