gom-couchdb-adapter 0.2.0 → 0.3.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.
@@ -93,3 +93,8 @@ Development has been done test-driven and the code follows at most the Clean Cod
93
93
  removed by using the reek[http://github.com/kevinrutherford/reek] code smell detector.
94
94
 
95
95
  The project is still experimental and under development. Any bug report and contribution is welcome!
96
+
97
+ == Support
98
+
99
+ Apart from contribution, support via Flattr[http://flattr.com/thing/108997/Generic-Object-Mapper-CouchDB-adapter]
100
+ is welcome.
data/Rakefile CHANGED
@@ -35,7 +35,7 @@ end
35
35
 
36
36
  desc "Run all specs in spec directory"
37
37
  RSpec::Core::RakeTask.new do |task|
38
- task.pattern = "spec/gom/**/*_spec.rb"
38
+ task.pattern = "spec/lib/**/*_spec.rb"
39
39
  end
40
40
 
41
41
  namespace :spec do
@@ -1,5 +1,5 @@
1
1
  require 'gom'
2
2
  require 'couchdb'
3
- require File.join(File.dirname(__FILE__), "gom", "storage")
3
+ require File.join(File.dirname(__FILE__), "storage")
4
4
 
5
5
  GOM::Storage::Adapter.register :couchdb, GOM::Storage::CouchDB::Adapter
@@ -1,20 +1,12 @@
1
1
 
2
- module GOM
3
-
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- autoload :Adapter, File.join(File.dirname(__FILE__), "couchdb", "adapter")
9
- autoload :Collection, File.join(File.dirname(__FILE__), "couchdb", "collection")
10
- autoload :Fetcher, File.join(File.dirname(__FILE__), "couchdb", "fetcher")
11
- autoload :Draft, File.join(File.dirname(__FILE__), "couchdb", "draft")
12
- autoload :Saver, File.join(File.dirname(__FILE__), "couchdb", "saver")
13
- autoload :Remover, File.join(File.dirname(__FILE__), "couchdb", "remover")
14
- autoload :View, File.join(File.dirname(__FILE__), "couchdb", "view")
15
-
16
- end
17
-
18
- end
2
+ module GOM::Storage::CouchDB
3
+
4
+ autoload :Adapter, File.join(File.dirname(__FILE__), "couchdb", "adapter")
5
+ autoload :Collection, File.join(File.dirname(__FILE__), "couchdb", "collection")
6
+ autoload :Fetcher, File.join(File.dirname(__FILE__), "couchdb", "fetcher")
7
+ autoload :Draft, File.join(File.dirname(__FILE__), "couchdb", "draft")
8
+ autoload :Saver, File.join(File.dirname(__FILE__), "couchdb", "saver")
9
+ autoload :Remover, File.join(File.dirname(__FILE__), "couchdb", "remover")
10
+ autoload :View, File.join(File.dirname(__FILE__), "couchdb", "view")
19
11
 
20
12
  end
@@ -1,72 +1,76 @@
1
1
 
2
- module GOM
2
+ # The couchdb storage adapter.
3
+ class GOM::Storage::CouchDB::Adapter < GOM::Storage::Adapter
3
4
 
4
- module Storage
5
+ attr_reader :server
6
+ attr_reader :database
5
7
 
6
- module CouchDB
7
-
8
- # The couchdb storage adapter.
9
- class Adapter < GOM::Storage::Adapter
10
-
11
- def setup
12
- initialize_server
13
- initialize_database
14
- setup_database
15
- push_design
16
- end
8
+ def setup
9
+ initialize_server
10
+ initialize_database
11
+ setup_database
12
+ push_design
13
+ end
17
14
 
18
- def fetch(id)
19
- Fetcher.new(@database, id, revisions).draft
20
- end
15
+ def teardown
16
+ clear_server
17
+ clear_database
18
+ end
21
19
 
22
- def store(draft)
23
- saver = Saver.new @database, draft, revisions, configuration.name
24
- saver.perform
25
- saver.id
26
- end
20
+ def fetch(id)
21
+ GOM::Storage::CouchDB::Fetcher.new(@database, id, revisions).draft
22
+ end
27
23
 
28
- def remove(id)
29
- remover = Remover.new @database, id, revisions
30
- remover.perform
31
- end
24
+ def store(draft)
25
+ saver = GOM::Storage::CouchDB::Saver.new @database, draft, revisions, configuration.name
26
+ saver.perform
27
+ saver.id
28
+ end
32
29
 
33
- def collection(name, options = { })
34
- view = @design.views[name.to_s]
35
- raise ViewNotFoundError, "there are no view with the name #{name}" unless view
36
- fetcher = Collection::Fetcher.new view, options
37
- GOM::Object::Collection.new fetcher
38
- end
30
+ def remove(id)
31
+ remover = GOM::Storage::CouchDB::Remover.new @database, id, revisions
32
+ remover.perform
33
+ end
39
34
 
40
- def revisions
41
- @revisions ||= { }
42
- end
35
+ def collection(name, options = { })
36
+ view = @design.views[name.to_s]
37
+ raise ViewNotFoundError, "there are no view with the name #{name}" unless view
38
+ fetcher = GOM::Storage::CouchDB::Collection::Fetcher.new view, options
39
+ GOM::Object::Collection.new fetcher
40
+ end
43
41
 
44
- private
42
+ def revisions
43
+ @revisions ||= { }
44
+ end
45
45
 
46
- def initialize_server
47
- @server = ::CouchDB::Server.new *configuration.values_at(:host, :port).compact
48
- end
46
+ private
49
47
 
50
- def initialize_database
51
- @database = ::CouchDB::Database.new *[ @server, configuration[:database] ].compact
52
- end
48
+ def initialize_server
49
+ @server = ::CouchDB::Server.new *configuration.values_at(:host, :port).compact
50
+ end
53
51
 
54
- def setup_database
55
- delete_database_if_exists, create_database_if_missing = configuration.values_at :delete_database_if_exists, :create_database_if_missing
56
- @database.delete_if_exists! if delete_database_if_exists
57
- @database.create_if_missing! if create_database_if_missing
58
- end
52
+ def clear_server
53
+ @server = nil
54
+ end
59
55
 
60
- def push_design
61
- pusher = View::Pusher.new @database, configuration.views
62
- pusher.perform
63
- @design = pusher.design
64
- end
56
+ def initialize_database
57
+ @database = ::CouchDB::Database.new *[ @server, configuration[:database] ].compact
58
+ end
65
59
 
66
- end
60
+ def clear_database
61
+ @database = nil
62
+ end
67
63
 
68
- end
64
+ def setup_database
65
+ delete_database_if_exists, create_database_if_missing = configuration.values_at :delete_database_if_exists, :create_database_if_missing
66
+ @database.delete_if_exists! if delete_database_if_exists
67
+ @database.create_if_missing! if create_database_if_missing
68
+ end
69
69
 
70
+ def push_design
71
+ pusher = GOM::Storage::CouchDB::View::Pusher.new @database, configuration.views
72
+ pusher.perform
73
+ @design = pusher.design
70
74
  end
71
75
 
72
76
  end
@@ -1,18 +1,6 @@
1
1
 
2
- module GOM
2
+ module GOM::Storage::CouchDB::Collection
3
3
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module Collection
9
-
10
- autoload :Fetcher, File.join(File.dirname(__FILE__), "collection", "fetcher")
11
-
12
- end
13
-
14
- end
15
-
16
- end
4
+ autoload :Fetcher, File.join(File.dirname(__FILE__), "collection", "fetcher")
17
5
 
18
6
  end
@@ -1,49 +1,33 @@
1
1
 
2
- module GOM
2
+ # Fetches a result-set of a CouchDB view and provides it to a GOM collection.
3
+ class GOM::Storage::CouchDB::Collection::Fetcher
3
4
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module Collection
9
-
10
- # Fetches a result-set of a CouchDB view and provides it to a GOM collection.
11
- class Fetcher
12
-
13
- def initialize(view, options)
14
- @view, @options = view, options
15
- end
16
-
17
- def drafts
18
- return nil if @view.reduce
19
- fetch_collection
20
- fetch_drafts
21
- @drafts
22
- end
23
-
24
- def rows
25
- fetch_collection
26
- @collection
27
- end
28
-
29
- private
5
+ def initialize(view, options)
6
+ @view, @options = view, options
7
+ end
30
8
 
31
- def fetch_collection
32
- @collection = @view.collection @options
33
- end
9
+ def drafts
10
+ return nil if @view.reduce
11
+ fetch_collection
12
+ fetch_drafts
13
+ @drafts
14
+ end
34
15
 
35
- def fetch_drafts
36
- @drafts = @collection.documents.map do |document|
37
- GOM::Storage::CouchDB::Draft::Builder.new(document).draft
38
- end
39
- end
16
+ def rows
17
+ fetch_collection
18
+ @collection
19
+ end
40
20
 
41
- end
21
+ private
42
22
 
43
- end
23
+ def fetch_collection
24
+ @collection = @view.collection @options
25
+ end
44
26
 
27
+ def fetch_drafts
28
+ @drafts = @collection.documents.map do |document|
29
+ GOM::Storage::CouchDB::Draft::Builder.new(document).draft
45
30
  end
46
-
47
31
  end
48
32
 
49
33
  end
@@ -1,18 +1,6 @@
1
1
 
2
- module GOM
2
+ module GOM::Storage::CouchDB::Draft
3
3
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module Draft
9
-
10
- autoload :Builder, File.join(File.dirname(__FILE__), "draft", "builder")
11
-
12
- end
13
-
14
- end
15
-
16
- end
4
+ autoload :Builder, File.join(File.dirname(__FILE__), "draft", "builder")
17
5
 
18
6
  end
@@ -1,72 +1,56 @@
1
1
 
2
- module GOM
2
+ # Builds a draft out of a CouchDB document.
3
+ class GOM::Storage::CouchDB::Draft::Builder
3
4
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module Draft
9
-
10
- # Builds a draft out of a CouchDB document.
11
- class Builder
12
-
13
- def initialize(document)
14
- @document = document
15
- end
16
-
17
- def draft
18
- initialize_draft
19
- set_id
20
- set_class
21
- set_properties_and_relations
22
- @draft
23
- end
24
-
25
- private
26
-
27
- def initialize_draft
28
- @draft = GOM::Object::Draft.new
29
- end
30
-
31
- def set_id
32
- @draft.id = @document.id
33
- end
5
+ def initialize(document)
6
+ @document = document
7
+ end
34
8
 
35
- def set_class
36
- @draft.class_name = @document["model_class"]
37
- end
9
+ def draft
10
+ initialize_draft
11
+ set_id
12
+ set_class
13
+ set_properties_and_relations
14
+ @draft
15
+ end
38
16
 
39
- def set_properties_and_relations
40
- @document.each do |key, value|
41
- set_property key, value if property_key?(key)
42
- set_relation key, value if relation_key?(key)
43
- end
44
- end
17
+ private
45
18
 
46
- def set_property(key, value)
47
- @draft.properties[key.to_sym] = value
48
- end
19
+ def initialize_draft
20
+ @draft = GOM::Object::Draft.new
21
+ end
49
22
 
50
- def set_relation(key, value)
51
- name = key.sub /_id$/, ""
52
- id = GOM::Object::Id.new value
53
- @draft.relations[name.to_sym] = GOM::Object::Proxy.new id
54
- end
23
+ def set_id
24
+ @draft.id = @document.id
25
+ end
55
26
 
56
- def property_key?(key)
57
- !relation_key?(key) && ![ "_id", "_rev", "model_class" ].include?(key)
58
- end
27
+ def set_class
28
+ @draft.class_name = @document["model_class"]
29
+ end
59
30
 
60
- def relation_key?(key)
61
- key =~ /.+_id$/
62
- end
31
+ def set_properties_and_relations
32
+ @document.each do |key, value|
33
+ set_property key, value if property_key?(key)
34
+ set_relation key, value if relation_key?(key)
35
+ end
36
+ end
63
37
 
64
- end
38
+ def set_property(key, value)
39
+ @draft.properties[key.to_sym] = value
40
+ end
65
41
 
66
- end
42
+ def set_relation(key, value)
43
+ name = key.sub /_id$/, ""
44
+ id = GOM::Object::Id.new value
45
+ @draft.relations[name.to_sym] = GOM::Object::Proxy.new id
46
+ end
67
47
 
68
- end
48
+ def property_key?(key)
49
+ !relation_key?(key) && ![ "_id", "_rev", "model_class" ].include?(key)
50
+ end
69
51
 
52
+ def relation_key?(key)
53
+ key =~ /.+_id$/
70
54
  end
71
55
 
72
56
  end
@@ -1,54 +1,42 @@
1
1
 
2
- module GOM
2
+ # Fetches a CouchDB document with the given id and returns a draft.
3
+ class GOM::Storage::CouchDB::Fetcher
3
4
 
4
- module Storage
5
+ attr_accessor :database
6
+ attr_accessor :id
7
+ attr_accessor :revisions
5
8
 
6
- module CouchDB
7
-
8
- # Fetches a CouchDB document with the given id and returns a draft.
9
- class Fetcher
10
-
11
- attr_accessor :database
12
- attr_accessor :id
13
- attr_accessor :revisions
14
-
15
- def initialize(database, id, revisions)
16
- @database, @id, @revisions = database, id, revisions
17
- end
18
-
19
- def draft
20
- initialize_document
21
- load_document
22
- build_draft
23
- @draft
24
- rescue ::CouchDB::Document::NotFoundError
25
- nil
26
- end
27
-
28
- private
29
-
30
- def initialize_document
31
- @document = ::CouchDB::Document.new @database
32
- @document.id = @id
33
- end
9
+ def initialize(database, id, revisions)
10
+ @database, @id, @revisions = database, id, revisions
11
+ end
34
12
 
35
- def load_document
36
- @document.load
37
- set_revision
38
- end
13
+ def draft
14
+ initialize_document
15
+ load_document
16
+ build_draft
17
+ @draft
18
+ rescue ::CouchDB::Document::NotFoundError
19
+ nil
20
+ end
39
21
 
40
- def set_revision
41
- @revisions[@document.id] = @document.rev
42
- end
22
+ private
43
23
 
44
- def build_draft
45
- @draft = GOM::Storage::CouchDB::Draft::Builder.new(@document).draft
46
- end
24
+ def initialize_document
25
+ @document = ::CouchDB::Document.new @database
26
+ @document.id = @id
27
+ end
47
28
 
48
- end
29
+ def load_document
30
+ @document.load
31
+ set_revision
32
+ end
49
33
 
50
- end
34
+ def set_revision
35
+ @revisions[@document.id] = @document.rev
36
+ end
51
37
 
38
+ def build_draft
39
+ @draft = GOM::Storage::CouchDB::Draft::Builder.new(@document).draft
52
40
  end
53
41
 
54
42
  end
@@ -1,38 +1,26 @@
1
1
 
2
- module GOM
2
+ # Removes the CouchDB document with the given id.
3
+ class GOM::Storage::CouchDB::Remover
3
4
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- # Removes the CouchDB document with the given id.
9
- class Remover
10
-
11
- def initialize(database, id, revisions)
12
- @database, @id, @revisions = database, id, revisions
13
- end
14
-
15
- def perform
16
- initialize_document
17
- destroy_document
18
- end
19
-
20
- private
21
-
22
- def initialize_document
23
- @document = ::CouchDB::Document.new @database
24
- @document.id = @id
25
- @document.rev = @revisions[@id]
26
- end
5
+ def initialize(database, id, revisions)
6
+ @database, @id, @revisions = database, id, revisions
7
+ end
27
8
 
28
- def destroy_document
29
- @document.destroy
30
- end
9
+ def perform
10
+ initialize_document
11
+ destroy_document
12
+ end
31
13
 
32
- end
14
+ private
33
15
 
34
- end
16
+ def initialize_document
17
+ @document = ::CouchDB::Document.new @database
18
+ @document.id = @id
19
+ @document.rev = @revisions[@id]
20
+ end
35
21
 
22
+ def destroy_document
23
+ @document.destroy
36
24
  end
37
25
 
38
26
  end
@@ -1,66 +1,55 @@
1
1
 
2
- module GOM
2
+ # Saves the given draft to a CouchDB document.
3
+ class GOM::Storage::CouchDB::Saver
3
4
 
4
- module Storage
5
+ attr_reader :id
5
6
 
6
- module CouchDB
7
-
8
- # Saves the given draft to a CouchDB document.
9
- class Saver
10
-
11
- attr_reader :id
12
-
13
- def initialize(database, draft, revisions, relation_storage_name)
14
- @database, @draft, @revisions, @relation_storage_name = database, draft, revisions, relation_storage_name
15
- end
16
-
17
- def perform
18
- initialize_document
19
- set_properties
20
- set_relations
21
- save_document
22
- store_revision
23
- end
24
-
25
- private
26
-
27
- def initialize_document
28
- @document = ::CouchDB::Document.new @database
29
- @document.id = @draft.id if @draft.id
30
- @document["model_class"] = @draft.class_name
31
- end
32
-
33
- def set_properties
34
- @draft.properties.each do |key, value|
35
- @document[key.to_s] = value
36
- end
37
- end
7
+ def initialize(database, draft, revisions, relation_storage_name)
8
+ @database, @draft, @revisions, @relation_storage_name = database, draft, revisions, relation_storage_name
9
+ end
38
10
 
39
- def set_relations
40
- @draft.relations.each do |key, object_proxy|
41
- id, object = object_proxy.id, object_proxy.object
42
- @document["#{key}_id"] = if id
43
- id.to_s
44
- else
45
- GOM::Storage.store object, @relation_storage_name
46
- GOM::Object.id object
47
- end
48
- end
49
- end
11
+ def perform
12
+ initialize_document
13
+ set_properties
14
+ set_relations
15
+ save_document
16
+ store_revision
17
+ end
50
18
 
51
- def save_document
52
- @document.save
53
- @id = @document.id
54
- end
19
+ private
55
20
 
56
- def store_revision
57
- @revisions[@document.id] = @document.rev
58
- end
21
+ def initialize_document
22
+ @document = ::CouchDB::Document.new @database
23
+ draft_id = @draft.id
24
+ @document.id = draft_id if draft_id
25
+ @document["model_class"] = @draft.class_name
26
+ end
59
27
 
60
- end
28
+ def set_properties
29
+ @draft.properties.each do |key, value|
30
+ @document[key.to_s] = value
31
+ end
32
+ end
61
33
 
34
+ def set_relations
35
+ @draft.relations.each do |key, object_proxy|
36
+ id, object = object_proxy.id, object_proxy.object
37
+ @document["#{key}_id"] = if id
38
+ id.to_s
39
+ else
40
+ GOM::Storage.store object, @relation_storage_name
41
+ GOM::Object.id object
42
+ end
62
43
  end
44
+ end
45
+
46
+ def save_document
47
+ @document.save
48
+ @id = @document.id
49
+ end
63
50
 
51
+ def store_revision
52
+ @revisions[@document.id] = @document.rev
64
53
  end
65
54
 
66
55
  end
@@ -1,19 +1,7 @@
1
1
 
2
- module GOM
2
+ module GOM::Storage::CouchDB::View
3
3
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module View
9
-
10
- autoload :Builder, File.join(File.dirname(__FILE__), "view", "builder")
11
- autoload :Pusher, File.join(File.dirname(__FILE__), "view", "pusher")
12
-
13
- end
14
-
15
- end
16
-
17
- end
4
+ autoload :Builder, File.join(File.dirname(__FILE__), "view", "builder")
5
+ autoload :Pusher, File.join(File.dirname(__FILE__), "view", "pusher")
18
6
 
19
7
  end
@@ -1,32 +1,16 @@
1
1
 
2
- module GOM
2
+ # Builds a javascript map-reduce-view out of a class view.
3
+ class GOM::Storage::CouchDB::View::Builder
3
4
 
4
- module Storage
5
-
6
- module CouchDB
7
-
8
- module View
9
-
10
- # Builds a javascript map-reduce-view out of a class view.
11
- class Builder
12
-
13
- def initialize(class_view)
14
- @class_view = class_view
15
- end
16
-
17
- def map_reduce_view
18
- GOM::Storage::Configuration::View::MapReduce.new(
19
- "function(document) {\n if (document['model_class'] == '#{@class_view.class_name}') {\n emit(document['_id'], null);\n }\n}",
20
- nil
21
- )
22
- end
23
-
24
- end
25
-
26
- end
27
-
28
- end
5
+ def initialize(class_view)
6
+ @class_view = class_view
7
+ end
29
8
 
9
+ def map_reduce_view
10
+ GOM::Storage::Configuration::View::MapReduce.new(
11
+ "function(document) {\n if (document['model_class'] == '#{@class_view.class_name}') {\n emit(document['_id'], null);\n }\n}",
12
+ nil
13
+ )
30
14
  end
31
15
 
32
16
  end
@@ -1,67 +1,51 @@
1
1
 
2
- module GOM
2
+ # A helper to push design documents to the CouchDB server.
3
+ class GOM::Storage::CouchDB::View::Pusher
3
4
 
4
- module Storage
5
+ attr_reader :design
5
6
 
6
- module CouchDB
7
-
8
- module View
9
-
10
- # A helper to push design documents to the CouchDB server.
11
- class Pusher
12
-
13
- attr_reader :design
14
-
15
- def initialize(database, view_hash)
16
- @database, @view_hash = database, view_hash
17
- end
18
-
19
- def perform
20
- initialize_design
21
- add_views
22
- push_design
23
- end
24
-
25
- private
26
-
27
- def initialize_design
28
- @design = ::CouchDB::Design.new @database, "gom"
29
- end
30
-
31
- def add_views
32
- @view_hash.each do |name, view|
33
- add_view name.to_s, view
34
- end
35
- end
36
-
37
- def push_design
38
- @design.save
39
- end
7
+ def initialize(database, view_hash)
8
+ @database, @view_hash = database, view_hash
9
+ end
40
10
 
41
- def add_view(name, view)
42
- case view.class.to_s
43
- when "GOM::Storage::Configuration::View::Class"
44
- add_view_by_class_view name, view
45
- when "GOM::Storage::Configuration::View::MapReduce"
46
- add_view_by_map_reduce_view name, view
47
- end
48
- end
11
+ def perform
12
+ initialize_design
13
+ add_views
14
+ push_design
15
+ end
49
16
 
50
- def add_view_by_class_view(name, class_view)
51
- map_reduce_view = Builder.new(class_view).map_reduce_view
52
- @design.views << ::CouchDB::Design::View.new(@design, name, map_reduce_view.map, map_reduce_view.reduce)
53
- end
17
+ private
54
18
 
55
- def add_view_by_map_reduce_view(name, map_reduce_view)
56
- @design.views << ::CouchDB::Design::View.new(@design, name, map_reduce_view.map, map_reduce_view.reduce)
57
- end
19
+ def initialize_design
20
+ @design = ::CouchDB::Design.new @database, "gom"
21
+ end
58
22
 
59
- end
23
+ def add_views
24
+ @view_hash.each do |name, view|
25
+ add_view name.to_s, view
26
+ end
27
+ end
60
28
 
61
- end
29
+ def push_design
30
+ @design.save
31
+ end
62
32
 
33
+ def add_view(name, view)
34
+ case view.class.to_s
35
+ when "GOM::Storage::Configuration::View::Class"
36
+ add_view_by_class_view name, view
37
+ when "GOM::Storage::Configuration::View::MapReduce"
38
+ add_view_by_map_reduce_view name, view
63
39
  end
40
+ end
41
+
42
+ def add_view_by_class_view(name, class_view)
43
+ map_reduce_view = GOM::Storage::CouchDB::View::Builder.new(class_view).map_reduce_view
44
+ @design.views << ::CouchDB::Design::View.new(@design, name, map_reduce_view.map, map_reduce_view.reduce)
45
+ end
64
46
 
47
+ def add_view_by_map_reduce_view(name, map_reduce_view)
48
+ @design.views << ::CouchDB::Design::View.new(@design, name, map_reduce_view.map, map_reduce_view.reduce)
65
49
  end
66
50
 
67
51
  end
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "couchdb-adapter"))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "gom", "couchdb-adapter"))
3
3
 
