diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2015-01-23 15:21:58 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2015-01-23 15:21:58 +0100 |
commit | 92550c7649bc86692b3b9951233bb92d2a9900ff (patch) | |
tree | ad6aac3477fb793e041d7ca7f9ec2ab1b3fb5bd2 /lib/tasks | |
parent | 58b5650ca1e0ba4388d67d3d19edce16594ea3f8 (diff) | |
download | postcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.tar.gz postcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.tar.bz2 postcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.zip |
Add task to fetch postcodes from Bring.
Diffstat (limited to 'lib/tasks')
-rw-r--r-- | lib/tasks/norwegian-postcodes.rake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/tasks/norwegian-postcodes.rake b/lib/tasks/norwegian-postcodes.rake index e69de29..6ec53b7 100644 --- a/lib/tasks/norwegian-postcodes.rake +++ b/lib/tasks/norwegian-postcodes.rake @@ -0,0 +1,13 @@ +require 'uri' +require 'open-uri' + +namespace :postcodes do + desc "Fetch postcode database from Bring" + task :fetch, [:data_path] do |t, args| + args.with_defaults(:data_path => 'data') + uri = URI.parse('http://www.bring.no/hele-bring/forside/_attachment/159761') + filename = File.join(args.data_path, 'Postnummerregister_ansi.txt') + puts "Downloading postcodes to: #{filename}..." + IO.write(filename, uri.read) + end +end |