Sha256: e47eb77deff09a617cd82c9512b0c492587a7cd30c8838eacf1bd9837a50b582
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
module Hatchy module CountryImporter def self.import t1 = Thread.new{ import_countries puts "]" } progress = 'Progress [' while t1.status progress << "." print "\r" print progress $stdout.flush sleep 0.2 end puts "Done!" end def self.import_countries eu_members = ['Austria', 'Belgium', 'Bulgaria', 'Croatia','Cyprus','Czech Republic','Denmark','Estonia','Finland','France','Germany','Greece','Hungary','Ireland','Italy','Latvia','Lithuania','Luxembourg','Malta','Netherlands','Poland','Portugal','Romania','Slovakia','Slovenia','Spain','Sweden','United Kingdom'] countries = File.read(File.join(Hatchy.root, 'db', 'countries.txt')).gsub(/\r/, "\n").split("\n").map { |c| c.split(/\t/) } countries.each do |code2, code3, name, continent, tld, currency| country = Hatchy::Country.new(:name => name, :code2 => code2, :code3 => code3, :continent => continent, :tld => tld.gsub('.', ''), :currency => currency) country.eu_member = true if eu_members.map(&:upcase).include?(name.upcase) country.save end end end end
Version data entries
4 entries across 4 versions & 1 rubygems