Sha256: 911e503ad9c94b6c476efa171abf3aedb614cc71313675addf8eb2144d1025f3
Contents?: true
Size: 1.06 KB
Versions: 21
Compression:
Stored size: 1.06 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 require 'nokogiri' require 'open-uri' module TwitterCldr module Resources class CurrencySymbolsImporter < Importer URL = 'https://www.xe.com/symbols.php'.freeze output_path 'shared' ruby_engine :mri private def execute path = File.join(params[:output_path], 'iso_currency_symbols.yml') File.open(path, 'w:utf-8') do |output| output.write( TwitterCldr::Utils::YAML.dump( TwitterCldr::Utils.deep_symbolize_keys(symbol_data), use_natural_symbols: true ) ) end end def symbol_data doc = Nokogiri::HTML(URI.open(URL).read) rows = doc.css('.currencySymblTable tr') rows[1..-1].each_with_object({}) do |row, ret| code = row.css('td')[1].text symbol = row.css('td.cSmbl_Fnt_C2000').text ret[code] = { code_points: symbol.codepoints, symbol: symbol } end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems