simply_stored 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -274,5 +274,18 @@ module SimplyStored
274
274
  end
275
275
 
276
276
  end
277
+
278
+ def self.delete_all_design_documents(database)
279
+ db = CouchRest.database(database)
280
+ db.info # ensure DB exists
281
+ design_docs = CouchRest.get("#{database}/_all_docs?startkey=%22_design%22&endkey=%22_design0%22")['rows'].map do |row|
282
+ [row['id'], row['value']['rev']]
283
+ end
284
+ design_docs.each do |doc_id, rev|
285
+ db.delete_doc({'_id' => doc_id, '_rev' => rev})
286
+ end
287
+ design_docs.size
288
+ end
289
+
277
290
  end
278
291
  end
@@ -0,0 +1,12 @@
1
+ namespace :simply_stored do
2
+ desc "delete all design documents"
3
+ task :delete_design_documents do
4
+ require File.dirname(__FILE__) + "/couch"
5
+ if database = ENV['DATABASE']
6
+ deleted = SimplyStored::Couch.delete_all_design_documents(database)
7
+ puts "deleted #{deleted} design documents in #{database}"
8
+ else
9
+ puts "please specify which database to clear: DATABASE=http://localhost:5984/simply_stored rake simply_stored:delete_design_documents"
10
+ end
11
+ end
12
+ end
@@ -7,6 +7,17 @@ class CouchTest < Test::Unit::TestCase
7
7
  CouchPotato::Config.database_name = 'simply_stored_test'
8
8
  recreate_db
9
9
  end
10
+
11
+ context "design documents" do
12
+ should "delete all" do
13
+ db = "http://localhost:5984/#{CouchPotato::Config.database_name}"
14
+ assert_equal 0, SimplyStored::Couch.delete_all_design_documents(db)
15
+ user = User.create
16
+ Post.create(:user => user)
17
+ user.posts
18
+ assert_equal 1, SimplyStored::Couch.delete_all_design_documents(db)
19
+ end
20
+ end
10
21
 
11
22
  context "when creating instances" do
12
23
  should "populate the attributes" do
data/test/test_helper.rb CHANGED
@@ -19,4 +19,4 @@ class Test::Unit::TestCase
19
19
  CouchPotato.couchrest_database.server.create_db CouchPotato::Config.database_name
20
20
  end
21
21
 
22
- end
22
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simply_stored
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Meyer, Jonathan Weiss
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-12 00:00:00 +01:00
12
+ date: 2010-02-13 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -56,6 +56,7 @@ files:
56
56
  - lib/simply_stored/couch/views.rb
57
57
  - lib/simply_stored/couch/views/array_property_view_spec.rb
58
58
  - lib/simply_stored/instance_methods.rb
59
+ - lib/simply_stored/rake.rb
59
60
  - lib/simply_stored/simpledb.rb
60
61
  - lib/simply_stored/simpledb/associations.rb
61
62
  - lib/simply_stored/simpledb/attributes.rb