riakrest 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,9 +10,9 @@ end
10
10
 
11
11
  describe "JiakClient" do
12
12
  before do
13
- @base_uri = 'http://127.0.0.1:8002/jiak/'
13
+ @base_uri = SERVER_URI
14
14
  @client = JiakClient.new(@base_uri)
15
- @params = {:reads => 1, :writes => 2, :durable_writes => 3, :waits => 4}
15
+ @params = {:reads => 1, :writes => 2, :durable_writes => 3, :deletes => 4}
16
16
  @opts = @params.merge({:proxy => 'proxy_uri'})
17
17
  end
18
18
 
@@ -20,16 +20,49 @@ describe "JiakClient" do
20
20
  @client.should respond_to(:set_schema,:schema,:keys)
21
21
  @client.should respond_to(:proxy,:proxy=)
22
22
  @client.should respond_to(:params,:set_params,:params=)
23
- @client.should respond_to(:get,:store,:delete,:walk)
23
+ @client.should respond_to(:store,:get,:delete)
24
+ @client.should respond_to(:exist?,:walk)
24
25
  @client.should respond_to(:==,:eql?)
25
26
  end
26
27
 
28
+ it "should protect constants" do
29
+ no_no = lambda {JiakClient::APP_JSON << 'a'}
30
+ no_no.should raise_error(StandardError,/frozen/)
31
+
32
+ no_no = lambda {JiakClient::RETURN_BODY << 'a'}
33
+ no_no.should raise_error(StandardError,/frozen/)
34
+
35
+ no_no = lambda {JiakClient::READS << 'a'}
36
+ no_no.should raise_error(StandardError,/frozen/)
37
+
38
+ no_no = lambda {JiakClient::WRITES << 'a'}
39
+ no_no.should raise_error(StandardError,/frozen/)
40
+
41
+ no_no = lambda {JiakClient::DURABLE_WRITES << 'a'}
42
+ no_no.should raise_error(StandardError,/frozen/)
43
+
44
+ no_no = lambda {JiakClient::DELETES << 'a'}
45
+ no_no.should raise_error(StandardError,/frozen/)
46
+
47
+ no_no = lambda {JiakClient::VALID_PARAMS << 'a'}
48
+ no_no.should raise_error(StandardError,/frozen/)
49
+
50
+ no_no = lambda {JiakClient::VALID_OPTS << 'a'}
51
+ no_no.should raise_error(StandardError,/frozen/)
52
+
53
+ no_no = lambda {JiakClient::KEYS << 'a'}
54
+ no_no.should raise_error(StandardError,/frozen/)
55
+
56
+ no_no = lambda {JiakClient::SCHEMA << 'a'}
57
+ no_no.should raise_error(StandardError,/frozen/)
58
+ end
59
+
27
60
  it "should default to base URI" do
28
61
  @client.server.should match @base_uri
29
62
  end
30
63
 
31
64
  it "should allow specified base URI" do
32
- base_uri = 'http://localhost:1234/tmp/'
65
+ base_uri = 'http://host:port/base/'
33
66
  client = JiakClient.new base_uri
34
67
  client.server.should match base_uri
35
68
  end
@@ -69,12 +102,12 @@ describe "JiakClient" do
69
102
  @client.params = @params
70
103
  @params.each {|k,v| @client.params[k].should == @params[k]}
71
104
 
72
- @client.set_params(:writes => 1, :waits => nil)
105
+ @client.set_params(:writes => 1, :deletes => nil)
73
106
  params = @client.params
74
107
  params[:reads].should eql 1
75
108
  params[:writes].should eql 1
76
109
  params[:durable_writes].should eql 3
77
- params[:waits].should eql nil
110
+ params[:deletes].should eql nil
78
111
 
79
112
  bad_opts = lambda {@client.set_params(:junk => 'junk')}
80
113
  bad_opts.should raise_error(JiakClientException,/option/)
@@ -87,7 +120,7 @@ end
87
120
 
88
121
  describe "JiakClient URI handling" do
89
122
  before do