4
4
  GOM::Storage::Configuration.read File.join(File.dirname(__FILE__), "..", "storage.configuration")
5
5
 
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
2
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "couchdb-adapter"))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "gom", "couchdb-adapter"))
3
3
 
4
4
  GOM::Storage::Configuration.read File.join(File.dirname(__FILE__), "..", "storage.configuration")
5
5
 
@@ -63,6 +63,26 @@ describe GOM::Storage::CouchDB::Adapter do
63
63
 
64
64
  end
65
65
 
66
+ describe "teardown" do
67
+
68
+ before :each do
69
+ @adapter.setup
70
+ end
71
+
72
+ it "should clear the server" do
73
+ lambda do
74
+ @adapter.teardown
75
+ end.should change(@adapter, :server).from(@server).to(nil)
76
+ end
77
+
78
+ it "should clear the database" do
79
+ lambda do
80
+ @adapter.teardown
81
+ end.should change(@adapter, :database).from(@database).to(nil)
82
+ end
83
+
84
+ end
85
+
66
86
  describe "fetch" do
67
87
 
68
88
  before :each do
@@ -4,4 +4,4 @@ require 'rspec'
4
4
 
5
5
  require 'gom/spec'
6
6
 
7
- require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "couchdb-adapter"))
7
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "lib", "gom", "couchdb-adapter"))
@@ -7,7 +7,7 @@ test_storage:
7
7
  views:
8
8
  test_object_class_view:
9
9
  type: class
10
- class: Object
10
+ class: GOM::Spec::Object
11
11
  test_map_view:
12
12
  type: map_reduce
13
13
  map:
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Philipp Br\xC3\xBCll"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-20 00:00:00 +01:00
17
+ date: 2011-02-17 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -27,9 +27,9 @@ dependencies:
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 0
30
- - 2
30
+ - 3
31
31
  - 0
32
- version: 0.2.0
32
+ version: 0.3.0
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
@@ -86,32 +86,32 @@ files:
86
86
  - README.rdoc
87
87
  - LICENSE
88
88
  - Rakefile
89
- - lib/gom/storage/couchdb/adapter.rb
90
- - lib/gom/storage/couchdb/view/builder.rb
91
- - lib/gom/storage/couchdb/view/pusher.rb
92
- - lib/gom/storage/couchdb/view.rb
93
- - lib/gom/storage/couchdb/saver.rb
89
+ - lib/gom/couchdb-adapter.rb
90
+ - lib/gom/storage.rb
91
+ - lib/gom/storage/couchdb.rb
94
92
  - lib/gom/storage/couchdb/fetcher.rb
95
93
  - lib/gom/storage/couchdb/draft/builder.rb
96
- - lib/gom/storage/couchdb/draft.rb
94
+ - lib/gom/storage/couchdb/view.rb
95
+ - lib/gom/storage/couchdb/saver.rb
97
96
  - lib/gom/storage/couchdb/remover.rb
