aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-01-23 15:21:58 +0100
committerHarald Eilertsen <haraldei@anduin.net>2015-01-23 15:21:58 +0100
commit92550c7649bc86692b3b9951233bb92d2a9900ff (patch)
treead6aac3477fb793e041d7ca7f9ec2ab1b3fb5bd2
parent58b5650ca1e0ba4388d67d3d19edce16594ea3f8 (diff)
downloadpostcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.tar.gz
postcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.tar.bz2
postcodes-norway-92550c7649bc86692b3b9951233bb92d2a9900ff.zip
Add task to fetch postcodes from Bring.
-rw-r--r--Rakefile2
-rw-r--r--lib/tasks/norwegian-postcodes.rake13
2 files changed, 15 insertions, 0 deletions
diff --git a/Rakefile b/Rakefile
index f8af56e..13a7fc7 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,3 +1,5 @@
+load 'lib/tasks/norwegian-postcodes.rake'
+
desc "Run unit tests"
task "test" do
sh 'ruby -Itest/ test/*.rb'
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