gom 0.4.2 → 0.4.3
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.
- data/README.rdoc +45 -37
- data/lib/gom/object.rb +8 -2
- data/spec/lib/gom/object_spec.rb +6 -0
- metadata +74 -46
data/README.rdoc
CHANGED
@@ -16,9 +16,11 @@ At the beginning of your program the storage configuration should be done with t
|
|
16
16
|
command.
|
17
17
|
|
18
18
|
GOM::Storage.configure {
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
storage {
|
20
|
+
name :storage_name
|
21
|
+
adapter :filesystem
|
22
|
+
directory "/var/project-name/data"
|
23
|
+
}
|
22
24
|
}
|
23
25
|
|
24
26
|
Look at the adapter pages to see the adapter-specific configuration values.
|
@@ -126,13 +128,15 @@ There views simply provides a collection of all object of a specified class. The
|
|
126
128
|
configuration.
|
127
129
|
|
128
130
|
GOM::Storage.configure {
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
131
|
+
storage {
|
132
|
+
name :storage_name
|
133
|
+
adapter :filesystem
|
134
|
+
directory "/var/project-name/data"
|
135
|
+
view {
|
136
|
+
name :users
|
137
|
+
type :class
|
138
|
+
model_class User
|
139
|
+
}
|
136
140
|
}
|
137
141
|
}
|
138
142
|
|
@@ -148,23 +152,25 @@ array.
|
|
148
152
|
These views are also defined in the storage configuration.
|
149
153
|
|
150
154
|
GOM::Storage.configure {
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
155
|
+
storage {
|
156
|
+
name :storage_name
|
157
|
+
adapter :couchdb
|
158
|
+
view {
|
159
|
+
name :active_user_count
|
160
|
+
type :map_reduce
|
161
|
+
map_function """
|
162
|
+
function(document) {
|
163
|
+
if (document['model_class'] == 'User' && document['active']) {
|
164
|
+
emit(document['_id'], 1);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
"""
|
168
|
+
reduce_function """
|
169
|
+
function(keys, values, rereduce) {
|
170
|
+
return sum(values);
|
160
171
|
}
|
161
|
-
|
162
|
-
|
163
|
-
reduce_function """
|
164
|
-
function(keys, values, rereduce) {
|
165
|
-
return sum(values);
|
166
|
-
}
|
167
|
-
"""
|
172
|
+
"""
|
173
|
+
}
|
168
174
|
}
|
169
175
|
}
|
170
176
|
|
@@ -178,18 +184,20 @@ If no <tt>reduce</tt> method is given, <tt>GOM</tt> will try to map the fetched
|
|
178
184
|
definition would be...
|
179
185
|
|
180
186
|
GOM::Storage.configure {
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
187
|
+
storage {
|
188
|
+
name :storage_name
|
189
|
+
adapter :couchdb
|
190
|
+
view {
|
191
|
+
name :active_users
|
192
|
+
type :map_reduce
|
193
|
+
map_function """
|
194
|
+
function(document) {
|
195
|
+
if (document['model_class'] == 'User') {
|
196
|
+
emit(document['_id'], null);
|
197
|
+
}
|
190
198
|
}
|
191
|
-
|
192
|
-
|
199
|
+
"""
|
200
|
+
}
|
193
201
|
}
|
194
202
|
}
|
195
203
|
|
data/lib/gom/object.rb
CHANGED
@@ -20,8 +20,14 @@ module GOM::Object
|
|
20
20
|
id ? id.storage_name : nil
|
21
21
|
end
|
22
22
|
|
23
|
-
def self.reference(
|
24
|
-
|
23
|
+
def self.reference(value)
|
24
|
+
if value.is_a?(GOM::Object::Proxy)
|
25
|
+
value
|
26
|
+
elsif value.is_a?(String)
|
27
|
+
Proxy.new Id.new(value)
|
28
|
+
else
|
29
|
+
Proxy.new value
|
30
|
+
end
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|
data/spec/lib/gom/object_spec.rb
CHANGED
@@ -64,6 +64,12 @@ describe GOM::Object do
|
|
64
64
|
proxy.object.should == @object
|
65
65
|
end
|
66
66
|
|
67
|
+
it "should return a proxy for the given id string" do
|
68
|
+
proxy = GOM::Object.reference "test:12345"
|
69
|
+
proxy.should be_instance_of(GOM::Object::Proxy)
|
70
|
+
proxy.id.should == "test:12345"
|
71
|
+
end
|
72
|
+
|
67
73
|
it "should return the proxy if a proxy is given" do
|
68
74
|
proxy = GOM::Object::reference @proxy
|
69
75
|
proxy.should == @proxy
|
metadata
CHANGED
@@ -1,57 +1,77 @@
|
|
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
|
+
hash: 9
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 4
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
- Philipp
|
12
|
+
authors:
|
13
|
+
- "Philipp Br\xC3\xBCll"
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
17
|
+
|
18
|
+
date: 2011-10-10 00:00:00 +02:00
|
13
19
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
16
22
|
name: configure
|
17
|
-
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
18
25
|
none: false
|
19
|
-
requirements:
|
20
|
-
- -
|
21
|
-
- !ruby/object:Gem::Version
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 19
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
- 3
|
33
|
+
- 0
|
22
34
|
version: 0.3.0
|
23
35
|
type: :runtime
|
24
|
-
|
25
|
-
|
26
|
-
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
27
38
|
name: rspec
|
28
|
-
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
29
41
|
none: false
|
30
|
-
requirements:
|
31
|
-
- -
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 7
|
46
|
+
segments:
|
47
|
+
- 2
|
48
|
+
version: "2"
|
34
49
|
type: :development
|
35
|
-
|
36
|
-
|
37
|
-
- !ruby/object:Gem::Dependency
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
38
52
|
name: reek
|
39
|
-
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
55
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 11
|
60
|
+
segments:
|
61
|
+
- 1
|
62
|
+
- 2
|
63
|
+
version: "1.2"
|
45
64
|
type: :development
|
46
|
-
|
47
|
-
version_requirements: *19788800
|
65
|
+
version_requirements: *id003
|
48
66
|
description: Core package of the General Object Mapper.
|
49
67
|
email: b.phifty@gmail.com
|
50
68
|
executables: []
|
69
|
+
|
51
70
|
extensions: []
|
52
|
-
|
71
|
+
|
72
|
+
extra_rdoc_files:
|
53
73
|
- README.rdoc
|
54
|
-
files:
|
74
|
+
files:
|
55
75
|
- README.rdoc
|
56
76
|
- LICENSE
|
57
77
|
- Rakefile
|
@@ -109,30 +129,38 @@ files:
|
|
109
129
|
has_rdoc: true
|
110
130
|
homepage: http://github.com/phifty/gom
|
111
131
|
licenses: []
|
132
|
+
|
112
133
|
post_install_message:
|
113
134
|
rdoc_options: []
|
114
|
-
|
135
|
+
|
136
|
+
require_paths:
|
115
137
|
- lib
|
116
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
139
|
none: false
|
118
|
-
requirements:
|
119
|
-
- -
|
120
|
-
- !ruby/object:Gem::Version
|
121
|
-
|
122
|
-
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 3
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
148
|
none: false
|
124
|
-
requirements:
|
125
|
-
- -
|
126
|
-
- !ruby/object:Gem::Version
|
127
|
-
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
hash: 3
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
version: "0"
|
128
156
|
requirements: []
|
157
|
+
|
129
158
|
rubyforge_project: gom
|
130
159
|
rubygems_version: 1.6.2
|
131
160
|
signing_key:
|
132
161
|
specification_version: 3
|
133
|
-
summary: General Object Mapper - maps any ruby object to different kinds of storage
|
134
|
-
|
135
|
-
test_files:
|
162
|
+
summary: General Object Mapper - maps any ruby object to different kinds of storage engines and vice versa.
|
163
|
+
test_files:
|
136
164
|
- spec/lib/gom/object/cached_builder_spec.rb
|
137
165
|
- spec/lib/gom/object/inspector_spec.rb
|
138
166
|
- spec/lib/gom/object/proxy_spec.rb
|