98
97
  - lib/gom/storage/couchdb/collection/fetcher.rb
99
98
  - lib/gom/storage/couchdb/collection.rb
100
- - lib/gom/storage/couchdb.rb
101
- - lib/gom/storage.rb
102
- - lib/couchdb-adapter.rb
103
- - spec/lib/gom/storage/couchdb/fetcher_spec.rb
104
- - spec/lib/gom/storage/couchdb/view/pusher_spec.rb
105
- - spec/lib/gom/storage/couchdb/view/builder_spec.rb
99
+ - lib/gom/storage/couchdb/view/pusher.rb
100
+ - lib/gom/storage/couchdb/view/builder.rb
101
+ - lib/gom/storage/couchdb/draft.rb
102
+ - lib/gom/storage/couchdb/adapter.rb
103
+ - spec/storage.configuration
106
104
  - spec/lib/gom/storage/couchdb/draft/builder_spec.rb
107
105
  - spec/lib/gom/storage/couchdb/collection/fetcher_spec.rb
108
- - spec/lib/gom/storage/couchdb/remover_spec.rb
109
- - spec/lib/gom/storage/couchdb/saver_spec.rb
110
106
  - spec/lib/gom/storage/couchdb/adapter_spec.rb
111
- - spec/storage.configuration
112
- - spec/spec_helper.rb
113
- - spec/acceptance/map_reduce_spec.rb
107
+ - spec/lib/gom/storage/couchdb/view/builder_spec.rb
108
+ - spec/lib/gom/storage/couchdb/view/pusher_spec.rb
109
+ - spec/lib/gom/storage/couchdb/fetcher_spec.rb
110
+ - spec/lib/gom/storage/couchdb/saver_spec.rb
111
+ - spec/lib/gom/storage/couchdb/remover_spec.rb
114
112
  - spec/acceptance/adapter_spec.rb
