lib/couch/actions/push.rb in couch-0.1.0 vs lib/couch/actions/push.rb in couch-0.1.1
- old
+ new
@@ -1,22 +1,23 @@
-require 'couch/actions/net_base'
+require 'couch/actions/base'
+require 'couch/design_document'
+require "rest_client"
+
module Couch
module Actions
- class Push < NetBase
+ class Push < Base
def create_database_unless_exists
- RestClient.put database, nil
- say "Created database %s" % database
+ RestClient.put DesignDocument.database, nil
+ say "Created database %s" % DesignDocument.database
rescue RestClient::PreconditionFailed
end
def push
- doc = mapper.doc
- url = url_for(doc["_id"])
+ doc = DesignDocument.build_from_filesystem(destination_root)
+ say "Pushing to %s" % DesignDocument.url
- say "Pushing to %s..." % url
-
- resp = RestClient.put url, doc.to_json
+ resp = RestClient.put DesignDocument.url, doc.to_json
response = JSON.parse(resp.body)
if response["ok"]
rev = response["rev"]
File.open File.join(destination_root, "_rev.js"), "w" do |file|