gom 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gom/spec/acceptance/adapter_with_search.rb +47 -0
- data/lib/gom/spec/acceptance/adapter_with_stateful_storage.rb +23 -0
- data/lib/gom/spec/acceptance/read_only_adapter_with_stateless_storage.rb +15 -1
- data/lib/gom/spec.rb +1 -0
- data/lib/gom/storage/configuration/view/all.rb +5 -0
- data/lib/gom/storage/configuration/view/search.rb +11 -0
- data/lib/gom/storage/configuration/view.rb +2 -0
- data/lib/gom/storage/configuration.rb +8 -0
- data/spec/fake_adapter.rb +14 -0
- data/spec/lib/gom/storage/configuration/view/all_spec.rb +5 -0
- data/spec/lib/gom/storage/configuration/view/search_spec.rb +17 -0
- data/spec/storage_configuration.rb +4 -0
- metadata +54 -77
@@ -0,0 +1,47 @@
|
|
1
|
+
|
2
|
+
shared_examples_for "an adapter with search view" do
|
3
|
+
|
4
|
+
before :all do
|
5
|
+
GOM::Storage.setup
|
6
|
+
end
|
7
|
+
|
8
|
+
after :all do
|
9
|
+
GOM::Storage.teardown
|
10
|
+
end
|
11
|
+
|
12
|
+
before :each do
|
13
|
+
@object_one = GOM::Spec::Object.new
|
14
|
+
@object_one.number = 11
|
15
|
+
|
16
|
+
@object_two = GOM::Spec::Object.new
|
17
|
+
@object_two.number = 24
|
18
|
+
|
19
|
+
@object_three = Object.new
|
20
|
+
@object_three.instance_variable_set :@number, 11
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "fetching a search collection" do
|
24
|
+
|
25
|
+
before :each do
|
26
|
+
GOM::Storage.store @object_one, :test_storage
|
27
|
+
GOM::Storage.store @object_two, :test_storage
|
28
|
+
|
29
|
+
sleep 1.0 # wait until changes go through the river in the index
|
30
|
+
end
|
31
|
+
|
32
|
+
after :each do
|
33
|
+
GOM::Storage.remove @object_one
|
34
|
+
GOM::Storage.remove @object_two
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should return the right results" do
|
38
|
+
collection = GOM::Storage.collection :test_storage, :test_search_view, :query => "11"
|
39
|
+
collection.should be_instance_of(GOM::Object::Collection)
|
40
|
+
collection.size.should == 1
|
41
|
+
collection.map(&:class).should == [ GOM::Spec::Object ]
|
42
|
+
collection.map(&:number).should == [ 11 ]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -143,6 +143,29 @@ shared_examples_for "an adapter connected to a stateful storage" do
|
|
143
143
|
|
144
144
|
end
|
145
145
|
|
146
|
+
describe "fetching an all collection" do
|
147
|
+
|
148
|
+
before :each do
|
149
|
+
GOM::Storage.store @object, :test_storage
|
150
|
+
end
|
151
|
+
|
152
|
+
after :each do
|
153
|
+
GOM::Storage.remove @related_object
|
154
|
+
GOM::Storage.remove @object
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should provide a collection of the property view" do
|
158
|
+
collection = GOM::Storage.collection :test_storage, :test_all_view
|
159
|
+
collection.should be_instance_of(GOM::Object::Collection)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should provide a collection that contains all object of the database" do
|
163
|
+
collection = GOM::Storage.collection :test_storage, :test_all_view
|
164
|
+
collection.size.should == 2
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
146
169
|
describe "fetching a property collection" do
|
147
170
|
|
148
171
|
before :each do
|
@@ -66,6 +66,20 @@ shared_examples_for "a read-only adapter connected to a stateless storage" do
|
|
66
66
|
|
67
67
|
end
|
68
68
|
|
69
|
+
describe "fetching an all collection" do
|
70
|
+
|
71
|
+
it "should return a collection" do
|
72
|
+
collection = GOM::Storage.collection :test_storage, :test_all_view
|
73
|
+
collection.should be_instance_of(GOM::Object::Collection)
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should return a collection that contains all objects of the database" do
|
77
|
+
collection = GOM::Storage.collection :test_storage, :test_all_view
|
78
|
+
collection.size.should == 2
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
69
83
|
describe "fetching a class collection" do
|
70
84
|
|
71
85
|
it "should return a collection" do
|
@@ -75,7 +89,7 @@ shared_examples_for "a read-only adapter connected to a stateless storage" do
|
|
75
89
|
|
76
90
|
it "should return a collection that contains all object of class Object" do
|
77
91
|
collection = GOM::Storage.collection :test_storage, :test_object_class_view
|
78
|
-
collection.size > 0
|
92
|
+
collection.size.should > 0
|
79
93
|
collection.each do |object|
|
80
94
|
[ 5, 7 ].should include(object.number)
|
81
95
|
end
|
data/lib/gom/spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
|
3
3
|
require File.join(File.dirname(__FILE__), "spec", "acceptance", "adapter_that_needs_setup")
|
4
|
+
require File.join(File.dirname(__FILE__), "spec", "acceptance", "adapter_with_search")
|
4
5
|
require File.join(File.dirname(__FILE__), "spec", "acceptance", "adapter_with_stateful_storage")
|
5
6
|
require File.join(File.dirname(__FILE__), "spec", "acceptance", "read_only_adapter_with_stateless_storage")
|
6
7
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
|
2
2
|
module GOM::Storage::Configuration::View
|
3
3
|
|
4
|
+
autoload :All, File.join(File.dirname(__FILE__), "view", "all")
|
4
5
|
autoload :Class, File.join(File.dirname(__FILE__), "view", "class")
|
5
6
|
autoload :MapReduce, File.join(File.dirname(__FILE__), "view", "map_reduce")
|
6
7
|
autoload :Property, File.join(File.dirname(__FILE__), "view", "property")
|
8
|
+
autoload :Search, File.join(File.dirname(__FILE__), "view", "search")
|
7
9
|
|
8
10
|
end
|
@@ -89,6 +89,10 @@ class GOM::Storage::Configuration
|
|
89
89
|
self.send method_name, hash
|
90
90
|
end
|
91
91
|
|
92
|
+
def self.all_view(hash)
|
93
|
+
View::All.new
|
94
|
+
end
|
95
|
+
|
92
96
|
def self.class_view(hash)
|
93
97
|
View::Class.new hash[:model_class]
|
94
98
|
end
|
@@ -101,6 +105,10 @@ class GOM::Storage::Configuration
|
|
101
105
|
View::Property.new *hash.values_at(:filter, :properties)
|
102
106
|
end
|
103
107
|
|
108
|
+
def self.search_view(hash)
|
109
|
+
View::Search.new hash[:model_class]
|
110
|
+
end
|
111
|
+
|
104
112
|
def self.setup_all
|
105
113
|
@configurations.values.each do |configuration|
|
106
114
|
configuration.setup
|
data/spec/fake_adapter.rb
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
|
2
2
|
class FakeAdapter < GOM::Storage::Adapter
|
3
3
|
|
4
|
+
class AllCollectionFetcher
|
5
|
+
|
6
|
+
def initialize(store, storage_name)
|
7
|
+
@store, @storage_name = store, storage_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def drafts
|
11
|
+
@store.values
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
4
16
|
class PropertyCollectionFetcher
|
5
17
|
|
6
18
|
def initialize(store, storage_name, filter, properties)
|
@@ -109,6 +121,8 @@ class FakeAdapter < GOM::Storage::Adapter
|
|
109
121
|
raise GOM::Storage::Adapter::NoSetupError unless @store
|
110
122
|
view = configuration.views[view_name]
|
111
123
|
case view_name.to_sym
|
124
|
+
when :test_all_view
|
125
|
+
GOM::Object::Collection.new AllCollectionFetcher.new(@store, configuration.name), configuration.name
|
112
126
|
when :test_property_view
|
113
127
|
GOM::Object::Collection.new PropertyCollectionFetcher.new(@store, configuration.name, view.filter, view.properties), configuration.name
|
114
128
|
when :test_object_class_view
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", "..", "spec_helper"))
|
2
|
+
|
3
|
+
describe GOM::Storage::Configuration::View::Search do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@view = described_class.new [ "Object" ]
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "initialize" do
|
10
|
+
|
11
|
+
it "should set the view's class name" do
|
12
|
+
@view.class_name.should == [ "Object" ]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
CHANGED
@@ -1,77 +1,56 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gom
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 3
|
10
|
-
version: 0.4.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Philipp Brüll
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-10-19 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: configure
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &16490400 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 19
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
- 3
|
33
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
34
21
|
version: 0.3.0
|
35
22
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rspec
|
39
23
|
prerelease: false
|
40
|
-
|
24
|
+
version_requirements: *16490400
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &16488920 !ruby/object:Gem::Requirement
|
41
28
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
segments:
|
47
|
-
- 2
|
48
|
-
version: "2"
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2'
|
49
33
|
type: :development
|
50
|
-
version_requirements: *id002
|
51
|
-
- !ruby/object:Gem::Dependency
|
52
|
-
name: reek
|
53
34
|
prerelease: false
|
54
|
-
|
35
|
+
version_requirements: *16488920
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: reek
|
38
|
+
requirement: &16486660 !ruby/object:Gem::Requirement
|
55
39
|
none: false
|
56
|
-
requirements:
|
57
|
-
- -
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
|
60
|
-
segments:
|
61
|
-
- 1
|
62
|
-
- 2
|
63
|
-
version: "1.2"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.2'
|
64
44
|
type: :development
|
65
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *16486660
|
66
47
|
description: Core package of the General Object Mapper.
|
67
48
|
email: b.phifty@gmail.com
|
68
49
|
executables: []
|
69
|
-
|
70
50
|
extensions: []
|
71
|
-
|
72
|
-
extra_rdoc_files:
|
51
|
+
extra_rdoc_files:
|
73
52
|
- README.rdoc
|
74
|
-
files:
|
53
|
+
files:
|
75
54
|
- README.rdoc
|
76
55
|
- LICENSE
|
77
56
|
- Rakefile
|
@@ -86,6 +65,8 @@ files:
|
|
86
65
|
- lib/gom/storage/counter.rb
|
87
66
|
- lib/gom/storage/configuration/view/property.rb
|
88
67
|
- lib/gom/storage/configuration/view/class.rb
|
68
|
+
- lib/gom/storage/configuration/view/search.rb
|
69
|
+
- lib/gom/storage/configuration/view/all.rb
|
89
70
|
- lib/gom/storage/configuration/view/map_reduce.rb
|
90
71
|
- lib/gom/storage/configuration/view.rb
|
91
72
|
- lib/gom/storage/adapter.rb
|
@@ -99,6 +80,7 @@ files:
|
|
99
80
|
- lib/gom/spec/object.rb
|
100
81
|
- lib/gom/spec/acceptance/adapter_with_stateful_storage.rb
|
101
82
|
- lib/gom/spec/acceptance/read_only_adapter_with_stateless_storage.rb
|
83
|
+
- lib/gom/spec/acceptance/adapter_with_search.rb
|
102
84
|
- lib/gom/spec/acceptance/adapter_that_needs_setup.rb
|
103
85
|
- lib/gom.rb
|
104
86
|
- spec/fake_adapter.rb
|
@@ -115,6 +97,8 @@ files:
|
|
115
97
|
- spec/lib/gom/storage/configuration/view/property_spec.rb
|
116
98
|
- spec/lib/gom/storage/configuration/view/map_reduce_spec.rb
|
117
99
|
- spec/lib/gom/storage/configuration/view/class_spec.rb
|
100
|
+
- spec/lib/gom/storage/configuration/view/all_spec.rb
|
101
|
+
- spec/lib/gom/storage/configuration/view/search_spec.rb
|
118
102
|
- spec/lib/gom/storage/fetcher_spec.rb
|
119
103
|
- spec/lib/gom/storage/remover_spec.rb
|
120
104
|
- spec/lib/gom/storage/saver_spec.rb
|
@@ -126,41 +110,32 @@ files:
|
|
126
110
|
- spec/acceptance/adapter_spec.rb
|
127
111
|
- spec/acceptance/fake_adapter_spec.rb
|
128
112
|
- spec/acceptance/object_spec.rb
|
129
|
-
has_rdoc: true
|
130
113
|
homepage: http://github.com/phifty/gom
|
131
114
|
licenses: []
|
132
|
-
|
133
115
|
post_install_message:
|
134
116
|
rdoc_options: []
|
135
|
-
|
136
|
-
require_paths:
|
117
|
+
require_paths:
|
137
118
|
- lib
|
138
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
120
|
none: false
|
140
|
-
requirements:
|
141
|
-
- -
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
|
144
|
-
|
145
|
-
- 0
|
146
|
-
version: "0"
|
147
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
148
126
|
none: false
|
149
|
-
requirements:
|
150
|
-
- -
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
|
153
|
-
segments:
|
154
|
-
- 0
|
155
|
-
version: "0"
|
127
|
+
requirements:
|
128
|
+
- - ! '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
156
131
|
requirements: []
|
157
|
-
|
158
132
|
rubyforge_project: gom
|
159
|
-
rubygems_version: 1.
|
133
|
+
rubygems_version: 1.8.10
|
160
134
|
signing_key:
|
161
135
|
specification_version: 3
|
162
|
-
summary: General Object Mapper - maps any ruby object to different kinds of storage
|
163
|
-
|
136
|
+
summary: General Object Mapper - maps any ruby object to different kinds of storage
|
137
|
+
engines and vice versa.
|
138
|
+
test_files:
|
164
139
|
- spec/lib/gom/object/cached_builder_spec.rb
|
165
140
|
- spec/lib/gom/object/inspector_spec.rb
|
166
141
|
- spec/lib/gom/object/proxy_spec.rb
|
@@ -174,6 +149,8 @@ test_files:
|
|
174
149
|
- spec/lib/gom/storage/configuration/view/property_spec.rb
|
175
150
|
- spec/lib/gom/storage/configuration/view/map_reduce_spec.rb
|
176
151
|
- spec/lib/gom/storage/configuration/view/class_spec.rb
|
152
|
+
- spec/lib/gom/storage/configuration/view/all_spec.rb
|
153
|
+
- spec/lib/gom/storage/configuration/view/search_spec.rb
|
177
154
|
- spec/lib/gom/storage/fetcher_spec.rb
|
178
155
|
- spec/lib/gom/storage/remover_spec.rb
|
179
156
|
- spec/lib/gom/storage/saver_spec.rb
|