113
+ - spec/acceptance/map_reduce_spec.rb
114
+ - spec/spec_helper.rb
115
115
  has_rdoc: true
116
116
  homepage: http://github.com/phifty/gom-couchdb-adapter
117
117
  licenses: []
@@ -145,13 +145,13 @@ signing_key:
145
145
  specification_version: 3
146
146
  summary: CouchDB storage adapter for the General Object Mapper.
147
147
  test_files:
148
- - spec/lib/gom/storage/couchdb/fetcher_spec.rb
149
- - spec/lib/gom/storage/couchdb/view/pusher_spec.rb
150
- - spec/lib/gom/storage/couchdb/view/builder_spec.rb
151
148
  - spec/lib/gom/storage/couchdb/draft/builder_spec.rb
152
149
  - spec/lib/gom/storage/couchdb/collection/fetcher_spec.rb
153
- - spec/lib/gom/storage/couchdb/remover_spec.rb
154
- - spec/lib/gom/storage/couchdb/saver_spec.rb
155
150
  - spec/lib/gom/storage/couchdb/adapter_spec.rb
156
- - spec/acceptance/map_reduce_spec.rb
151
+ - spec/lib/gom/storage/couchdb/view/builder_spec.rb
152
+ - spec/lib/gom/storage/couchdb/view/pusher_spec.rb
153
+ - spec/lib/gom/storage/couchdb/fetcher_spec.rb
154
+ - spec/lib/gom/storage/couchdb/saver_spec.rb
155
+ - spec/lib/gom/storage/couchdb/remover_spec.rb
157
156
  - spec/acceptance/adapter_spec.rb
157
+ - spec/acceptance/map_reduce_spec.rb