Class: Phonelib::DataImporter::Importer

Inherits:
Object
  • Object
show all
Includes:
Phonelib::DataImporterHelper
Defined in:
lib/phonelib/data_importer.rb

Overview

class with functionality for importing data

Constant Summary collapse

DOUBLE_COUNTRY_CODES_COUNTRIES =

countries that can have double country prefix in number

%w(IN DE BR)
MAIN_FILE =

main data file in repo

'resources/PhoneNumberMetadata.xml'
SHORT_DATA_FILE =

short number metadata

'resources/ShortNumberMetadata.xml'
FORMATS_FILE =

alternate formats data file in repo

'resources/PhoneNumberAlternateFormats.xml'
GEOCODING_DIR =

geocoding data dir in repo

'resources/geocoding/en/'
CARRIER_DIR =

carrier data dir in repo

'resources/carrier/en/'
TIMEZONES_DIR =

timezones data dir in repo

'resources/timezones/'

Constants included from Phonelib::DataImporterHelper

Phonelib::DataImporterHelper::XML_COMMENT_ATTRIBUTES, Phonelib::DataImporterHelper::XML_FORMAT_NAMES

Instance Method Summary collapse

Methods included from Phonelib::DataImporterHelper

#camel2snake, #fill_prefixes, #get_hash_from_xml, #is_not_format, #main_from_xml, #name2sym, #parse_raw_file, #str_clean, #without_comments

Constructor Details

#initializeImporter

class initialization method



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/phonelib/data_importer.rb', line 37

def initialize
  @destination = File.path(
      "#{File.dirname(__FILE__)}/../../data/libphonenumber/")
  @data = {}
  @prefixes = {}
  @geo_names = []
  @timezones = []
  @carriers = []

  clone_repo
  import_main_data
  import_short_data
  import_alternate_formats
  import_geocoding_data
  import_timezone_data
  import_carrier_data
  save_data_file
end