90
- @base_uri = 'http://127.0.0.1:8002/jiak/'
123
+ @base_uri = SERVER_URI
91
124
  @client = JiakClient.new @base_uri
92
125
  @bucket = JiakBucket.new('uri_bucket',FooBarBaz)
93
126
  @key = 'uri_key'
@@ -96,7 +129,7 @@ end
96
129
 
97
130
  describe "JiakClient processing" do
98
131
  before do
99
- @base_uri = 'http://127.0.0.1:8002/jiak/'
132
+ @base_uri = SERVER_URI
100
133
  @client = JiakClient.new @base_uri
101
134
  end
102
135
 
@@ -107,7 +140,24 @@ describe "JiakClient processing" do
107
140
  @client.set_schema(@bucket)
108
141
  end
109
142
 
110
- it "should create and fetch a bucket schema" do
143
+ it "should fetch schema by bucket or bucket name" do
144
+ @client.schema(@bucket).should eql FooBarBaz.schema
145
+ @client.schema(@bucket.name).should eql FooBarBaz.schema
146
+ end
147
+
148
+ it "should fetch default schema" do
149
+ bucket_name = "wide open"
150
+ bucket = JiakBucket.new(bucket_name,FooBarBaz)
151
+ @client.schema(bucket).should eql JiakSchema::WIDE_OPEN
152
+ end
153
+
154
+ it "should set and fetch a wide open schema" do
155
+ @client.schema(@bucket).should_not eql JiakSchema::WIDE_OPEN
156
+ @client.set_schema(@bucket.name,JiakSchema::WIDE_OPEN)
157
+ @client.schema(@bucket).should eql JiakSchema::WIDE_OPEN
158
+ end
159
+
160
+ it "should set and fetch a bucket schema" do
111
161
  schema = @client.schema(@bucket)
112
162
 
