riakrest 0.0.1
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/History.txt +4 -0
- data/Manifest.txt +41 -0
- data/PostInstall.txt +2 -0
- data/README.rdoc +51 -0
- data/Rakefile +24 -0
- data/examples/auto_update_data.rb +50 -0
- data/examples/auto_update_links.rb +48 -0
- data/examples/basic_client.rb +33 -0
- data/examples/basic_resource.rb +34 -0
- data/examples/json_data_resource.rb +32 -0
- data/examples/linked_resource.rb +113 -0
- data/examples/multiple_resources.rb +43 -0
- data/lib/riakrest/core/exceptions.rb +73 -0
- data/lib/riakrest/core/jiak_bucket.rb +146 -0
- data/lib/riakrest/core/jiak_client.rb +316 -0
- data/lib/riakrest/core/jiak_data.rb +265 -0
- data/lib/riakrest/core/jiak_link.rb +131 -0
- data/lib/riakrest/core/jiak_object.rb +233 -0
- data/lib/riakrest/core/jiak_schema.rb +242 -0
- data/lib/riakrest/core/query_link.rb +156 -0
- data/lib/riakrest/data/jiak_data_hash.rb +182 -0
- data/lib/riakrest/resource/jiak_resource.rb +628 -0
- data/lib/riakrest/version.rb +7 -0
- data/lib/riakrest.rb +164 -0
- data/riakrest.gemspec +38 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/core/exceptions_spec.rb +18 -0
- data/spec/core/jiak_bucket_spec.rb +103 -0
- data/spec/core/jiak_client_spec.rb +358 -0
- data/spec/core/jiak_link_spec.rb +77 -0
- data/spec/core/jiak_object_spec.rb +210 -0
- data/spec/core/jiak_schema_spec.rb +184 -0
- data/spec/core/query_link_spec.rb +128 -0
- data/spec/data/jiak_data_hash_spec.rb +14 -0
- data/spec/resource/jiak_resource_spec.rb +128 -0
- data/spec/riakrest_spec.rb +17 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +12 -0
- data/tasks/rspec.rake +21 -0
- metadata +113 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "JiakSchema" do
|
4
|
+
before do
|
5
|
+
@allowed_fields = [:foo,:bar,:baz]
|
6
|
+
@required_fields = [:foo]
|
7
|
+
@read_mask = [:foo,:bar]
|
8
|
+
@write_mask = [:baz]
|
9
|
+
@hash = {
|
10
|
+
:allowed_fields => @allowed_fields,
|
11
|
+
:required_fields => @required_fields,
|
12
|
+
:read_mask => @read_mask,
|
13
|
+
:write_mask => @write_mask
|
14
|
+
}
|
15
|
+
@jiak_schema = JiakSchema.new(@hash)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should respond to" do
|
19
|
+
JiakSchema.should respond_to(:from_jiak)
|
20
|
+
|
21
|
+
@jiak_schema.should respond_to(:allowed_fields,:allowed_fields=)
|
22
|
+
@jiak_schema.should respond_to(:required_fields,:required_fields=)
|
23
|
+
@jiak_schema.should respond_to(:read_mask,:read_mask=)
|
24
|
+
@jiak_schema.should respond_to(:write_mask,:write_mask=)
|
25
|
+
|
26
|
+
@jiak_schema.should respond_to(:to_jiak)
|
27
|
+
@jiak_schema.should respond_to(:==,:eql?)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should create using defaults from allowed_fields" do
|
31
|
+
jiak_schema = JiakSchema.new({:allowed_fields => @allowed_fields})
|
32
|
+
jiak_schema.allowed_fields.should eql @allowed_fields
|
33
|
+
jiak_schema.required_fields.should eql []
|
34
|
+
jiak_schema.read_mask.should eql @allowed_fields
|
35
|
+
jiak_schema.write_mask.should eql @allowed_fields
|
36
|
+
|
37
|
+
jiak_schema = JiakSchema.new(@allowed_fields)
|
38
|
+
jiak_schema.allowed_fields.should eql @allowed_fields
|
39
|
+
jiak_schema.required_fields.should eql []
|
40
|
+
jiak_schema.read_mask.should eql @allowed_fields
|
41
|
+
jiak_schema.write_mask.should eql @allowed_fields
|
42
|
+
|
43
|
+
jiak_schema = JiakSchema.new({:allowed_fields => []})
|
44
|
+
jiak_schema.allowed_fields.should eql []
|
45
|
+
jiak_schema.required_fields.should eql []
|
46
|
+
jiak_schema.read_mask.should eql []
|
47
|
+
jiak_schema.write_mask.should eql []
|
48
|
+
|
49
|
+
jiak_schema = JiakSchema.new([])
|
50
|
+
jiak_schema.allowed_fields.should eql []
|
51
|
+
jiak_schema.required_fields.should eql []
|
52
|
+
jiak_schema.read_mask.should eql []
|
53
|
+
jiak_schema.write_mask.should eql []
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should create using specified fields and masks" do
|
57
|
+
@jiak_schema.allowed_fields.should eql @allowed_fields
|
58
|
+
@jiak_schema.required_fields.should eql @required_fields
|
59
|
+
@jiak_schema.read_mask.should eql @read_mask
|
60
|
+
@jiak_schema.write_mask.should eql @write_mask
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should create from a Hash" do
|
64
|
+
jiak_schema = JiakSchema.new(@hash)
|
65
|
+
jiak_schema.allowed_fields.should eql @allowed_fields
|
66
|
+
jiak_schema.required_fields.should eql @required_fields
|
67
|
+
jiak_schema.read_mask.should eql @read_mask
|
68
|
+
jiak_schema.write_mask.should eql @write_mask
|
69
|
+
|
70
|
+
hash = {:schema => @hash}
|
71
|
+
jiak_schema = JiakSchema.new(hash)
|
72
|
+
jiak_schema.should eql @jiak_schema
|
73
|
+
jiak_schema.should == @jiak_schema
|
74
|
+
|
75
|
+
@hash['allowed_fields'] = @hash[:allowed_fields]
|
76
|
+
@hash.delete(:allowed_fields)
|
77
|
+
@hash['read_mask'] = @hash[:read_mask]
|
78
|
+
@hash.delete(:read_mask)
|
79
|
+
jiak_schema = JiakSchema.new(@hash)
|
80
|
+
jiak_schema.allowed_fields.should eql @allowed_fields
|
81
|
+
jiak_schema.required_fields.should eql @required_fields
|
82
|
+
jiak_schema.read_mask.should eql @read_mask
|
83
|
+
jiak_schema.write_mask.should eql @write_mask
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should create from json" do
|
87
|
+
schema = JiakSchema.from_jiak(JSON.parse(@hash.to_json))
|
88
|
+
@allowed_fields.same_fields?(schema.allowed_fields).should be true
|
89
|
+
@required_fields.same_fields?(schema.required_fields).should be true
|
90
|
+
@write_mask.same_fields?(schema.write_mask).should be true
|
91
|
+
@read_mask.same_fields?(schema.read_mask).should be true
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should validate create options" do
|
95
|
+
hash = @hash.clone
|
96
|
+
hash.delete(:allowed_fields)
|
97
|
+
bad = lambda {JiakSchema.new(hash)}
|
98
|
+
bad.should raise_error(JiakSchemaException,/allowed_fields.*array/)
|
99
|
+
|
100
|
+
hash = @hash.clone
|
101
|
+
hash[:allowed_fields] = nil
|
102
|
+
bad = lambda {JiakSchema.new(hash)}
|
103
|
+
bad.should raise_error(JiakSchemaException,/allowed_fields.*array/)
|
104
|
+
|
105
|
+
hash[:allowed_fields] = 'a'
|
106
|
+
bad = lambda {JiakSchema.new(hash)}
|
107
|
+
bad.should raise_error(JiakSchemaException,/allowed_fields.*array/)
|
108
|
+
|
109
|
+
hash = @hash.clone
|
110
|
+
hash[:required_fields] = {}
|
111
|
+
bad = lambda {JiakSchema.new(hash)}
|
112
|
+
bad.should raise_error(JiakSchemaException,/required_fields.*array/)
|
113
|
+
|
114
|
+
hash = @hash.clone
|
115
|
+
hash[:read_mask] = [1]
|
116
|
+
bad = lambda {JiakSchema.new(hash)}
|
117
|
+
bad.should raise_error(JiakSchemaException,/read_mask.*strings/)
|
118
|
+
|
119
|
+
hash = @hash.clone
|
120
|
+
hash[:write_mask] = ['a','b',3]
|
121
|
+
bad = lambda {JiakSchema.new(hash)}
|
122
|
+
bad.should raise_error(JiakSchemaException,/write_mask.*strings/)
|
123
|
+
|
124
|
+
hash = @hash.clone
|
125
|
+
hash[:allowed_fields] << @allowed_fields[0].to_s
|
126
|
+
bad = lambda {JiakSchema.new(hash)}
|
127
|
+
bad.should raise_error(JiakSchemaException,/unique/)
|
128
|
+
|
129
|
+
hash = @hash.clone
|
130
|
+
hash[:allowed_fields] << @allowed_fields[0].to_sym
|
131
|
+
bad = lambda {JiakSchema.new(hash)}
|
132
|
+
bad.should raise_error(JiakSchemaException,/unique/)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should update with validation" do
|
136
|
+
arr = [:f1,'f2']
|
137
|
+
@jiak_schema.allowed_fields = arr
|
138
|
+
@jiak_schema.allowed_fields.should eql arr
|
139
|
+
@jiak_schema.required_fields = arr
|
140
|
+
@jiak_schema.required_fields.should eql arr
|
141
|
+
@jiak_schema.read_mask = arr
|
142
|
+
@jiak_schema.read_mask.should eql arr
|
143
|
+
@jiak_schema.write_mask = arr
|
144
|
+
@jiak_schema.write_mask.should eql arr
|
145
|
+
|
146
|
+
bad = lambda {@jiak_schema.allowed_fields = nil}
|
147
|
+
bad.should raise_error(JiakSchemaException,/allowed_fields.*array/)
|
148
|
+
|
149
|
+
bad = lambda {@jiak_schema.required_fields = 'a'}
|
150
|
+
bad.should raise_error(JiakSchemaException,/required_fields.*array/)
|
151
|
+
|
152
|
+
bad = lambda {@jiak_schema.read_mask = [:f,1]}
|
153
|
+
bad.should raise_error(JiakSchemaException,/read_mask.*symbol/)
|
154
|
+
|
155
|
+
arr << :f1
|
156
|
+
bad = lambda {@jiak_schema.write_mask = arr}
|
157
|
+
bad.should raise_error(JiakSchemaException,/unique/)
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should convert to json" do
|
161
|
+
@jiak_schema.to_jiak.should eql ({:schema => @hash}.to_json)
|
162
|
+
end
|
163
|
+
|
164
|
+
it "should equal an equal JiakSchema" do
|
165
|
+
jiak_schema = JiakSchema.new(@hash)
|
166
|
+
jiak_schema.should eql @jiak_schema
|
167
|
+
|
168
|
+
strings = JiakSchema.new(['a','bb','CcC'])
|
169
|
+
symbols = JiakSchema.new([:a,:bb,:CcC])
|
170
|
+
strings.should eql symbols
|
171
|
+
symbols.should eql strings
|
172
|
+
|
173
|
+
strings = JiakSchema.new(['a','bb','CcC','d'])
|
174
|
+
symbols = JiakSchema.new([:a,:bb,:CcC])
|
175
|
+
strings.should_not eql symbols
|
176
|
+
symbols.should_not eql strings
|
177
|
+
|
178
|
+
strings = JiakSchema.new(['a','bb','CC'])
|
179
|
+
symbols = JiakSchema.new([:a,:bb,:CcC])
|
180
|
+
strings.should_not eql symbols
|
181
|
+
symbols.should_not eql strings
|
182
|
+
end
|
183
|
+
|
184
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "QueryLink" do
|
4
|
+
before do
|
5
|
+
@bucket = 'b'
|
6
|
+
@tag = 't'
|
7
|
+
@acc = 'a'
|
8
|
+
@any = QueryLink::ANY
|
9
|
+
@query_link = QueryLink.new(@bucket,@tag,@acc)
|
10
|
+
@array = [@bucket,@tag,@acc]
|
11
|
+
@query_link_any = QueryLink.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should respond to" do
|
15
|
+
@query_link.should respond_to(:bucket,:tag,:acc)
|
16
|
+
@query_link.should respond_to(:bucket=,:tag=,:acc=)
|
17
|
+
|
18
|
+
@query_link.should respond_to(:for_uri)
|
19
|
+
|
20
|
+
@query_link.should respond_to(:eql?,:==)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should init from specified values" do
|
24
|
+
@query_link.bucket.should eql @bucket
|
25
|
+
@query_link.tag.should eql @tag
|
26
|
+
@query_link.acc.should eql @acc
|
27
|
+
|
28
|
+
query_link = QueryLink.new([@bucket,@tag,@acc])
|
29
|
+
query_link.bucket.should eql @bucket
|
30
|
+
query_link.tag.should eql @tag
|
31
|
+
query_link.acc.should eql @acc
|
32
|
+
|
33
|
+
query_link = QueryLink.new(@query_link)
|
34
|
+
query_link.bucket.should eql @bucket
|
35
|
+
query_link.tag.should eql @tag
|
36
|
+
query_link.acc.should eql @acc
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should fill in missing args with ANY" do
|
40
|
+
query_link = QueryLink.new(@bucket,@tag)
|
41
|
+
query_link.bucket.should eql @bucket
|
42
|
+
query_link.tag.should eql @tag
|
43
|
+
query_link.acc.should eql @any
|
44
|
+
|
45
|
+
query_link = QueryLink.new(@bucket)
|
46
|
+
query_link.bucket.should eql @bucket
|
47
|
+
query_link.tag.should eql @any
|
48
|
+
query_link.acc.should eql @any
|
49
|
+
|
50
|
+
query_link = QueryLink.new
|
51
|
+
query_link.bucket.should eql @any
|
52
|
+
query_link.tag.should eql @any
|
53
|
+
query_link.acc.should eql @any
|
54
|
+
|
55
|
+
query_link = QueryLink.new([@bucket,@tag])
|
56
|
+
query_link.bucket.should eql @bucket
|
57
|
+
query_link.tag.should eql @tag
|
58
|
+
query_link.acc.should eql @any
|
59
|
+
|
60
|
+
query_link = QueryLink.new([@bucket])
|
61
|
+
query_link.bucket.should eql @bucket
|
62
|
+
query_link.tag.should eql @any
|
63
|
+
query_link.acc.should eql @any
|
64
|
+
|
65
|
+
query_link = QueryLink.new []
|
66
|
+
query_link.bucket.should eql @any
|
67
|
+
query_link.tag.should eql @any
|
68
|
+
query_link.acc.should eql @any
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should ignore leading/trailing spaces for opts on init" do
|
72
|
+
bucket = " "+@bucket+" "
|
73
|
+
tag = " "+@tag+" "
|
74
|
+
acc = " "+@acc+" "
|
75
|
+
query_link = QueryLink.new([bucket,tag,acc])
|
76
|
+
query_link.bucket.should eql @bucket
|
77
|
+
query_link.tag.should eql @tag
|
78
|
+
query_link.acc.should eql @acc
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should treat blank, empty strings, or nil as ANY on init" do
|
82
|
+
jiak_any_link = QueryLink.new
|
83
|
+
|
84
|
+
[""," ",nil].each do |val|
|
85
|
+
query_link = QueryLink.new([val,val,val])
|
86
|
+
query_link.should eql jiak_any_link
|
87
|
+
query_link.should == jiak_any_link
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should init from an array" do
|
92
|
+
query_link = QueryLink.new(@array)
|
93
|
+
query_link.bucket.should eql @bucket
|
94
|
+
query_link.tag.should eql @tag
|
95
|
+
query_link.acc.should eql @acc
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should allow field updates" do
|
99
|
+
@query_link.bucket = 'new_bucket'
|
100
|
+
@query_link.bucket.should eql 'new_bucket'
|
101
|
+
@query_link.tag = 'new_tag'
|
102
|
+
@query_link.tag.should eql 'new_tag'
|
103
|
+
@query_link.acc = 'new_acc'
|
104
|
+
@query_link.acc.should eql 'new_acc'
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should convert to a suitable URI string" do
|
108
|
+
@query_link.for_uri.should eql @bucket+','+@tag+','+@acc
|
109
|
+
|
110
|
+
b = 's p a c e'
|
111
|
+
t = '<%>'
|
112
|
+
a = '\\'
|
113
|
+
query_link = QueryLink.new([b,t,a])
|
114
|
+
query_link.for_uri.should eql URI.encode([b,t,a].join(','))
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should compare to another QueryLink via eql?" do
|
118
|
+
query_link_1 = QueryLink.new(['a','b','c'])
|
119
|
+
query_link_2 = QueryLink.new(['a','b','c'])
|
120
|
+
query_link_3 = QueryLink.new(['a','','c'])
|
121
|
+
|
122
|
+
query_link_1.should eql query_link_2
|
123
|
+
query_link_1.should_not eql query_link_3
|
124
|
+
|
125
|
+
query_link_1.should == query_link_2
|
126
|
+
query_link_1.should_not == query_link_3
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "JiakDataHash" do
|
4
|
+
Person = JiakDataHash.create(:name, :age)
|
5
|
+
|
6
|
+
before do
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should create a fully usable JiakData class" do
|
10
|
+
Person.schema.should respond_to(:allowed_fields,:required_fields,
|
11
|
+
:read_mask,:write_mask)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "JiakResource" do
|
4
|
+
F1F2 = JiakDataHash.create(:f1,:f2)
|
5
|
+
class Rsrc
|
6
|
+
include JiakResource
|
7
|
+
server 'http://localhost:8002/jiak'
|
8
|
+
group 'group'
|
9
|
+
data_class F1F2
|
10
|
+
end
|
11
|
+
|
12
|
+
before do
|
13
|
+
@server = 'http://localhost:8002/jiak'
|
14
|
+
@group = 'group'
|
15
|
+
@data_class = F1F2
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "class" do
|
19
|
+
it "should respond to" do
|
20
|
+
Rsrc.should respond_to(:server,:group,:data_class)
|
21
|
+
Rsrc.should respond_to(:params,:auto_update,:schema,:keys)
|
22
|
+
Rsrc.should respond_to(:allowed,:required,:readable,:writable,:readwrite)
|
23
|
+
Rsrc.should respond_to(:point_of_view,:pov,:point_of_view?,:pov?)
|
24
|
+
Rsrc.should respond_to(:post,:put,:get,:delete)
|
25
|
+
Rsrc.should respond_to(:refresh,:update)
|
26
|
+
Rsrc.should respond_to(:link,:bi_link,:walk)
|
27
|
+
Rsrc.should respond_to(:new,:copy)
|
28
|
+
Rsrc.should respond_to(:auto_post,:auto_update,:auto_post?,:auto_update?)
|
29
|
+
|
30
|
+
Rsrc.jiak.should respond_to(:server,:uri,:group,:data,:bucket,:auto_update)
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
it "shoud have settings from creation" do
|
36
|
+
Rsrc.params.should be_empty
|
37
|
+
Rsrc.auto_update?.should be false
|
38
|
+
Rsrc.schema.should eql F1F2.schema
|
39
|
+
|
40
|
+
Rsrc.jiak.should be_a Struct
|
41
|
+
Rsrc.jiak.server.should be_a JiakClient
|
42
|
+
Rsrc.jiak.uri.should eql @server
|
43
|
+
Rsrc.jiak.group.should eql @group
|
44
|
+
Rsrc.jiak.data.should include JiakData
|
45
|
+
Rsrc.jiak.data.should == F1F2
|
46
|
+
Rsrc.jiak.bucket.should be_a JiakBucket
|
47
|
+
Rsrc.jiak.bucket.name.should eql @group
|
48
|
+
Rsrc.jiak.bucket.data_class.should == F1F2
|
49
|
+
Rsrc.jiak.auto_update.should be false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "instance" do
|
54
|
+
before do
|
55
|
+
@rsrc = Rsrc.new
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should respond to" do
|
59
|
+
@rsrc.should respond_to(:jiak,:jiak=)
|
60
|
+
@rsrc.should respond_to(:auto_update=,:auto_update?)
|
61
|
+
@rsrc.should respond_to(:post,:put,:update,:refresh,:delete)
|
62
|
+
@rsrc.should respond_to(:link,:bi_link,:walk)
|
63
|
+
@rsrc.should respond_to(:eql?,:==)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should have default settings" do
|
67
|
+
@rsrc.jiak.should be_a Struct
|
68
|
+
@rsrc.jiak.should respond_to(:obj,:auto_update)
|
69
|
+
|
70
|
+
@rsrc.jiak.obj.should be_a JiakObject
|
71
|
+
@rsrc.jiak.obj.bucket.should be_a JiakBucket
|
72
|
+
@rsrc.jiak.obj.bucket.name.should eql @group
|
73
|
+
@rsrc.jiak.obj.bucket.data_class.should == F1F2
|
74
|
+
|
75
|
+
@rsrc.jiak.auto_update.should be_nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "JiakResource default class-level auto-post" do
|
81
|
+
PersonData = JiakDataHash.create(:name,:age)
|
82
|
+
PersonData.keygen :name
|
83
|
+
class Person
|
84
|
+
include JiakResource
|
85
|
+
server 'http://localhost:8002/jiak'
|
86
|
+
group 'people'
|
87
|
+
data_class PersonData
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should create instance without posting" do
|
91
|
+
Person.auto_post?.should be false
|
92
|
+
|
93
|
+
name = 'p'
|
94
|
+
p = Person.new(:name => name, :age => 10)
|
95
|
+
|
96
|
+
no_rsrc = lambda {Person.get(name)}
|
97
|
+
no_rsrc.should raise_error(JiakResourceNotFound)
|
98
|
+
|
99
|
+
p.post
|
100
|
+
Person.get(name).name.should eql p.name
|
101
|
+
|
102
|
+
p.delete
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe "JiakResource class-level auto-post true" do
|
107
|
+
PersonData = JiakDataHash.create(:name,:age)
|
108
|
+
PersonData.keygen :name
|
109
|
+
class Person
|
110
|
+
include JiakResource
|
111
|
+
server 'http://localhost:8002/jiak'
|
112
|
+
group 'people'
|
113
|
+
data_class PersonData
|
114
|
+
auto_post true
|
115
|
+
end
|
116
|
+
|
117
|
+
it "should auto-post a new instance" do
|
118
|
+
Person.auto_post?.should be true
|
119
|
+
|
120
|
+
name = 'P'
|
121
|
+
p = Person.new(:name => name, :age => 10)
|
122
|
+
Person.get(name).name.should eql name
|
123
|
+
p.delete
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
# CxINC Many, many more tests to go
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
# desc "Run the specs under spec/models"
|
18
|
+
# Spec::Rake::SpecTask.new do |t|
|
19
|
+
# t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
# t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: riakrest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Rogers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-29 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: |-
|
26
|
+
RiakRest provides structured, RESTful interaction with a Riak document
|
27
|
+
store. In Riak parlance, this JSON data exchange is called Jiak. RiakRest
|
28
|
+
provides two levels of interaction: Core Client and Resource. Core Client
|
29
|
+
interaction works down at the Jiak level and exposes Jiak internals. Resource
|
30
|
+
interaction is an abstraction built on top of the Core Client.
|
31
|
+
email:
|
32
|
+
- paul@dingosky.com
|
33
|
+
executables: []
|
34
|
+
|
35
|
+
extensions: []
|
36
|
+
|
37
|
+
extra_rdoc_files:
|
38
|
+
- History.txt
|
39
|
+
- Manifest.txt
|
40
|
+
- PostInstall.txt
|
41
|
+
files:
|
42
|
+
- History.txt
|
43
|
+
- Manifest.txt
|
44
|
+
- PostInstall.txt
|
45
|
+
- README.rdoc
|
46
|
+
- Rakefile
|
47
|
+
- examples/auto_update_data.rb
|
48
|
+
- examples/auto_update_links.rb
|
49
|
+
- examples/basic_client.rb
|
50
|
+
- examples/basic_resource.rb
|
51
|
+
- examples/json_data_resource.rb
|
52
|
+
- examples/linked_resource.rb
|
53
|
+
- examples/multiple_resources.rb
|
54
|
+
- lib/riakrest.rb
|
55
|
+
- lib/riakrest/core/exceptions.rb
|
56
|
+
- lib/riakrest/core/jiak_bucket.rb
|
57
|
+
- lib/riakrest/core/jiak_client.rb
|
58
|
+
- lib/riakrest/core/jiak_data.rb
|
59
|
+
- lib/riakrest/core/jiak_link.rb
|
60
|
+
- lib/riakrest/core/jiak_object.rb
|
61
|
+
- lib/riakrest/core/jiak_schema.rb
|
62
|
+
- lib/riakrest/core/query_link.rb
|
63
|
+
- lib/riakrest/data/jiak_data_hash.rb
|
64
|
+
- lib/riakrest/resource/jiak_resource.rb
|
65
|
+
- lib/riakrest/version.rb
|
66
|
+
- riakrest.gemspec
|
67
|
+
- script/console
|
68
|
+
- script/destroy
|
69
|
+
- script/generate
|
70
|
+
- spec/core/exceptions_spec.rb
|
71
|
+
- spec/core/jiak_bucket_spec.rb
|
72
|
+
- spec/core/jiak_client_spec.rb
|
73
|
+
- spec/core/jiak_link_spec.rb
|
74
|
+
- spec/core/jiak_object_spec.rb
|
75
|
+
- spec/core/jiak_schema_spec.rb
|
76
|
+
- spec/core/query_link_spec.rb
|
77
|
+
- spec/data/jiak_data_hash_spec.rb
|
78
|
+
- spec/resource/jiak_resource_spec.rb
|
79
|
+
- spec/riakrest_spec.rb
|
80
|
+
- spec/spec.opts
|
81
|
+
- spec/spec_helper.rb
|
82
|
+
- tasks/rspec.rake
|
83
|
+
has_rdoc: true
|
84
|
+
homepage: http://github.com/wcpr/riakrest
|
85
|
+
licenses: []
|
86
|
+
|
87
|
+
post_install_message: PostInstall.txt
|
88
|
+
rdoc_options:
|
89
|
+
- --main
|
90
|
+
- README.rdoc
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project: riakrest
|
108
|
+
rubygems_version: 1.3.5
|
109
|
+
signing_key:
|
110
|
+
specification_version: 3
|
111
|
+
summary: RiakRest provides structured, RESTful interaction with a Riak document store
|
112
|
+
test_files: []
|
113
|
+
|