Sha256: d414b9f49e846e25a7a37cb92cea07e9eac024746b3ff811c023f7978e8b9272
Contents?: true
Size: 871 Bytes
Versions: 2
Compression:
Stored size: 871 Bytes
Contents
require 'couch/actions/base' module Couch module Actions class Push < Base def create_database_unless_exists RestClient.put database, nil say "Created database %s" % database rescue RestClient::PreconditionFailed end def push doc = mapper.doc url = url_for(doc["_id"]) say "Pushing to %s..." % url resp = RestClient.put 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| file << "#{rev}\n" end say "Pushed %s" % rev else say "Error occured: %s" % response.inspect end rescue RestClient::Conflict say "Conflict! Try to pull first or delete ./_rev." end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
couch-0.0.4 | lib/couch/actions/push.rb |
couch-0.0.3 | lib/couch/actions/push.rb |