Permalink
Browse files

Add function to export the database to a file

  • Loading branch information...
scotchi committed Jul 24, 2012
1 parent 9592360 commit 4dd8866c9b851f2a7368c64f43c4859b7ca63294
Showing with 11 additions and 0 deletions.
  1. +11 −0 Ruby/lib/directededge/updatejob.rb
@@ -60,6 +60,17 @@ def run
end
end
+ def self.export_to_file(database, filename)
+ uri = URI(database.resource.url)
+ Net::HTTP.start(uri.host, uri.port) do |http|
+ request = Net::HTTP::Get.new(uri.request_uri)
+ request.basic_auth(uri.user, uri.password)
+ http.request request do |response|
+ open(filename, 'w') { |io| response.read_body { |chunk| io.write chunk } }
+ end
+ end
+ end
+
def self.import_from_file(database, filename, mode = :replace)
validate_mode(mode)
file = File.open(filename, 'r')

0 comments on commit 4dd8866

Please sign in to comment.