aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/postcodes-norway.rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/postcodes-norway.rake')
-rw-r--r--lib/tasks/postcodes-norway.rake13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/tasks/postcodes-norway.rake b/lib/tasks/postcodes-norway.rake
new file mode 100644
index 0000000..6ec53b7
--- /dev/null
+++ b/lib/tasks/postcodes-norway.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