25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/free_zipcode_data/runner.rb', line 25
def start
start_time = Time.now
opt = FreeZipcodeData::Options.instance
opt.initialize_hash(collect_args)
@options = opt.hash
logger.info("Starting FreeZipcodeData v#{VERSION}...".green)
datasource = DataSource.new(options.country)
datasource.download
db_file = File.join(options.work_dir, 'free_zipcode_data.sqlite3')
database = SqliteRam.new(db_file)
line_count = datasource_line_count(datasource.datafile)
configure_meta(database.conn, line_count)
%i[country state county zipcode].each { |t| initialize_table(t, database) }
(datasource, database)
logger.info("Saving database to disk '#{db_file}'...")
database.save_to_disk
if options.generate_files
logger.info('Generating .csv files...')
database.dump_tables(options.work_dir)
end
elapsed = Time.at(Time.now - start_time).utc.strftime('%H:%M:%S')
logger.info("Processed #{line_count} zipcodes in [#{elapsed}].".yellow)
end
|