riakpb 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +23 -23
- data/Rakefile +3 -3
- data/lib/riak/bucket.rb +23 -23
- data/lib/riak/client/rpc.rb +14 -12
- data/lib/riak/client.rb +59 -73
- data/lib/riak/client_pb.rb +1 -1
- data/lib/riak/{riak_content.rb → content.rb} +125 -70
- data/lib/riak/failed_exchange.rb +2 -2
- data/lib/riak/failed_request.rb +3 -3
- data/lib/riak/key.rb +38 -38
- data/lib/riak/locale/en.yml +3 -3
- data/lib/riak/map_reduce.rb +6 -6
- data/lib/riak/sibling_error.rb +3 -3
- data/lib/riak/util/decode.rb +1 -1
- data/lib/riak/util/encode.rb +2 -2
- data/lib/riak/util/message_code.rb +9 -9
- data/lib/riak/util/translation.rb +1 -1
- data/lib/riak.rb +3 -3
- data/load_stocks.rb +1 -1
- data/spec/riak/bucket_spec.rb +22 -22
- data/spec/riak/client_spec.rb +31 -31
- data/spec/riak/{riak_content_spec.rb → content_spec.rb} +17 -18
- data/spec/riak/key_spec.rb +16 -16
- data/spec/riak/map_reduce_spec.rb +30 -30
- data/spec/riak/rpc_spec.rb +2 -2
- metadata +9 -10
- data/riakpb.gemspec +0 -37
@@ -1,15 +1,15 @@
|
|
1
1
|
require File.expand_path("../spec_helper", File.dirname(__FILE__))
|
2
2
|
|
3
|
-
describe
|
3
|
+
describe Riakpb::MapReduce do
|
4
4
|
before :each do
|
5
|
-
@client =
|
5
|
+
@client = Riakpb::Client.new
|
6
6
|
@client.rpc.stub!(:request).and_return(nil)
|
7
|
-
@mr =
|
7
|
+
@mr = Riakpb::MapReduce.new(@client)
|
8
8
|
end
|
9
9
|
|
10
10
|
it "should require a client" do
|
11
|
-
lambda {
|
12
|
-
lambda {
|
11
|
+
lambda { Riakpb::MapReduce.new }.should raise_error
|
12
|
+
lambda { Riakpb::MapReduce.new(@client) }.should_not raise_error
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should initialize the inputs and query to empty arrays" do
|
@@ -19,7 +19,7 @@ describe Riak::MapReduce do
|
|
19
19
|
|
20
20
|
it "should yield itself when given a block on initializing" do
|
21
21
|
@mr2 = nil
|
22
|
-
@mr =
|
22
|
+
@mr = Riakpb::MapReduce.new(@client) do |mr|
|
23
23
|
@mr2 = mr
|
24
24
|
end
|
25
25
|
@mr2.should == @mr
|
@@ -41,8 +41,8 @@ describe Riak::MapReduce do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
it "should add an object to the inputs by its bucket and key" do
|
44
|
-
bucket =
|
45
|
-
key =
|
44
|
+
bucket = Riakpb::Bucket.new(@client, "foo")
|
45
|
+
key = Riakpb::Key.new(bucket, "bar")
|
46
46
|
@mr.add(key)
|
47
47
|
@mr.inputs.should == [["foo", "bar"]]
|
48
48
|
end
|
@@ -53,7 +53,7 @@ describe Riak::MapReduce do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should use a bucket name as the single input" do
|
56
|
-
@mr.add(
|
56
|
+
@mr.add(Riakpb::Bucket.new(@client, "foo"))
|
57
57
|
@mr.inputs.should == "foo"
|
58
58
|
@mr.add("docs")
|
59
59
|
@mr.inputs.should == "docs"
|
@@ -114,7 +114,7 @@ describe Riak::MapReduce do
|
|
114
114
|
@mr.query.should have(1).items
|
115
115
|
phase = @mr.query.first
|
116
116
|
phase.type.should == :link
|
117
|
-
# phase.function.should be_kind_of(
|
117
|
+
# phase.function.should be_kind_of(Riakpb::WalkSpec)
|
118
118
|
phase.function[:tag].should == "next"
|
119
119
|
end
|
120
120
|
|
@@ -123,7 +123,7 @@ describe Riak::MapReduce do
|
|
123
123
|
@mr.query.should have(1).items
|
124
124
|
phase = @mr.query.first
|
125
125
|
phase.type.should == :link
|
126
|
-
# phase.function.should be_kind_of(
|
126
|
+
# phase.function.should be_kind_of(Riakpb::WalkSpec)
|
127
127
|
phase.function[:bucket].should == "foo"
|
128
128
|
phase.keep.should be_true
|
129
129
|
end
|
@@ -135,7 +135,7 @@ describe Riak::MapReduce do
|
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should map phases to their JSON equivalents" do
|
138
|
-
phase =
|
138
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => "function(){}")
|
139
139
|
@mr.query << phase
|
140
140
|
@mr.to_json.should include('"source":"function(){}"')
|
141
141
|
@mr.to_json.should include('"query":[{"map":{')
|
@@ -175,11 +175,11 @@ describe Riak::MapReduce do
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should interpret failed requests with JSON content-types as map reduce errors" do
|
178
|
-
@http.stub!(:post).and_raise(
|
179
|
-
lambda { @mr.run }.should raise_error(
|
178
|
+
@http.stub!(:post).and_raise(Riakpb::FailedRequest.new(:post, 200, 500, {"content-type" => ["application/json"]}, '{"error":"syntax error"}'))
|
179
|
+
lambda { @mr.run }.should raise_error(Riakpb::MapReduceError)
|
180
180
|
begin
|
181
181
|
@mr.run
|
182
|
-
rescue
|
182
|
+
rescue Riakpb::MapReduceError => mre
|
183
183
|
mre.message.should == '{"error":"syntax error"}'
|
184
184
|
else
|
185
185
|
fail "No exception raised!"
|
@@ -187,66 +187,66 @@ describe Riak::MapReduce do
|
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should re-raise non-JSON error responses" do
|
190
|
-
@http.stub!(:post).and_raise(
|
191
|
-
lambda { @mr.run }.should raise_error(
|
190
|
+
@http.stub!(:post).and_raise(Riakpb::FailedRequest.new(:post, 200, 500, {"content-type" => ["text/plain"]}, 'Oops, you bwoke it.'))
|
191
|
+
lambda { @mr.run }.should raise_error(Riakpb::FailedRequest)
|
192
192
|
end
|
193
193
|
end
|
194
194
|
=end
|
195
195
|
end
|
196
196
|
|
197
|
-
describe
|
197
|
+
describe Riakpb::MapReduce::Phase do
|
198
198
|
before :each do
|
199
199
|
@fun = "function(v,_,_){ return v['values'][0]['data']; }"
|
200
200
|
end
|
201
201
|
|
202
202
|
it "should initialize with a type and a function" do
|
203
|
-
phase =
|
203
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => @fun, :language => "javascript")
|
204
204
|
phase.type.should == :map
|
205
205
|
phase.function.should == @fun
|
206
206
|
phase.language.should == "javascript"
|
207
207
|
end
|
208
208
|
|
209
209
|
it "should initialize with a type and an MF" do
|
210
|
-
phase =
|
210
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => ["module", "function"], :language => "erlang")
|
211
211
|
phase.type.should == :map
|
212
212
|
phase.function.should == ["module", "function"]
|
213
213
|
phase.language.should == "erlang"
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should initialize with a type and a bucket/key" do
|
217
|
-
phase =
|
217
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => {:bucket => "funs", :key => "awesome_map"}, :language => "javascript")
|
218
218
|
phase.type.should == :map
|
219
219
|
phase.function.should == {:bucket => "funs", :key => "awesome_map"}
|
220
220
|
phase.language.should == "javascript"
|
221
221
|
end
|
222
222
|
|
223
223
|
it "should assume the language is erlang when the function is an array" do
|
224
|
-
phase =
|
224
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => ["module", "function"])
|
225
225
|
phase.language.should == "erlang"
|
226
226
|
end
|
227
227
|
|
228
228
|
it "should assume the language is javascript when the function is a string" do
|
229
|
-
phase =
|
229
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => @fun)
|
230
230
|
phase.language.should == "javascript"
|
231
231
|
end
|
232
232
|
|
233
233
|
it "should assume the language is javascript when the function is a hash" do
|
234
|
-
phase =
|
234
|
+
phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => {:bucket => "jobs", :key => "awesome_map"})
|
235
235
|
phase.language.should == "javascript"
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should accept a WalkSpec for the function when a link phase" do
|
239
|
-
# phase =
|
240
|
-
# phase.function.should be_kind_of(
|
239
|
+
# phase = Riakpb::MapReduce::Phase.new(:type => :link, :function => Riakpb::WalkSpec.new({}))
|
240
|
+
# phase.function.should be_kind_of(Riakpb::WalkSpec)
|
241
241
|
end
|
242
242
|
|
243
243
|
it "should raise an error if a WalkSpec is given for a phase type other than :link" do
|
244
|
-
# lambda {
|
244
|
+
# lambda { Riakpb::MapReduce::Phase.new(:type => :map, :function => Riakpb::WalkSpec.new({})) }.should raise_error(ArgumentError)
|
245
245
|
end
|
246
246
|
|
247
247
|
describe "converting to JSON for the job" do
|
248
248
|
before :each do
|
249
|
-
@phase =
|
249
|
+
@phase = Riakpb::MapReduce::Phase.new(:type => :map, :function => "")
|
250
250
|
end
|
251
251
|
|
252
252
|
[:map, :reduce].each do |type|
|
@@ -276,8 +276,8 @@ describe Riak::MapReduce::Phase do
|
|
276
276
|
end
|
277
277
|
|
278
278
|
it "should include the function name when the function is not a lambda" do
|
279
|
-
@phase.function = "
|
280
|
-
@phase.to_json.should include('"name":"
|
279
|
+
@phase.function = "Riakpb.mapValues"
|
280
|
+
@phase.to_json.should include('"name":"Riakpb.mapValues"')
|
281
281
|
@phase.to_json.should_not include('"source"')
|
282
282
|
end
|
283
283
|
|
data/spec/riak/rpc_spec.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Scott Gonyea
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-07-
|
17
|
+
date: 2010-07-09 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -61,7 +61,7 @@ dependencies:
|
|
61
61
|
version: 0.4.4
|
62
62
|
type: :runtime
|
63
63
|
version_requirements: *id003
|
64
|
-
description: riakpb is a protocol buffer client for
|
64
|
+
description: riakpb is a protocol buffer client for Riakpb--the distributed database by Basho.
|
65
65
|
email: me@inherentlylame.com
|
66
66
|
executables: []
|
67
67
|
|
@@ -76,13 +76,13 @@ files:
|
|
76
76
|
- lib/riak/client/rpc.rb
|
77
77
|
- lib/riak/client.rb
|
78
78
|
- lib/riak/client_pb.rb
|
79
|
+
- lib/riak/content.rb
|
79
80
|
- lib/riak/failed_exchange.rb
|
80
81
|
- lib/riak/failed_request.rb
|
81
82
|
- lib/riak/i18n.rb
|
82
83
|
- lib/riak/key.rb
|
83
84
|
- lib/riak/locale/en.yml
|
84
85
|
- lib/riak/map_reduce.rb
|
85
|
-
- lib/riak/riak_content.rb
|
86
86
|
- lib/riak/sibling_error.rb
|
87
87
|
- lib/riak/util/decode.rb
|
88
88
|
- lib/riak/util/encode.rb
|
@@ -93,15 +93,14 @@ files:
|
|
93
93
|
- Manifest.txt
|
94
94
|
- Rakefile
|
95
95
|
- README.rdoc
|
96
|
-
- riakpb.gemspec
|
97
96
|
- script/console
|
98
97
|
- script/destroy
|
99
98
|
- script/generate
|
100
99
|
- spec/riak/bucket_spec.rb
|
101
100
|
- spec/riak/client_spec.rb
|
101
|
+
- spec/riak/content_spec.rb
|
102
102
|
- spec/riak/key_spec.rb
|
103
103
|
- spec/riak/map_reduce_spec.rb
|
104
|
-
- spec/riak/riak_content_spec.rb
|
105
104
|
- spec/riak/rpc_spec.rb
|
106
105
|
- spec/spec_helper.rb
|
107
106
|
has_rdoc: true
|
@@ -133,12 +132,12 @@ rubyforge_project:
|
|
133
132
|
rubygems_version: 1.3.6
|
134
133
|
signing_key:
|
135
134
|
specification_version: 3
|
136
|
-
summary: riakpb is a protocol buffer client for
|
135
|
+
summary: riakpb is a protocol buffer client for Riakpb--the distributed database by Basho.
|
137
136
|
test_files:
|
138
137
|
- spec/riak/bucket_spec.rb
|
139
138
|
- spec/riak/client_spec.rb
|
139
|
+
- spec/riak/content_spec.rb
|
140
140
|
- spec/riak/key_spec.rb
|
141
141
|
- spec/riak/map_reduce_spec.rb
|
142
|
-
- spec/riak/riak_content_spec.rb
|
143
142
|
- spec/riak/rpc_spec.rb
|
144
143
|
- spec/spec_helper.rb
|
data/riakpb.gemspec
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
|
-
Gem::Specification.new do |s|
|
4
|
-
s.name = %q{riakpb}
|
5
|
-
s.version = "0.1.6"
|
6
|
-
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = ["Scott Gonyea"]
|
9
|
-
s.date = %q{2010-07-08}
|
10
|
-
s.description = %q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
11
|
-
s.email = %q{me@inherentlylame.com}
|
12
|
-
s.files = ["goog.csv", "History.txt", "lib/riak/bucket.rb", "lib/riak/client/rpc.rb", "lib/riak/client.rb", "lib/riak/client_pb.rb", "lib/riak/failed_exchange.rb", "lib/riak/failed_request.rb", "lib/riak/i18n.rb", "lib/riak/key.rb", "lib/riak/locale/en.yml", "lib/riak/map_reduce.rb", "lib/riak/riak_content.rb", "lib/riak/sibling_error.rb", "lib/riak/util/decode.rb", "lib/riak/util/encode.rb", "lib/riak/util/message_code.rb", "lib/riak/util/translation.rb", "lib/riak.rb", "load_stocks.rb", "Manifest.txt", "Rakefile", "README.rdoc", "riakpb.gemspec", "script/console", "script/destroy", "script/generate", "spec/riak/bucket_spec.rb", "spec/riak/client_spec.rb", "spec/riak/key_spec.rb", "spec/riak/map_reduce_spec.rb", "spec/riak/riak_content_spec.rb", "spec/riak/rpc_spec.rb", "spec/spec_helper.rb"]
|
13
|
-
s.homepage = %q{http://github.com/aitrus/riak-pbclient}
|
14
|
-
s.require_paths = ["lib"]
|
15
|
-
s.rubygems_version = %q{1.3.6}
|
16
|
-
s.summary = %q{riakpb is a protocol buffer client for Riak--the distributed database by Basho.}
|
17
|
-
s.test_files = ["spec/riak/bucket_spec.rb", "spec/riak/client_spec.rb", "spec/riak/key_spec.rb", "spec/riak/map_reduce_spec.rb", "spec/riak/riak_content_spec.rb", "spec/riak/rpc_spec.rb", "spec/spec_helper.rb"]
|
18
|
-
|
19
|
-
if s.respond_to? :specification_version then
|
20
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
21
|
-
s.specification_version = 3
|
22
|
-
|
23
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
24
|
-
s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.9"])
|
25
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 2.3.5"])
|
26
|
-
s.add_runtime_dependency(%q<protobuf>, [">= 0.4.4"])
|
27
|
-
else
|
28
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.9"])
|
29
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
30
|
-
s.add_dependency(%q<protobuf>, [">= 0.4.4"])
|
31
|
-
end
|
32
|
-
else
|
33
|
-
s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.9"])
|
34
|
-
s.add_dependency(%q<activesupport>, [">= 2.3.5"])
|
35
|
-
s.add_dependency(%q<protobuf>, [">= 0.4.4"])
|
36
|
-
end
|
37
|
-
end
|