riakrest 0.0.4 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +25 -26
- data/README.rdoc +16 -26
- data/VERSION +1 -1
- data/examples/auto_update_data.rb +16 -21
- data/examples/auto_update_links.rb +17 -21
- data/examples/basic_client.rb +15 -11
- data/examples/basic_resource.rb +14 -18
- data/examples/bucket_schemas.rb +12 -10
- data/examples/linked_resources.rb +23 -26
- data/examples/links_only_pov.rb +25 -25
- data/examples/multiple_pov.rb +16 -14
- data/examples/rest_interaction.rb +5 -5
- data/examples/ruby_json_data.rb +1 -19
- data/lib/riakrest/core/jiak_bucket.rb +18 -50
- data/lib/riakrest/core/jiak_client.rb +147 -79
- data/lib/riakrest/core/jiak_data.rb +179 -164
- data/lib/riakrest/core/jiak_data_fields.rb +69 -0
- data/lib/riakrest/core/jiak_link.rb +6 -8
- data/lib/riakrest/core/jiak_object.rb +15 -13
- data/lib/riakrest/core/jiak_schema.rb +192 -57
- data/lib/riakrest/resource/jiak_resource.rb +118 -170
- data/lib/riakrest.rb +24 -103
- data/spec/core/jiak_bucket_spec.rb +15 -45
- data/spec/core/jiak_client_spec.rb +70 -41
- data/spec/core/jiak_link_spec.rb +2 -2
- data/spec/core/jiak_object_spec.rb +12 -12
- data/spec/core/jiak_schema_spec.rb +122 -18
- data/spec/resource/jiak_resource_spec.rb +115 -148
- metadata +3 -5
- data/lib/riakrest/data/jiak_data_hash.rb +0 -182
- data/spec/data/jiak_data_hash_spec.rb +0 -14
@@ -1,71 +1,48 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
2
|
|
3
3
|
describe "JiakResource default" do
|
4
|
-
F1F2 = JiakDataHash.create(:f1,:f2)
|
5
4
|
class Rsrc # :nodoc:
|
6
5
|
include JiakResource
|
7
6
|
server 'http://localhost:8002/jiak/'
|
8
|
-
|
9
|
-
data_class F1F2
|
10
|
-
point_of_view
|
7
|
+
jattr_accessor :f1, :f2
|
11
8
|
end
|
12
9
|
|
13
10
|
before do
|
14
11
|
@server = 'http://localhost:8002/jiak/'
|
15
|
-
@group = '
|
16
|
-
@
|
12
|
+
@group = 'rsrc'
|
13
|
+
@schema = JiakSchema.new [:f1,:f2]
|
14
|
+
Rsrc.pov
|
17
15
|
end
|
18
16
|
|
19
17
|
describe "class creation" do
|
20
18
|
it "should respond to" do
|
21
|
-
Rsrc.should respond_to(:server,:group
|
19
|
+
Rsrc.should respond_to(:server,:group)
|
20
|
+
Rsrc.should respond_to(:jattr_reader,:jattr,:jattr_writer,:jattr_accessor)
|
22
21
|
Rsrc.should respond_to(:params,:auto_update,:schema,:keys)
|
23
|
-
Rsrc.should respond_to(:allowed,:required,:readable,:writable,:readwrite)
|
24
22
|
Rsrc.should respond_to(:point_of_view,:pov,:point_of_view?,:pov?)
|
25
23
|
Rsrc.should respond_to(:post,:put,:get,:delete)
|
26
24
|
Rsrc.should respond_to(:refresh,:update,:exist?)
|
27
25
|
Rsrc.should respond_to(:link,:bi_link,:query,:walk)
|
28
|
-
Rsrc.should respond_to(:
|
29
|
-
Rsrc.should respond_to(:auto_post,:auto_update,:
|
30
|
-
|
31
|
-
Rsrc.jiak.should respond_to(:server,:uri,:group,:data,:bucket,:auto_update)
|
26
|
+
Rsrc.should respond_to(:auto_post,:auto_update,:auto_manage)
|
27
|
+
Rsrc.should respond_to(:auto_post,:auto_update,:auto_manage?)
|
28
|
+
Rsrc.jiak.should respond_to(:server,:uri,:group,:data,:bucket)
|
32
29
|
end
|
33
30
|
|
34
31
|
it "should have specified settings" do
|
35
32
|
Rsrc.params.should be_empty
|
36
33
|
Rsrc.auto_update?.should be false
|
37
|
-
Rsrc.schema.should eql
|
34
|
+
Rsrc.schema.should eql @schema
|
38
35
|
|
39
36
|
Rsrc.jiak.should be_a Struct
|
40
37
|
Rsrc.jiak.server.should be_a JiakClient
|
41
38
|
Rsrc.jiak.uri.should eql @server
|
42
39
|
Rsrc.jiak.group.should eql @group
|
43
40
|
Rsrc.jiak.data.should include JiakData
|
44
|
-
Rsrc.jiak.data.should == F1F2
|
45
41
|
Rsrc.jiak.bucket.should be_a JiakBucket
|
46
42
|
Rsrc.jiak.bucket.name.should eql @group
|
47
|
-
Rsrc.jiak.
|
43
|
+
Rsrc.jiak.auto_post.should be false
|
48
44
|
Rsrc.jiak.auto_update.should be false
|
49
45
|
end
|
50
|
-
|
51
|
-
it "should copy with defaults and overrides" do
|
52
|
-
Rsrc_default = Rsrc.copy
|
53
|
-
Rsrc_default.jiak.uri.should eql @server
|
54
|
-
Rsrc_default.jiak.group.should eql @group
|
55
|
-
Rsrc_default.jiak.data.should == F1F2
|
56
|
-
Rsrc_default.auto_post?.should == Rsrc.auto_post?
|
57
|
-
Rsrc_default.auto_update?.should == Rsrc.auto_update?
|
58
|
-
|
59
|
-
DiffData = JiakDataHash.create
|
60
|
-
Rsrc_diff = Rsrc.copy(:server => 'scopy', :group => 'gcopy',
|
61
|
-
:data_class => DiffData,
|
62
|
-
:auto_post => true, :auto_update => true)
|
63
|
-
Rsrc_diff.jiak.uri.should eql 'scopy'
|
64
|
-
Rsrc_diff.jiak.group.should eql 'gcopy'
|
65
|
-
Rsrc_diff.jiak.data.should == DiffData
|
66
|
-
Rsrc_diff.auto_post?.should be true
|
67
|
-
Rsrc_diff.auto_update?.should be true
|
68
|
-
end
|
69
46
|
end
|
70
47
|
|
71
48
|
describe "instance creation" do
|
@@ -99,7 +76,6 @@ describe "JiakResource default" do
|
|
99
76
|
@rsrc.jiak.object.should be_a JiakObject
|
100
77
|
@rsrc.jiak.object.bucket.should be_a JiakBucket
|
101
78
|
@rsrc.jiak.object.bucket.name.should eql @group
|
102
|
-
@rsrc.jiak.object.bucket.data_class.should == F1F2
|
103
79
|
|
104
80
|
@rsrc.jiak.auto_update.should be_nil
|
105
81
|
end
|
@@ -107,64 +83,62 @@ describe "JiakResource default" do
|
|
107
83
|
end
|
108
84
|
|
109
85
|
describe "JiakResource default class-level auto-post/auto-update" do
|
110
|
-
|
111
|
-
PersonData.keygen :name
|
112
|
-
class Person # :nodoc:
|
86
|
+
class People # :nodoc:
|
113
87
|
include JiakResource
|
114
88
|
server 'http://localhost:8002/jiak'
|
115
89
|
group 'people'
|
116
|
-
|
90
|
+
jattr_accessor :name, :age
|
91
|
+
keygen { name }
|
117
92
|
point_of_view
|
118
93
|
end
|
119
94
|
|
120
95
|
before do
|
121
96
|
@name = 'p default'
|
122
|
-
@p =
|
97
|
+
@p = People.new(:name => @name, :age => 10)
|
123
98
|
end
|
124
99
|
|
125
100
|
it "should create instance without posting" do
|
126
|
-
|
101
|
+
People.auto_post?.should be false
|
127
102
|
|
128
|
-
|
103
|
+
People.exist?(@name).should be false
|
129
104
|
@p.local?.should be true
|
130
105
|
@p.post
|
131
|
-
|
106
|
+
People.get(@name).name.should eql @name
|
132
107
|
@p.local?.should be false
|
133
108
|
@p.delete
|
134
109
|
end
|
135
110
|
|
136
111
|
it "should change local data without updating" do
|
137
112
|
@p.post
|
138
|
-
|
113
|
+
People.get(@name).age.should eql 10
|
139
114
|
@p.age = 12
|
140
|
-
|
115
|
+
People.get(@name).age.should eql 10
|
141
116
|
@p.update
|
142
|
-
|
117
|
+
People.get(@name).age.should eql 12
|
143
118
|
@p.delete
|
144
119
|
end
|
145
120
|
|
146
121
|
it "should check if resource is local and if it exists on server" do
|
147
122
|
name = 'p local'
|
148
|
-
p =
|
123
|
+
p = People.new(:name => name)
|
149
124
|
p.local?.should be true
|
150
|
-
|
125
|
+
People.exist?(name).should be false
|
151
126
|
|
152
127
|
p.post
|
153
128
|
p.local?.should be false
|
154
|
-
|
129
|
+
People.exist?(name).should be true
|
155
130
|
|
156
131
|
p.delete
|
157
132
|
end
|
158
133
|
end
|
159
134
|
|
160
135
|
describe "JiakResource class auto-post" do
|
161
|
-
|
162
|
-
PersonData.keygen :name
|
163
|
-
class Person # :nodoc:
|
136
|
+
class People # :nodoc:
|
164
137
|
include JiakResource
|
165
138
|
server 'http://localhost:8002/jiak'
|
166
139
|
group 'people'
|
167
|
-
|
140
|
+
jattr_accessor :name, :age
|
141
|
+
keygen { name }
|
168
142
|
point_of_view
|
169
143
|
end
|
170
144
|
|
@@ -174,21 +148,21 @@ describe "JiakResource class auto-post" do
|
|
174
148
|
|
175
149
|
describe "false" do
|
176
150
|
before do
|
177
|
-
|
151
|
+
People.auto_post false
|
178
152
|
end
|
179
153
|
|
180
154
|
it "should not auto-post, or auto-update a local object" do
|
181
|
-
|
155
|
+
People.auto_post?.should be false
|
182
156
|
|
183
|
-
|
157
|
+
People.exist?(@name).should be false
|
184
158
|
|
185
|
-
|
186
|
-
p =
|
159
|
+
People.auto_update true
|
160
|
+
p = People.new(:name => @name, :age => 10)
|
187
161
|
p.local?.should be true
|
188
162
|
p.age = 12
|
189
163
|
p.local?.should be true
|
190
164
|
|
191
|
-
q =
|
165
|
+
q = People.new(:name => 'q', :age => 20)
|
192
166
|
|
193
167
|
link_to_local = lambda {p.link(q,'link')}
|
194
168
|
link_to_local.should raise_error(JiakResourceException,/local/)
|
@@ -203,11 +177,11 @@ describe "JiakResource class auto-post" do
|
|
203
177
|
p.post
|
204
178
|
p.local?.should be false
|
205
179
|
p.age.should be 12
|
206
|
-
|
207
|
-
p.query(
|
180
|
+
People.get(@name).age.should be 12
|
181
|
+
p.query(People,'link')[0].should eql q
|
208
182
|
|
209
183
|
p.age = 10
|
210
|
-
|
184
|
+
People.get(@name).age.should be 10
|
211
185
|
|
212
186
|
p.delete
|
213
187
|
q.delete
|
@@ -216,21 +190,21 @@ describe "JiakResource class auto-post" do
|
|
216
190
|
|
217
191
|
describe "true" do
|
218
192
|
before do
|
219
|
-
|
193
|
+
People.auto_post true
|
220
194
|
end
|
221
195
|
|
222
196
|
it "should auto-post a new instance" do
|
223
|
-
|
197
|
+
People.auto_post?.should be true
|
224
198
|
|
225
|
-
|
226
|
-
p =
|
227
|
-
|
199
|
+
People.exist?(@name).should be false
|
200
|
+
p = People.new(:name => @name, :age => 10)
|
201
|
+
People.get(@name).name.should eql @name
|
228
202
|
p.delete
|
229
203
|
end
|
230
204
|
|
231
205
|
it "should reject auto-post of a new instance with an existing key" do
|
232
|
-
p =
|
233
|
-
duplicate_key = lambda {
|
206
|
+
p = People.new(:name => @name, :age => 10)
|
207
|
+
duplicate_key = lambda {People.new(:name => p.name, :age => 0)}
|
234
208
|
duplicate_key.should raise_error(JiakResourceException,/exist/)
|
235
209
|
p.delete
|
236
210
|
end
|
@@ -238,122 +212,118 @@ describe "JiakResource class auto-post" do
|
|
238
212
|
end
|
239
213
|
|
240
214
|
describe "JiakResource class auto-update" do
|
241
|
-
|
242
|
-
DogData.keygen :name
|
243
|
-
class Dog # :nodoc:
|
215
|
+
class Dogs # :nodoc:
|
244
216
|
include JiakResource
|
245
217
|
server 'http://localhost:8002/jiak'
|
246
218
|
group 'dogs'
|
247
|
-
|
219
|
+
jattr_accessor :name, :age
|
220
|
+
keygen { name }
|
248
221
|
point_of_view
|
249
|
-
|
250
|
-
auto_update true
|
222
|
+
auto_manage
|
251
223
|
end
|
252
224
|
|
253
225
|
before do
|
254
226
|
@pname = 'p auto-update'
|
255
227
|
@c1name = 'c1 auto-update'
|
256
228
|
@c2name = 'c2 auto-update'
|
257
|
-
@p =
|
258
|
-
@c1 =
|
259
|
-
@c2 =
|
229
|
+
@p = Dogs.new(:name => @pname, :age => 10)
|
230
|
+
@c1 = Dogs.new(:name => @cname, :age => 4)
|
231
|
+
@c2 = Dogs.new(:name => @cname, :age => 4)
|
260
232
|
end
|
261
233
|
|
262
234
|
after do
|
263
235
|
@p.delete
|
264
236
|
@c1.delete
|
265
237
|
@c2.delete
|
266
|
-
|
238
|
+
Dogs.auto_update true
|
267
239
|
end
|
268
240
|
|
269
241
|
it "should auto-update local changes" do
|
270
|
-
|
242
|
+
Dogs.get(@pname).age.should eql 10
|
271
243
|
@p.age = 12
|
272
|
-
|
244
|
+
Dogs.get(@pname).age.should eql 12
|
273
245
|
|
274
|
-
|
246
|
+
Dogs.get(@pname).name.should eql @pname
|
275
247
|
@p.name = @pname.upcase
|
276
|
-
|
248
|
+
Dogs.get(@pname).name.should eql @pname.upcase
|
277
249
|
|
278
|
-
@p.query(
|
250
|
+
@p.query(Dogs,'pup').size.should eql 0
|
279
251
|
@p.link(@c1,'pup')
|
280
|
-
@p.query(
|
252
|
+
@p.query(Dogs,'pup').size.should eql 1
|
281
253
|
|
282
|
-
[@c1,@c2].each {|c| c.query(
|
254
|
+
[@c1,@c2].each {|c| c.query(Dogs,'sibling').size.should eql 0}
|
283
255
|
@c1.bi_link(@c2,'sibling')
|
284
|
-
[@c1,@c2].each {|c| c.query(
|
256
|
+
[@c1,@c2].each {|c| c.query(Dogs,'sibling').size.should eql 1}
|
285
257
|
end
|
286
258
|
|
287
259
|
it "should allow instance level override of class level auto-update true" do
|
288
260
|
@p.auto_update?.should be nil
|
289
261
|
|
290
|
-
|
262
|
+
Dogs.get(@pname).age.should eql 10
|
291
263
|
@p.auto_update = false
|
292
264
|
@p.auto_update?.should be false
|
293
265
|
@p.age = 12
|
294
|
-
|
266
|
+
Dogs.get(@pname).age.should eql 10
|
295
267
|
@p.update
|
296
|
-
|
268
|
+
Dogs.get(@pname).age.should eql 12
|
297
269
|
|
298
|
-
[@c1,@c2].each {|c| c.query(
|
270
|
+
[@c1,@c2].each {|c| c.query(Dogs,'sibling').size.should eql 0}
|
299
271
|
@c2.auto_update = false
|
300
272
|
@c1.bi_link(@c2,'sibling')
|
301
|
-
@c1.query(
|
302
|
-
@c2.query(
|
273
|
+
@c1.query(Dogs,'sibling').size.should eql 1
|
274
|
+
@c2.query(Dogs,'sibling').size.should eql 0
|
303
275
|
end
|
304
276
|
|
305
277
|
it "should allow instance level override of class level auto-update false" do
|
306
|
-
|
278
|
+
Dogs.auto_update false
|
307
279
|
|
308
|
-
|
280
|
+
Dogs.get(@pname).age.should eql 10
|
309
281
|
@p.auto_update = true
|
310
282
|
@p.auto_update?.should be true
|
311
283
|
@p.age = 12
|
312
|
-
|
284
|
+
Dogs.get(@pname).age.should eql 12
|
313
285
|
|
314
|
-
[@c1,@c2].each {|c| c.query(
|
286
|
+
[@c1,@c2].each {|c| c.query(Dogs,'sibling').size.should eql 0}
|
315
287
|
@c2.auto_update = true
|
316
288
|
@c1.bi_link(@c2,'sibling')
|
317
|
-
@c1.query(
|
318
|
-
@c2.query(
|
289
|
+
@c1.query(Dogs,'sibling').size.should eql 0
|
290
|
+
@c2.query(Dogs,'sibling').size.should eql 1
|
319
291
|
end
|
320
292
|
|
321
293
|
it "should allow instance level deferring back to class level" do
|
322
|
-
|
294
|
+
Dogs.get(@pname).age.should eql 10
|
323
295
|
@p.auto_update = false
|
324
296
|
@p.age = 12
|
325
|
-
|
297
|
+
Dogs.get(@pname).age.should eql 10
|
326
298
|
@p.update
|
327
|
-
|
299
|
+
Dogs.get(@pname).age.should eql 12
|
328
300
|
|
329
301
|
@p.auto_update = nil
|
330
302
|
@p.auto_update?.should be nil
|
331
303
|
@p.age = 10
|
332
|
-
|
304
|
+
Dogs.get(@pname).age.should eql 10
|
333
305
|
end
|
334
306
|
|
335
307
|
end
|
336
308
|
|
337
309
|
describe "JiakResource simple" do
|
338
|
-
|
339
|
-
DogData.keygen :name
|
340
|
-
class Dog # :nodoc:
|
310
|
+
class Dogs # :nodoc:
|
341
311
|
include JiakResource
|
342
312
|
server 'http://localhost:8002/jiak'
|
343
313
|
group 'dogs'
|
344
|
-
|
314
|
+
jattr_accessor :name, :age
|
315
|
+
keygen { name }
|
345
316
|
point_of_view
|
346
|
-
|
347
|
-
auto_update true
|
317
|
+
auto_manage
|
348
318
|
end
|
349
319
|
|
350
320
|
before do
|
351
321
|
@pname = 'p'
|
352
322
|
@c1name = 'c1'
|
353
323
|
@c2name = 'c2'
|
354
|
-
@p =
|
355
|
-
@c1 =
|
356
|
-
@c2 =
|
324
|
+
@p = Dogs.new(:name => @pname, :age => 10)
|
325
|
+
@c1 = Dogs.new(:name => @c1name, :age => 4)
|
326
|
+
@c2 = Dogs.new(:name => @c2name, :age => 4)
|
357
327
|
end
|
358
328
|
|
359
329
|
after do
|
@@ -363,54 +333,51 @@ describe "JiakResource simple" do
|
|
363
333
|
end
|
364
334
|
|
365
335
|
it "should do basic interaction and single-step relationships" do
|
366
|
-
|
367
|
-
|
336
|
+
Dogs.exist?(@pname).should be true
|
337
|
+
Dogs.get(@pname).should eql @p
|
368
338
|
|
369
339
|
@p.name.should eql @pname
|
370
340
|
@p.age.should eql 10
|
371
341
|
|
372
342
|
@p.age = 11
|
373
|
-
@p =
|
343
|
+
@p = Dogs.get(@pname)
|
374
344
|
@p.age.should eql 11
|
375
345
|
|
376
346
|
[@c1,@c2].each {|c| @p.link(c,'pup')}
|
377
|
-
pups = @p.query(
|
347
|
+
pups = @p.query(Dogs,'pup')
|
378
348
|
pups.size.should eql 2
|
379
349
|
same_elements = pups.map {|c| c.name}.same_elements?([@c1.name,@c2.name])
|
380
350
|
same_elements.should be true
|
381
351
|
|
382
352
|
@c1.bi_link(@c2,'sibling')
|
383
|
-
[@c1,@c2].each {|c| c.query(
|
384
|
-
@c1.query(
|
385
|
-
@c2.query(
|
353
|
+
[@c1,@c2].each {|c| c.query(Dogs,'sibling').size.should eql 1}
|
354
|
+
@c1.query(Dogs,'sibling')[0].should eql @c2
|
355
|
+
@c2.query(Dogs,'sibling')[0].should eql @c1
|
386
356
|
|
387
357
|
@c1.remove_link(@c2,'sibling')
|
388
|
-
@c1.query(
|
389
|
-
@c2.query(
|
358
|
+
@c1.query(Dogs,'sibling').size.should eql 0
|
359
|
+
@c2.query(Dogs,'sibling').size.should eql 1
|
390
360
|
|
391
361
|
[@c1,@c2].each {|c| c.link(@p,'parent')}
|
392
362
|
|
393
|
-
@c1.query(
|
394
|
-
@c2.query(
|
395
|
-
@c2.query(
|
396
|
-
@c2.query(
|
363
|
+
@c1.query(Dogs).size.should eql 1
|
364
|
+
@c2.query(Dogs).size.should eql 2
|
365
|
+
@c2.query(Dogs,'sibling').size.should eql 1
|
366
|
+
@c2.query(Dogs,'parent').size.should eql 1
|
397
367
|
end
|
398
368
|
end
|
399
369
|
|
400
370
|
describe "JiakResource complex" do
|
401
|
-
|
402
|
-
PersonData.keygen :name
|
403
|
-
|
404
|
-
class Parent # :nodoc:
|
371
|
+
class Parents # :nodoc:
|
405
372
|
include JiakResource
|
406
|
-
|
407
373
|
server 'http://localhost:8002/jiak'
|
408
|
-
|
409
|
-
|
374
|
+
jattr_accessor :name
|
375
|
+
keygen { name }
|
410
376
|
point_of_view
|
411
377
|
end
|
412
378
|
|
413
|
-
|
379
|
+
Children = Parents.dup
|
380
|
+
Children.group 'children'
|
414
381
|
|
415
382
|
it "should do multi-step relationships" do
|
416
383
|
# relationships
|
@@ -431,12 +398,12 @@ describe "JiakResource complex" do
|
|
431
398
|
|
432
399
|
# store data and relationships
|
433
400
|
parent_children.each do |pname,cnames|
|
434
|
-
p =
|
401
|
+
p = Parents.new(:name => pname).post
|
435
402
|
cnames.each do |cname|
|
436
403
|
begin
|
437
|
-
c =
|
404
|
+
c = Children.get(cname)
|
438
405
|
rescue
|
439
|
-
c =
|
406
|
+
c = Children.new(:name => cname)
|
440
407
|
end
|
441
408
|
c.link(p,'parent')
|
442
409
|
c.put
|
@@ -445,13 +412,13 @@ describe "JiakResource complex" do
|
|
445
412
|
p.update
|
446
413
|
end
|
447
414
|
|
448
|
-
parents = parent_children.keys.map {|p|
|
449
|
-
children = child_parents.keys.map {|c|
|
415
|
+
parents = parent_children.keys.map {|p| Parents.get(p)}
|
416
|
+
children = child_parents.keys.map {|c| Children.get(c)}
|
450
417
|
c0,c1,c2,c3,c4 = children
|
451
418
|
|
452
419
|
# siblings
|
453
420
|
c0s,c1s,c2s,c3s,c4s = children.map do |c|
|
454
|
-
c.query(
|
421
|
+
c.query(Parents,'parent',Children,'child').delete_if{|s| s.eql?(c)}
|
455
422
|
end
|
456
423
|
c0s.size.should eql 2
|
457
424
|
c1s.size.should eql 2
|
@@ -465,21 +432,21 @@ describe "JiakResource complex" do
|
|
465
432
|
same_elements.should be true
|
466
433
|
|
467
434
|
# c3's step-sibling's other parent?
|
468
|
-
c3sp = c3.query(
|
469
|
-
c3.query(
|
435
|
+
c3sp = c3.query(Parents,'parent',Children,'child',Parents,'parent')
|
436
|
+
c3.query(Parents,'parent').each {|p| c3sp.delete_if{|sp| p.eql?(sp)}}
|
470
437
|
c3sp[0].name.should eql parents[1].name
|
471
438
|
|
472
439
|
# add sibling links
|
473
|
-
|
440
|
+
Children.auto_update true
|
474
441
|
children.each do |c|
|
475
|
-
siblings = c.query(
|
442
|
+
siblings = c.query(Parents,'parent',Children,'child').delete_if{|s| s.eql?(c)}
|
476
443
|
siblings.each {|s| c.link(s,'sibling')}
|
477
444
|
end
|
478
|
-
c0.query(
|
479
|
-
c1.query(
|
480
|
-
c2.query(
|
481
|
-
c3.query(
|
482
|
-
c4.query(
|
445
|
+
c0.query(Children,'sibling').size.should eql 2
|
446
|
+
c1.query(Children,'sibling').size.should eql 2
|
447
|
+
c2.query(Children,'sibling').size.should eql 3
|
448
|
+
c3.query(Children,'sibling').size.should eql 1
|
449
|
+
c4.query(Children,'sibling').size.should eql 0
|
483
450
|
|
484
451
|
parents.each {|p| p.delete}
|
485
452
|
children.each {|c| c.delete}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riakrest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Rogers
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-17 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -71,11 +71,11 @@ files:
|
|
71
71
|
- lib/riakrest/core/jiak_bucket.rb
|
72
72
|
- lib/riakrest/core/jiak_client.rb
|
73
73
|
- lib/riakrest/core/jiak_data.rb
|
74
|
+
- lib/riakrest/core/jiak_data_fields.rb
|
74
75
|
- lib/riakrest/core/jiak_link.rb
|
75
76
|
- lib/riakrest/core/jiak_object.rb
|
76
77
|
- lib/riakrest/core/jiak_schema.rb
|
77
78
|
- lib/riakrest/core/query_link.rb
|
78
|
-
- lib/riakrest/data/jiak_data_hash.rb
|
79
79
|
- lib/riakrest/resource/jiak_resource.rb
|
80
80
|
- spec/core/exceptions_spec.rb
|
81
81
|
- spec/core/jiak_bucket_spec.rb
|
@@ -84,7 +84,6 @@ files:
|
|
84
84
|
- spec/core/jiak_object_spec.rb
|
85
85
|
- spec/core/jiak_schema_spec.rb
|
86
86
|
- spec/core/query_link_spec.rb
|
87
|
-
- spec/data/jiak_data_hash_spec.rb
|
88
87
|
- spec/resource/jiak_resource_spec.rb
|
89
88
|
- spec/riakrest_spec.rb
|
90
89
|
- spec/spec.opts
|
@@ -125,7 +124,6 @@ test_files:
|
|
125
124
|
- spec/core/jiak_object_spec.rb
|
126
125
|
- spec/core/jiak_schema_spec.rb
|
127
126
|
- spec/core/query_link_spec.rb
|
128
|
-
- spec/data/jiak_data_hash_spec.rb
|
129
127
|
- spec/resource/jiak_resource_spec.rb
|
130
128
|
- spec/riakrest_spec.rb
|
131
129
|
- spec/spec_helper.rb
|