eee-c-couch_docs 0.9.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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)
@@ -9,13 +9,36 @@ Manage CouchDB views and documents.
9
9
 
10
10
  == FEATURES/PROBLEMS:
11
11
 
12
- * Store your CouchDB documents on the filesystem for on-demand
13
- upload. Design documents are kept in a <tt>_design</tt>
14
- sub-directory, with <tt>.js</tt> extensions. Normal documents are
15
- stored with a <tt>.json</tt> extension.
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
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{couch_docs}
5
- s.version = "0.9.0"
5
+ s.version = "1.0.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chris Strom"]
@@ -1,7 +1,7 @@
1
1
  module CouchDocs
2
2
 
3
3
  # :stopdoc:
4
- VERSION = '0.9.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,
@@ -57,7 +57,7 @@ module CouchDocs
57
57
 
58
58
  def each
59
59
  Store.get("#{url}/_all_docs")['rows'].each do |rec|
60
- yield Store.get("#{url}/#{rec['id']}")
60
+ yield Store.get("#{url}/#{rec['id']}?attachments=true")
61
61
  end
62
62
  end
63
63
  end
@@ -62,13 +62,22 @@ describe CouchDocs do
62
62
 
63
63
  CouchDocs.dump("uri", "fixtures")
64
64
  end
65
- it "should be able to store all CouchDB documents on the filesystem" do
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eee-c-couch_docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Strom