Sha256: a40961899c99419b2ef5f3defdd85bffa15973ca1d37d1f28123eb53088fd729

Contents?: true

Size: 604 Bytes

Versions: 17

Compression:

Stored size: 604 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').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

17 entries across 17 versions & 1 rubygems

Version Path
telephone_number-1.4.7 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.6 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.5 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.4 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.3 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.2 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.1 lib/importers/geo_location_data_importer.rb
telephone_number-1.4.0 lib/importers/geo_location_data_importer.rb
telephone_number-1.3.5 lib/importers/geo_location_data_importer.rb
telephone_number-1.3.4 lib/importers/geo_location_data_importer.rb
telephone_number-1.3.3 lib/importers/geo_location_data_importer.rb
telephone_number-1.3.1 lib/importers/geo_location_data_importer.rb
telephone_number-1.3.0 lib/importers/geo_location_data_importer.rb
telephone_number-1.2.4 lib/importers/geo_location_data_importer.rb
telephone_number-1.2.3 lib/importers/geo_location_data_importer.rb
telephone_number-1.2.2 lib/importers/geo_location_data_importer.rb
telephone_number-1.2.1 lib/importers/geo_location_data_importer.rb