class TwitterCldr::Resources::UnicodePropertyAliasesImporter

Constants

PROPERTY_ALIASES_FILE
PROPERTY_VALUE_ALIASES_FILE

Private Instance Methods

execute() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 19
def execute
  File.write(
    File.join(output_path, 'property_value_aliases.yml'),
    YAML.dump(parse_property_value_aliases)
  )

  File.write(
    File.join(output_path, 'property_aliases.yml'),
    YAML.dump(parse_property_aliases)
  )
end
output_path() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 31
def output_path
  params.fetch(:output_path)
end
parse_alias(data) click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 61
def parse_alias(data)
  {
    long_name: data[1],
    additional: data[2..-1]
  }
end
parse_ccc_value_alias(data) click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 75
def parse_ccc_value_alias(data)
  {
    numeric: data[1],  # don't know what this means
    abbreviated_name: data[2],
    long_name: data[3]
  }
end
parse_file(file, &block) click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 35
def parse_file(file, &block)
  UnicodeFileParser.parse_standard_file(file, &block)
end
parse_property_aliases() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 39
def parse_property_aliases
  Hash.new { |h, k| h[k] = [] }.tap do |result|
    parse_file(property_aliases_data_file) do |data|
      property = data[0]
      result[property] = parse_alias(data)
    end
  end
end
parse_property_value_aliases() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 48
def parse_property_value_aliases
  Hash.new { |h, k| h[k] = [] }.tap do |result|
    parse_file(property_value_aliases_data_file) do |data|
      property_value = data[0]
      result[property_value] << if property_value == 'ccc'
        parse_ccc_value_alias(data)
      else
        parse_value_alias(data)
      end
    end
  end
end
parse_value_alias(data) click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 68
def parse_value_alias(data)
  {
    abbreviated_name: data[1],
    long_name: data[2]
  }
end
property_aliases_data_file() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 83
def property_aliases_data_file
  requirements[:unicode].source_path_for(PROPERTY_ALIASES_FILE)
end
property_value_aliases_data_file() click to toggle source
# File lib/twitter_cldr/resources/unicode_property_aliases_importer.rb, line 87
def property_value_aliases_data_file
  requirements[:unicode].source_path_for(PROPERTY_VALUE_ALIASES_FILE)
end