Class: TwitterCldr::Resources::UnicodeDataImporter

Inherits:
Importer
  • Object
show all
Defined in:
lib/twitter_cldr/resources/unicode_data_importer.rb

Constant Summary collapse

BLOCKS_FILE =
'ucd/Blocks.txt'
UNICODE_DATA_FILE =
'ucd/UnicodeData.txt'
CASEFOLDING_DATA_FILE =
'ucd/CaseFolding.txt'

Constants inherited from Importer

Importer::DEFAULT_ENGINE

Instance Attribute Summary

Attributes inherited from Importer

#params, #requirements

Instance Method Summary collapse

Methods inherited from Importer

#can_import?, default_params, #import, #initialize, locales, output_path, parameter, parameters, #prepare, requirement, requirements, ruby_engine

Constructor Details

This class inherits a constructor from TwitterCldr::Resources::Importer

Instance Method Details

#executeObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/twitter_cldr/resources/unicode_data_importer.rb', line 19

def execute
  blocks           = import_blocks
  unicode_data     = import_unicode_data(blocks)
  casefolding_data = import_casefolding_data

  STDOUT.write('Writing data to disk... ')

  FileUtils.mkdir_p(output_path)

  File.open(File.join(output_path, 'blocks.yml'), 'w') do |output|
    YAML.dump(blocks, output)
  end

  FileUtils.mkdir_p(File.join(output_path, 'blocks'))

  unicode_data.each do |block_name, code_points|
    File.open(File.join(output_path, 'blocks', "#{block_name}.yml"), 'w') do |output|
      YAML.dump(code_points, output)
    end
  end

  File.open(File.join(output_path, 'casefolding.yml'), 'w') do |output|
    YAML.dump(casefolding_data, output)
  end

  puts 'done'
end