Permalink
Browse files

soca purge deletes the design doc, soca json pretty prints

  • Loading branch information...
quirkey committed Oct 12, 2010
1 parent ffbf215 commit b1798e89931057ba2e18992cae6b183bd5b496ac
Showing with 23 additions and 2 deletions.
  1. +6 −0 lib/soca/cli.rb
  2. +16 −1 lib/soca/pusher.rb
  3. +1 −1 soca.gemspec
View
@@ -172,6 +172,12 @@ def autopush(env = 'default')
end
end
+ desc 'purge [ENV]', "deletes the design document for the database at ENV"
+ def purge(env = 'default')
+ push = pusher(env)
+ push.purge!
+ end
+
private
def appname
@appname = options[:name] || File.basename(appdir)
View
@@ -41,7 +41,7 @@ def build
end
def json
- JSON.generate(build)
+ JSON.pretty_generate(build)
end
def db_url
@@ -90,6 +90,14 @@ def push!
run_hook_file!(:after_push)
end
+ def purge!
+ get_current_revision
+ url = push_url
+ url += "?rev=#{revision}" if revision && revision.length > 0
+ logger.debug "deleting document at #{url}"
+ delete!(url)
+ end
+
def compact!
logger.debug "compacting #{db_url}"
post!("#{db_url}/_compact")
@@ -186,5 +194,12 @@ def post!(url, body = '')
response
end
+ def delete!(url)
+ logger.debug "DELETE #{url}"
+ response = Typhoeus::Request.delete(url)
+ logger.debug "Response: #{response.code} #{response.body[0..200]}"
+ response.code == 200 ? response.body : nil
+ end
+
end
end
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Aaron Quint"]
- s.date = %q{2010-10-04}
+ s.date = %q{2010-10-11}
s.default_executable = %q{soca}
s.description = %q{soca is a different way of writing apps for CouchDB. The structure is up to you.}
s.email = %q{aaron@quirkey.com}

0 comments on commit b1798e8

Please sign in to comment.