113
163
  ['allowed_fields',
@@ -129,7 +179,6 @@ describe "JiakClient processing" do
129
179
  resp_schema.required_fields.should be_empty
130
180
  resp_schema.read_mask.should include :baz
131
181
  resp_schema.write_mask.should include :baz
132
-
133
182
  end
134
183
 
135
184
  it "should get a list of keys for a bucket" do
@@ -159,7 +208,11 @@ describe "JiakClient processing" do
159
208
  before do
160
209
  @bucket = JiakBucket.new('bucket_2',FooBarBaz)
161
210
  @client.set_schema(@bucket)
162
- @data = FooBarBaz.new(:foo => 'foo val')
211
+ @data = FooBarBaz.new(:foo => 'Foo',:bar => 'Bar')
212
+ end
213
+
214
+ after do
215
+ @client.keys(@bucket).each {|key| @client.delete(@bucket,key)}
163
216
  end
164
217
 
165
218
  describe "storage" do
@@ -205,10 +258,17 @@ describe "JiakClient processing" do
205
258
  end
206
259
 
207
260
  describe "fetching" do
261
+ it "should check for resource existence" do
262
+ jobj = JiakObject.new(:bucket => @bucket, :data => @data)
263
+ key = @client.store(jobj)
264
+
265
+ @client.exist?(@bucket,key).should be true
266
+ @client.exist?(@bucket,'nope').should be false
267
+ end
268
+
208
269
  it "should get a previously stored JiakObject" do
209
- key = 'fetch_key_1'
210
- jobj = JiakObject.new(:bucket => @bucket, :key => key, :data => @data)
211
- @client.store(jobj)
270
+ jobj = JiakObject.new(:bucket => @bucket, :data => @data)
271
+ key = @client.store(jobj)
212
272
 
213
273
  fetched = @client.get(@bucket,key)
214
274
  fetched.should be_a JiakObject
@@ -222,6 +282,16 @@ describe "JiakClient processing" do
222
282
  fetched.should be_a JiakObject
223
283
  end
224
284
 
285
+ it "should accept write and read parameters" do
286
+ key = 'fetch_key_wr'
287
+ jobj = JiakObject.new(:bucket => @bucket, :key => key, :data => @data)
288
+ jobj = @client.store(jobj,
289
+ :writes => 3, :reads => 3,
290
+ :return => :object)
291
+
292
+ jobj = @client.get(@bucket, key, :reads => 1)
293
+ end
294
+
225
295
  it "should raise JiakResourceNotFound for a non-existent key" do
226
296
  get_nope = lambda {@client.get(@bucket,'nope')}
227
297
  get_nope.should raise_error(JiakResourceNotFound)
@@ -275,7 +345,7 @@ end
275
345
 
276
346
  describe "JiakClient links" do
277
347
  before do
278
- @base_uri = 'http://127.0.0.1:8002/jiak/'
348
+ @base_uri = SERVER_URI
279
349
  @client = JiakClient.new @base_uri
280
350
 
281
351
  @p_bucket = JiakBucket.new('parent',PersonData)
@@ -28,6 +28,14 @@ describe "JiakSchema" do
28
28
  @jiak_schema.should respond_to(:==,:eql?)
29
29
  end
30
30
 
31
+ it "should protect constants" do
32
+ no_no = lambda {JiakSchema::WIDE_OPEN.allow :x}
33
+ no_no.should raise_error(StandardError,/frozen/)
34
+
35
+ no_no = lambda {JiakSchema::WILDCARD << 'a'}
36
+ no_no.should raise_error(StandardError,/frozen/)
37
+ end
38
+
31
39
  it "should create using defaults from allowed_fields" do
32
40
  jiak_schema = JiakSchema.new({:allowed_fields => @allowed_fields})
33
41
  jiak_schema.allowed_fields.should eql @allowed_fields
@@ -136,6 +144,7 @@ describe "JiakSchema" do
136
144
  it "should ignore duplicate fields" do
137
145
  hash = @hash.clone
138
146
  hash[:allowed_fields] << @allowed_fields[0].to_s
147
+
139
148
  jiak_schema = JiakSchema.new(hash)
140
149
  jiak_schema.should eql @jiak_schema
141
150
 
@@ -144,15 +153,55 @@ describe "JiakSchema" do
144
153
 
145
154
  hash[:read_mask] << @read_mask[0]
146
155
  jiak_schema.read_mask = hash[:read_mask]
147
- jiak_schema.read_mask.should eql @hash[:read_mask]
156
+ jiak_schema.read_mask.should eql @jiak_schema.read_mask
148
157
 
149
158
  hash[:write_mask] << @write_mask[0]
150
159
  jiak_schema.write_mask = hash[:write_mask]
151
- jiak_schema.write_mask.should eql @hash[:write_mask]
160
+ jiak_schema.write_mask.should eql @jiak_schema.write_mask
152
161
 
153
162
  jiak_schema.readwrite = hash[:read_mask]
154
- jiak_schema.read_mask.should eql @hash[:read_mask]
155
- jiak_schema.write_mask.should eql @hash[:read_mask]
163
+ jiak_schema.read_mask.should eql @jiak_schema.read_mask
164
+ jiak_schema.write_mask.should eql @jiak_schema.read_mask
165
+ end
166
+
167
+ it "should be independent of init arg" do
168
+ @jiak_schema.allowed_fields.should eql @hash[:allowed_fields]
169
+ @hash[:allowed_fields] << :junk
170
+ @jiak_schema.allowed_fields.should_not eql @hash[:allowed_fields]
171
+
172
+ @jiak_schema.required_fields.should eql @hash[:required_fields]
173
+ @hash[:required_fields] << :junk
174
+ @jiak_schema.required_fields.should_not eql @hash[:required_fields]
175
+
176
+ @jiak_schema.read_mask.should eql @hash[:read_mask]
177
+ @hash[:read_mask] << :junk
178
+ @jiak_schema.read_mask.should_not eql @hash[:read_mask]
179
+
180
+ @jiak_schema.write_mask.should eql @hash[:write_mask]
181
+ @hash[:write_mask] << :junk
182
+ @jiak_schema.write_mask.should_not eql @hash[:write_mask]
183
+
184
+ arr = [:a,:b]
185
+ jiak_schema = JiakSchema.new(arr)
186
+ jiak_schema.allowed_fields.should eql arr
187
+ arr << :c
188
+ jiak_schema.allowed_fields.should_not eql arr
189
+ end
190
+
191
+ it "should init with wildcards" do
192
+ jiak_schema = JiakSchema.new(JiakSchema::WILDCARD)
193
+ jiak_schema.allowed_fields.should eql JiakSchema::WILDCARD
194
+ jiak_schema.required_fields.should be_empty
195
+ jiak_schema.read_mask.should eql JiakSchema::WILDCARD
196
+ jiak_schema.write_mask.should eql JiakSchema::WILDCARD
197
+ end
198
+
199
+ it "should init a wide open schema" do
200
+ jiak_schema = JiakSchema::WIDE_OPEN
201
+ jiak_schema.allowed_fields.should eql JiakSchema::WILDCARD
202
+ jiak_schema.required_fields.should be_empty
203
+ jiak_schema.read_mask.should eql JiakSchema::WILDCARD
204
+ jiak_schema.write_mask.should eql JiakSchema::WILDCARD
156
205
  end
157
206
 
158
207
  it "should update individual arrays" do
@@ -194,6 +243,59 @@ describe "JiakSchema" do
194
243
  jiak_schema.write_mask.should eql arr123
195
244
  end
196
245
 
246
+ it "should update wild card arrays" do
247
+ array = [:f1]
248
+ jiak_schema = JiakSchema.new(JiakSchema::WILDCARD)
249
+ jiak_schema.allow :f1
250
+ jiak_schema.allowed_fields.should eql array
251
+ jiak_schema.required_fields.should be_empty
252
+ jiak_schema.read_mask.should eql JiakSchema::WILDCARD
253
+ jiak_schema.write_mask.should eql JiakSchema::WILDCARD
254
+
255
+ array << :f2
256
+ jiak_schema = JiakSchema.new(JiakSchema::WILDCARD)
257
+ jiak_schema.readable array
258
+ jiak_schema.allowed_fields.should eql array
259
+ jiak_schema.required_fields.should be_empty
260
+ jiak_schema.read_mask.should eql array
261
+ jiak_schema.write_mask.should eql JiakSchema::WILDCARD
262
+
263
+ array << :f3
264
+ jiak_schema = JiakSchema.new(JiakSchema::WILDCARD)
265
+ jiak_schema.writable array
266
+ jiak_schema.allowed_fields.should eql array
267
+ jiak_schema.required_fields.should be_empty
268
+ jiak_schema.read_mask.should eql JiakSchema::WILDCARD
269
+ jiak_schema.write_mask.should eql array
270
+
271
+ array << :f4
272
+ jiak_schema = JiakSchema.new(JiakSchema::WILDCARD)
273
+ jiak_schema.readwrite array
274
+ jiak_schema.allowed_fields.should eql array
275
+ jiak_schema.required_fields.should be_empty
276
+ jiak_schema.read_mask.should eql array
277
+ jiak_schema.write_mask.should eql array
278
+ end
279
+
280
+ it "should set wild card arrays" do
281
+ @jiak_schema.allowed_fields = JiakSchema::WILDCARD
282
+ @jiak_schema.allowed_fields.should eql JiakSchema::WILDCARD
283
+ @jiak_schema.read_mask.should eql @read_mask
284
+ @jiak_schema.write_mask.should eql @write_mask
285
+
286
+ @jiak_schema.read_mask = JiakSchema::WILDCARD
287
+ @jiak_schema.allowed_fields.should eql JiakSchema::WILDCARD
288
+ @jiak_schema.read_mask.should eql JiakSchema::WILDCARD
289
+ @jiak_schema.write_mask.should eql @write_mask
290
+
291
+ @jiak_schema.write_mask = JiakSchema::WILDCARD
292
+ @jiak_schema.allowed_fields.should eql JiakSchema::WILDCARD
293
+ @jiak_schema.read_mask.should eql JiakSchema::WILDCARD
294
+ @jiak_schema.write_mask.should eql JiakSchema::WILDCARD
295
+
296
+ @jiak_schema.required_fields.should eql @required_fields
297
+ end
298
+
197
299
  it "should return added fields when updating individual arrays" do
198
300
  arr12 = [:f1,:f2]
199
301
  arr23 = [:f2,:f3]
@@ -262,7 +364,7 @@ describe "JiakSchema" do
262
364
  end
263
365
 
264
366
  it "should convert to json" do
265
- @jiak_schema.to_jiak.should eql ({:schema => @hash})
367
+ @jiak_schema.to_jiak.should eql({:schema => @hash})
266
368
  end
267
369
 
268
370
  it "should equal an equal JiakSchema" do
@@ -3,29 +3,28 @@ require File.dirname(__FILE__) + '/../spec_helper.rb'
3
3
  describe "JiakResource default" do
4
4
  class Rsrc # :nodoc:
5
5
  include JiakResource
6
- server 'http://localhost:8002/jiak/'
6
+ server SERVER_URI
7
7
  jattr_accessor :f1, :f2
8
8
  end
9
9
 
10
10
  before do
11
- @server = 'http://localhost:8002/jiak/'
11
+ @server_uri = SERVER_URI
12
12
  @group = 'rsrc'
13
13
  @schema = JiakSchema.new [:f1,:f2]
14
- Rsrc.pov
15
14
  end
16
15
 
17
16
  describe "class creation" do
18
17
  it "should respond to" do
19
18
  Rsrc.should respond_to(:server,:group)
20
19
  Rsrc.should respond_to(:jattr_reader,:jattr,:jattr_writer,:jattr_accessor)
21
- Rsrc.should respond_to(:params,:auto_update,:schema,:keys)
22
- Rsrc.should respond_to(:point_of_view,:pov,:point_of_view?,:pov?)
20
+ Rsrc.should respond_to(:params,:auto_update,:keys)
21
+ Rsrc.should respond_to(:schema,:push_schema,:server_schema?)
23
22
  Rsrc.should respond_to(:post,:put,:get,:delete)
24
23
  Rsrc.should respond_to(:refresh,:update,:exist?)
25
24
  Rsrc.should respond_to(:link,:bi_link,:query,:walk)
26
25
  Rsrc.should respond_to(:auto_post,:auto_update,:auto_manage)
27
26
  Rsrc.should respond_to(:auto_post,:auto_update,:auto_manage?)
28
- Rsrc.jiak.should respond_to(:server,:uri,:group,:data,:bucket)
27
+ Rsrc.jiak.should respond_to(:client,:uri,:group,:data,:bucket)
29
28
  end
30
29
 
31
30
  it "should have specified settings" do
@@ -34,8 +33,8 @@ describe "JiakResource default" do
34
33
  Rsrc.schema.should eql @schema
35
34
 
36
35
  Rsrc.jiak.should be_a Struct
37
- Rsrc.jiak.server.should be_a JiakClient
38
- Rsrc.jiak.uri.should eql @server
36
+ Rsrc.jiak.client.should be_a JiakClient
37
+ Rsrc.jiak.uri.should eql @server_uri
39
38
  Rsrc.jiak.group.should eql @group
40
39
  Rsrc.jiak.data.should include JiakData
41
40
  Rsrc.jiak.bucket.should be_a JiakBucket
@@ -51,7 +50,7 @@ describe "JiakResource default" do
51
50
  end
52
51
 
53
52
  it "should respond to" do
54
- @rsrc.should respond_to(:jiak,:jiak=)
53
+ @rsrc.should respond_to(:jiak)
55
54
  @rsrc.should respond_to(:auto_update=,:auto_update?)
56
55
  @rsrc.should respond_to(:post,:put,:delete)
57
56
  @rsrc.should respond_to(:update,:push,:refresh,:pull)
@@ -82,14 +81,37 @@ describe "JiakResource default" do
82
81
  end
83
82
  end
84
83
 
84
+ describe "JiakResource schema" do
85
+ class People # :nodoc:
86
+ include JiakResource
87
+ server SERVER_URI
88
+ group 'schema'
89
+ jattr_accessor :name, :age
90
+ keygen { name }
91
+ end
92
+
93
+ it "should have data schema" do
94
+ jiak_schema = JiakSchema.new([:name,:age])
95
+ People.schema.should eql jiak_schema
96
+ end
97
+
98
+ it "should push/check server schema" do
99
+ People.server_schema?.should be false
100
+ People.push_schema
101
+ People.server_schema?.should be true
102
+
103
+ People.push_schema(JiakSchema::WIDE_OPEN)
104
+ People.server_schema?.should be false
105
+ end
106
+ end
107
+
85
108
  describe "JiakResource default class-level auto-post/auto-update" do
86
109
  class People # :nodoc:
87
110
  include JiakResource
88
- server 'http://localhost:8002/jiak'
111
+ server SERVER_URI
89
112
  group 'people'
90
113
  jattr_accessor :name, :age
91
114
  keygen { name }
92
- point_of_view
93
115
  end
94
116
 
95
117
  before do
@@ -135,11 +157,10 @@ end
135
157
  describe "JiakResource class auto-post" do
136
158
  class People # :nodoc:
137
159
  include JiakResource
138
- server 'http://localhost:8002/jiak'
160
+ server SERVER_URI
139
161
  group 'people'
140
162
  jattr_accessor :name, :age
141
163
  keygen { name }
142
- point_of_view
143
164
  end
144
165
 
145
166
  before do
@@ -214,11 +235,10 @@ end
214
235
  describe "JiakResource class auto-update" do
215
236
  class Dogs # :nodoc:
216
237
  include JiakResource
217
- server 'http://localhost:8002/jiak'
238
+ server SERVER_URI
218
239
  group 'dogs'
219
240
  jattr_accessor :name, :age
220
241
  keygen { name }
221
- point_of_view
222
242
  auto_manage
223
243
  end
224
244
 
@@ -309,11 +329,10 @@ end
309
329
  describe "JiakResource simple" do
310
330
  class Dogs # :nodoc:
311
331
  include JiakResource
312
- server 'http://localhost:8002/jiak'
332
+ server SERVER_URI
313
333
  group 'dogs'
314
334
  jattr_accessor :name, :age
315
335
  keygen { name }
316
- point_of_view
317
336
  auto_manage
318
337
  end
319
338
 
@@ -370,10 +389,9 @@ end
370
389
  describe "JiakResource complex" do
371
390
  class Parents # :nodoc:
372
391
  include JiakResource
373
- server 'http://localhost:8002/jiak'
392
+ server SERVER_URI
374
393
  jattr_accessor :name
375
394
  keygen { name }
376
- point_of_view
377
395
  end
378
396
 
379
397
  Children = Parents.dup
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  begin
2
2
  require 'spec'
3
+ require 'json'
3
4
  rescue LoadError
4
5
  require 'rubygems' unless ENV['NO_RUBYGEMS']
5
6
  gem 'rspec'
@@ -10,3 +11,5 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
10
11
 
11
12
  require 'riakrest'
12
13
  include RiakRest
14
+
15
+ SERVER_URI = 'http://localhost:8002/jiak' unless(defined?(SERVER_URI))
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.1.0
4
+ version: 0.1.2
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-17 00:00:00 -08:00
12
+ date: 2009-11-29 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,6 +22,16 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.0.0
24
24
  version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.9
34
+ version:
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: rest-client
27
37
  type: :development
@@ -32,6 +42,26 @@ dependencies:
32
42
  - !ruby/object:Gem::Version
33
43
  version: 1.0.0
34
44
  version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: json
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: 1.1.9
54
+ version:
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ type: :development
58
+ version_requirement:
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: 1.4.0
64
+ version:
35
65
  - !ruby/object:Gem::Dependency
36
66
  name: rspec
37
67
  type: :development
@@ -43,7 +73,7 @@ dependencies:
43
73
  version: 1.2.9
44
74
  version:
45
75
  description: " RiakRest provides structured, RESTful interaction with\n the HTTP/JSON interface of a Riak[http://riak.basho.com] document data\n store. RiakRest provides two levels of interaction: Core Client and\n Resource. Core Client works at the Jiak level and exposes Jiak\n internals. JiakResource is an abstraction built on top of the Core Client\n that gives a true RESTful feel.\n"
46
- email: paul@dingosky.com
76
+ email: riak@dingosky.com
47
77
  executables: []
48
78
 
49
79
  extensions: []
@@ -62,10 +92,8 @@ files:
62
92
  - examples/auto_update_links.rb
63
93
  - examples/basic_client.rb
64
94
  - examples/basic_resource.rb
95
+ - examples/example_helper.rb
65
96
  - examples/linked_resources.rb
66
- - examples/links_only_pov.rb
67
- - examples/multiple_pov.rb
68
- - examples/ruby_json_data.rb
69
97
  - lib/riakrest.rb
70
98
  - lib/riakrest/core/exceptions.rb
71
99
  - lib/riakrest/core/jiak_bucket.rb
@@ -131,9 +159,5 @@ test_files:
131
159
  - examples/auto_update_links.rb
132
160
  - examples/basic_client.rb
133
161
  - examples/basic_resource.rb
134
- - examples/bucket_schemas.rb
162
+ - examples/example_helper.rb
135
163
  - examples/linked_resources.rb
136
- - examples/links_only_pov.rb
137
- - examples/multiple_pov.rb
138
- - examples/rest_interaction.rb
139
- - examples/ruby_json_data.rb
@@ -1,38 +0,0 @@
1
- require 'riakrest'
2
- include RiakRest
3
-
4
- DogData = JiakDataFields.create(:name,:age,:breeds)
5
- DogData.keygen { name.downcase }
6
-
7
- # client = JiakClient.new("http://localhost:8002/jiak")
8
- client = JiakClient.new("http://localhost:8002/jiak",
9
- :proxy=>"http://localhost:8888")
10
- bucket = JiakBucket.new("dogs", DogData)
11
- chili = JiakObject.new(:bucket => bucket,
12
- :data => DogData.new(:name => "Chili",
13
- :age => 6,
14
- :breeds => ["heeler","akita"]))
15
- client.set_schema(bucket)
16
- client.store(chili)
17
- chili = client.get(bucket,'chili')
18
-
19
- DogBreedsData = JiakDataFields.create(:name,:breeds)
20
- bucket.data_class = DogBreedsData
21
- client.set_schema(bucket)
22
- chili = client.get(bucket,'chili')
23
- chili.data.breeds = ["heeler","mutt"]
24
-
25
-
26
- DogAgeData = JiakDataFields.create(:name,:age)
27
- diego = JiakObject.new(:bucket => bucket,
28
- :data => DogAgeData.new(:name => "Diego",
29
- :age => 7))
30
- client.store(diego)
31
-
32
- addie = JiakObject.new(:bucket => bucket,
33
- :data => DogData.new(:name => "Adelaide",
34
- :age => 14,
35
- :breeds => ["heeler"]))
36
- client.store(addie)
37
-
38
- addie = client.get(bucket,'addie')
@@ -1,38 +0,0 @@
1
- require 'riakrest'
2
- include RiakRest
3
-
4
- # class with 10 fields
5
- class Fields
6
- include JiakResource
7
- server 'http://localhost:8002/jiak'
8
- jattr_accessor (0...10).map {|n| "f#{n}".to_sym}
9
- auto_manage
10
- end
11
-
12
- class Links
13
- include JiakResource
14
- server 'http://localhost:8002/jiak'
15
- auto_manage
16
- end
17
-
18
- # populate two Fields objects with (meaningless) stuff
19
- Fields.pov
20
- fields = ["fields1","fields2"]
21
- fields1,fields2 =
22
- fields.map {|o| Fields.new(Fields.schema.write_mask.inject({}) do |h,f|
23
- h[f]="#{o.upcase}-#{f.hash}"
24
- h
25
- end)}
26
-
27
- Links.pov
28
- links1 = Links.get(fields1.jiak.key)
29
- links1.link(fields2,'link')
30
-
31
- Fields.pov
32
- fields2.f1 = "new f1"
33
-
34
- linked = fields1.query(Fields,'link')[0]
35
- puts linked.f1 == fields2.f1 # => true
36
-
37
- fields1.delete
38
- fields2.delete