in lib/twitter_cldr/resources/tailoring_importer.rb [143:178]
def parse_tailorings(data, locale)
rules = data && data.at_xpath('rules')
return '' unless rules
collator = collator_class.get_instance(Java::JavaUtil::Locale.new(locale.to_s))
rules.children.map do |child|
validate_tailoring_rule(child)
if child.name =~ LEVEL_RULE_REGEXP
if $2.empty?
table_entry_for_rule(collator, child.text)
else
child.text.chars.map { |char| table_entry_for_rule(collator, char) }
end
elsif child.name == 'x'
context = ''
child.children.inject([]) do |memo, c|
if SIMPLE_RULES.include?(c.name)
memo << table_entry_for_rule(collator, context + c.text)
elsif c.name == 'context'
context = c.text
elsif c.name == 'comment'
elsif c.name != 'extend'
raise ImportError, "Rule '#{c.name}' inside <x></x> is not supported."
end
memo
end
else
raise ImportError, "Tag '#{child.name}' is not supported." unless IGNORED_TAGS.include?(child.name)
end
end.flatten.compact.join("\n")
end