eee-c-couch_docs 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/README.rdoc +32 -5
- data/couch_docs.gemspec +1 -1
- data/lib/couch_docs.rb +2 -2
- data/lib/couch_docs/store.rb +1 -1
- data/spec/couch_docs_spec.rb +12 -3
- metadata +1 -1
data/History.txt
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== 1.0.0 / 2009-08-09
|
2
|
+
|
3
|
+
* Update the couch-docs script to be able to dump a CouchDB database
|
4
|
+
to a local directory as well as uploading a local directory into a
|
5
|
+
CouchDB database.
|
6
|
+
|
7
|
+
* CouchDB revision numbers are stripped when dumping (to prevent
|
8
|
+
conflicts when re-loading)
|
9
|
+
|
10
|
+
* Attachments are dumped as well.
|
11
|
+
|
1
12
|
== 0.9.0 / 2009-08-08
|
2
13
|
|
3
14
|
* Import from couch_design_docs (name change to reflect increased functionality)
|
data/README.rdoc
CHANGED
@@ -9,13 +9,36 @@ Manage CouchDB views and documents.
|
|
9
9
|
|
10
10
|
== FEATURES/PROBLEMS:
|
11
11
|
|
12
|
-
*
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
* Upload JSON documents stored on the filesystem into a CouchDB
|
13
|
+
database.
|
14
|
+
|
15
|
+
* Map <tt>.js</tt> files stored on the filesystem
|
16
|
+
(e.g. <tt>_design/recipes/count_by_month/map.js</tt>) into CouchDB
|
17
|
+
design documents.
|
18
|
+
|
19
|
+
* Dump documents stored in CouchDB to the filesystem.
|
20
|
+
|
21
|
+
* Script (couch-docs) to restore / backup CouchDB database.
|
22
|
+
|
23
|
+
* The couch-docs scipts does not work with design documents.
|
24
|
+
|
25
|
+
* A progress bar would be helpful.
|
26
|
+
|
27
|
+
* Unit testing of view javascript would be very nice.
|
16
28
|
|
17
29
|
== SYNOPSIS:
|
18
30
|
|
31
|
+
From the command line:
|
32
|
+
|
33
|
+
# For dumping the contents of a CouchDB database to the filesystem
|
34
|
+
couch-docs dump "http://localhost:5984/db" path/to/dump_dir/
|
35
|
+
|
36
|
+
# For loading documents from the filesystem into CouchDB
|
37
|
+
couch-docs load path/to/dump_dir/ "http://localhost:5984/db"
|
38
|
+
|
39
|
+
|
40
|
+
In code:
|
41
|
+
|
19
42
|
DB_URL = "http://localhost:5984/db"
|
20
43
|
DIRECTORY = "/repos/db/couchdb/"
|
21
44
|
|
@@ -30,6 +53,10 @@ Manage CouchDB views and documents.
|
|
30
53
|
# a document named "foo" with the JSON contents from the foo.json
|
31
54
|
# file
|
32
55
|
|
56
|
+
CouchDocs.dump(DB_URL, "/repos/db/bak")
|
57
|
+
|
58
|
+
# => JSON dump of every document at DB_URL
|
59
|
+
|
33
60
|
== REQUIREMENTS:
|
34
61
|
|
35
62
|
* CouchDB
|
@@ -38,7 +65,7 @@ Manage CouchDB views and documents.
|
|
38
65
|
|
39
66
|
== INSTALL:
|
40
67
|
|
41
|
-
* sudo gem install couch_docs
|
68
|
+
* sudo gem install eee-c-couch_docs
|
42
69
|
|
43
70
|
== LICENSE:
|
44
71
|
|
data/couch_docs.gemspec
CHANGED
data/lib/couch_docs.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module CouchDocs
|
2
2
|
|
3
3
|
# :stopdoc:
|
4
|
-
VERSION = '0.
|
4
|
+
VERSION = '1.0.0'
|
5
5
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
6
6
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
7
7
|
# :startdoc:
|
@@ -55,7 +55,7 @@ module CouchDocs
|
|
55
55
|
store.
|
56
56
|
map.
|
57
57
|
reject { |doc| doc['_id'] =~ /^_design/ }.
|
58
|
-
each { |doc| dir.store_document(doc) }
|
58
|
+
each { |doc| doc.delete('_rev'); dir.store_document(doc) }
|
59
59
|
end
|
60
60
|
|
61
61
|
# Returns the library path for the module. If any arguments are given,
|
data/lib/couch_docs/store.rb
CHANGED
data/spec/couch_docs_spec.rb
CHANGED
@@ -62,13 +62,22 @@ describe CouchDocs do
|
|
62
62
|
|
63
63
|
CouchDocs.dump("uri", "fixtures")
|
64
64
|
end
|
65
|
-
it "should
|
65
|
+
it "should ignore design documents" do
|
66
66
|
@store.stub!(:map).and_return([{'_id' => '_design/foo'}])
|
67
67
|
@dir.
|
68
68
|
should_not_receive(:store_document)
|
69
69
|
|
70
70
|
CouchDocs.dump("uri", "fixtures")
|
71
71
|
end
|
72
|
+
it "should strip revision numbers" do
|
73
|
+
@store.stub!(:map).
|
74
|
+
and_return([{'_id' => 'foo', '_rev' => '1-1234'}])
|
75
|
+
@dir.
|
76
|
+
should_receive(:store_document).
|
77
|
+
with({'_id' => 'foo'})
|
78
|
+
|
79
|
+
CouchDocs.dump("uri", "fixtures")
|
80
|
+
end
|
72
81
|
end
|
73
82
|
end
|
74
83
|
|
@@ -162,8 +171,8 @@ describe Store do
|
|
162
171
|
"rows" => [{"id"=>"1", "value"=>{}, "key"=>"1"},
|
163
172
|
{"id"=>"2", "value"=>{}, "key"=>"2"}]})
|
164
173
|
|
165
|
-
Store.stub!(:get).with("uri/1")
|
166
|
-
Store.should_receive(:get).with("uri/2")
|
174
|
+
Store.stub!(:get).with("uri/1?attachments=true")
|
175
|
+
Store.should_receive(:get).with("uri/2?attachments=true")
|
167
176
|
|
168
177
|
@it.each { }
|
169
178
|
end
|