Class: TwitterCldr::Resources::UnicodePropertiesImporter
- Inherits:
-
UnicodeImporter
- Object
- UnicodeImporter
- TwitterCldr::Resources::UnicodePropertiesImporter
- Defined in:
- lib/twitter_cldr/resources/unicode_properties_importer.rb
Constant Summary collapse
- PROPERTIES_BASE_URL =
'ftp://ftp.unicode.org/Public/UCD/latest/ucd'
- PROPERTIES =
[ "auxiliary/SentenceBreakProperty", "auxiliary/WordBreakProperty", "LineBreak" ]
Instance Method Summary collapse
- #import ⇒ Object
-
#initialize(input_path, output_path) ⇒ UnicodePropertiesImporter
constructor
Arguments:.
Constructor Details
#initialize(input_path, output_path) ⇒ UnicodePropertiesImporter
Arguments:
input_path - path to a directory containing the various property files
output_path - output directory for imported YAML files
25 26 27 28 |
# File 'lib/twitter_cldr/resources/unicode_properties_importer.rb', line 25 def initialize(input_path, output_path) @input_path = input_path @output_path = output_path end |
Instance Method Details
#import ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/twitter_cldr/resources/unicode_properties_importer.rb', line 30 def import FileUtils.mkdir_p(@output_path) PROPERTIES.each do |property| input_file = property_data_file("#{property}.txt") output_file = File.join(@output_path, "#{fix_name(property)}.yml") File.open(output_file, "w+") do |f| f.write( YAML.dump( parse_standard_file(input_file).inject({}) do |ret, data| name = data[1].strip.to_sym ret[name] ||= [] ret[name] += (data[0]) ret end.inject({}) do |ret, (key, data)| ret[key] = TwitterCldr::Utils::RangeSet.rangify(data) ret end ) ) end end end |