lib/tasks/phonelib_tasks.rake in phonelib-0.2.6 vs lib/tasks/phonelib_tasks.rake in phonelib-0.2.7
- old
+ new
@@ -1,11 +1,10 @@
namespace :phonelib do
desc 'Import and reparse original data file from Google libphonenumber'
task :import_data do
require 'net/http'
- require 'yaml'
require 'nokogiri'
# get metadata from google
url = 'http://libphonenumber.googlecode.com/svn/trunk/resources/PhoneNumberMetadata.xml'
xml_data = Net::HTTP.get_response(URI.parse(url)).body
@@ -64,12 +63,11 @@
end
end
countries.push(country)
end
- target = 'data/phone_data.yml'
- File.open(target, 'w+') do |f|
- f.write(countries.to_yaml)
+ File.open('data/phone_data.dat', 'wb+') do |f|
+ Marshal.dump(countries, f)
end
end
def camel2snake(s)
s.gsub(/[A-Z]+/) { |m| "_#{m.downcase}" }