gom-couchdb-adapter 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +2 -0
- data/spec/lib/gom/storage/couchdb/view/pusher_spec.rb +16 -15
- data/spec/spec_helper.rb +3 -3
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
The CouchDB adapter for the Generic Object Mapper (http://github.com/phifty/gom) provides an easy way store and fetch
|
5
5
|
object data to/from a CouchDB server. Object properties are mapped as well as object relations.
|
6
6
|
|
7
|
+
http://travis-ci.org/phifty/gom-couchdb-adapter.png
|
8
|
+
|
7
9
|
== Configuration
|
8
10
|
|
9
11
|
If the couchdb adapter is chosen in the storage configuration, the following configuration values should be specified.
|
@@ -5,9 +5,9 @@ describe GOM::Storage::CouchDB::View::Pusher do
|
|
5
5
|
before :each do
|
6
6
|
@database = mock CouchDB::Database
|
7
7
|
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@view_hash = { "test_class_view" => @
|
8
|
+
@class_view_configuration = GOM::Storage::Configuration::View::Class.new "Object"
|
9
|
+
@map_reduce_view_configuration = GOM::Storage::Configuration::View::MapReduce.new "function(document) { }", "function(key, values) { }"
|
10
|
+
@view_hash = { "test_class_view" => @class_view_configuration, "test_map_reduce_view" => @map_reduce_view_configuration }
|
11
11
|
|
12
12
|
@pusher = described_class.new @database, @view_hash
|
13
13
|
end
|
@@ -16,15 +16,18 @@ describe GOM::Storage::CouchDB::View::Pusher do
|
|
16
16
|
|
17
17
|
before :each do
|
18
18
|
@design = mock CouchDB::Design, :views => mock(CouchDB::Design::ViewsProxy, :<< => nil), :save => true
|
19
|
-
CouchDB::Design.stub
|
19
|
+
CouchDB::Design.stub :new => @design
|
20
20
|
|
21
|
-
@
|
22
|
-
CouchDB::Design::View
|
21
|
+
@class_view = mock CouchDB::Design::View
|
22
|
+
@map_reduce_view = mock CouchDB::Design::View
|
23
|
+
CouchDB::Design::View.stub :new do |design, name, map_function, reduce_function|
|
24
|
+
{ "test_class_view" => @class_view, "test_map_reduce_view" => @map_reduce_view }[name]
|
25
|
+
end
|
23
26
|
|
24
27
|
@class_map_reduce_view = mock GOM::Storage::Configuration::View::MapReduce,
|
25
28
|
:map => "function(document) { }", :reduce => nil
|
26
29
|
@builder = mock GOM::Storage::CouchDB::View::Builder, :map_reduce_view => @class_map_reduce_view
|
27
|
-
GOM::Storage::CouchDB::View::Builder.stub
|
30
|
+
GOM::Storage::CouchDB::View::Builder.stub :new => @builder
|
28
31
|
end
|
29
32
|
|
30
33
|
it "should initialize the design document" do
|
@@ -33,24 +36,22 @@ describe GOM::Storage::CouchDB::View::Pusher do
|
|
33
36
|
end
|
34
37
|
|
35
38
|
it "should initialize the builder with the class view" do
|
36
|
-
GOM::Storage::CouchDB::View::Builder.should_receive(:new).with(@
|
39
|
+
GOM::Storage::CouchDB::View::Builder.should_receive(:new).with(@class_view_configuration).and_return(@builder)
|
37
40
|
@pusher.perform
|
38
41
|
end
|
39
42
|
|
40
|
-
it "should use the builder to
|
43
|
+
it "should use the builder to generate a map reduce view out of the class view" do
|
41
44
|
@builder.should_receive(:map_reduce_view).and_return(@class_map_reduce_view)
|
42
45
|
@pusher.perform
|
43
46
|
end
|
44
47
|
|
45
|
-
it "should
|
46
|
-
|
47
|
-
CouchDB::Design::View.should_receive(:new).once.and_return(@view)
|
48
|
+
it "should add the generated map reduce view" do
|
49
|
+
@design.views.should_receive(:<<).with(@class_view)
|
48
50
|
@pusher.perform
|
49
51
|
end
|
50
52
|
|
51
|
-
it "should
|
52
|
-
|
53
|
-
CouchDB::Design::View.should_receive(:new).with(@design, "test_map_reduce_view", "function(document) { }", "function(key, values) { }").and_return(@view)
|
53
|
+
it "should add the map reduce view" do
|
54
|
+
@design.views.should_receive(:<<).with(@map_reduce_view)
|
54
55
|
@pusher.perform
|
55
56
|
end
|
56
57
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,12 +15,12 @@ GOM::Storage.configure {
|
|
15
15
|
create_database_if_missing true
|
16
16
|
view {
|
17
17
|
name :test_object_class_view
|
18
|
-
|
18
|
+
kind :class
|
19
19
|
model_class GOM::Spec::Object
|
20
20
|
}
|
21
21
|
view {
|
22
22
|
name :test_map_view
|
23
|
-
|
23
|
+
kind :map_reduce
|
24
24
|
map_function """
|
25
25
|
function(document) {
|
26
26
|
if (document['number'] == 11) {
|
@@ -31,7 +31,7 @@ GOM::Storage.configure {
|
|
31
31
|
}
|
32
32
|
view {
|
33
33
|
name :test_map_reduce_view
|
34
|
-
|
34
|
+
kind :map_reduce
|
35
35
|
map_function """
|
36
36
|
function(document) {
|
37
37
|
if (document['number']) {
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gom-couchdb-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- "Philipp Br\xC3\xBCll"
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-30 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ">="
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.4.
|
24
|
+
version: 0.4.1
|
25
25
|
type: :runtime
|
26
26
|
version_requirements: *id001
|
27
27
|
- !ruby/object:Gem::Dependency
|