Sha256: e5bbf9d5185be205b89bb24ecc1ed1448cf4bc476fedac1032b29d82211b3ff6

Contents?: true

Size: 610 Bytes

Versions: 14

Compression:

Stored size: 610 Bytes

Contents

module TelephoneNumber
  class GeoLocationDataImporter
    def self.load_data!
      Dir.glob("data/geocoding/**/*.txt").each { |file| process_file(file) }
    end

    def self.process_file(file_path)
      master_data = {}
      bin_file_path = "#{File.dirname(file_path)}/#{File.basename(file_path, '.txt')}.dat"

      File.open(file_path, 'r:UTF-8').each do |row|
        next if row.strip !~ /^[0-9]/
        number, location = row.split('|')
        master_data[number.strip] = location.strip
      end

      File.open(bin_file_path, 'wb'){ |file| file << Marshal.dump(master_data) }
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
telephone_number-1.4.22 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.21 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.20 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.19 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.18 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.16 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.15 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.14 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.13 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.12 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.11 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.10 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.9 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.8 lib/importers/geo_location_data_importer.rb