riak-client 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -30,17 +30,19 @@ module Riak
30
30
  when IO
31
31
  request.body_stream = data
32
32
  end
33
- response = http.request(request)
34
33
 
35
- if valid_response?(expect, response.code)
36
- result = {:headers => response.to_hash, :code => response.code.to_i}
37
- response.read_body {|chunk| yield chunk } if block_given?
38
- if return_body?(method, response.code, block_given?)
39
- result[:body] = response.body
34
+ {}.tap do |result|
35
+ http.request(request) do |response|
36
+ if valid_response?(expect, response.code)
37
+ result.merge!({:headers => response.to_hash, :code => response.code.to_i})
38
+ response.read_body {|chunk| yield chunk } if block_given?
39
+ if return_body?(method, response.code, block_given?)
40
+ result[:body] = response.body
41
+ end
42
+ else
43
+ raise FailedRequest.new(method, expect, response.code, response.to_hash, response.body)
44
+ end
40
45
  end
41
- result
42
- else
43
- raise FailedRequest.new(method, expect, response.code, response.to_hash, response.body)
44
46
  end
45
47
  end
46
48
  end
@@ -128,8 +128,10 @@ module Riak
128
128
  # @param [Fixnum] value the job timeout, in milliseconds
129
129
  def timeout(value)
130
130
  @timeout = value
131
+ return self
131
132
  end
132
-
133
+ alias :timeout= :timeout
134
+
133
135
  # Convert the job to JSON for submission over the HTTP interface.
134
136
  # @return [String] the JSON representation
135
137
  def to_json(options={})
data/lib/riak/robject.rb CHANGED
@@ -233,7 +233,7 @@ module Riak
233
233
  end
234
234
 
235
235
  # Converts the object to a link suitable for linking other objects to it
236
- def to_link(tag=nil)
236
+ def to_link(tag)
237
237
  Link.new(@bucket.client.http.path(@bucket.client.prefix, escape(@bucket.name), escape(@key)).path, tag)
238
238
  end
239
239
 
@@ -178,6 +178,10 @@ describe Riak::MapReduce do
178
178
  @mr.timeout(50000)
179
179
  @mr.to_json.should include('"timeout":50000')
180
180
  end
181
+
182
+ it "should return self from setting the timeout" do
183
+ @mr.timeout(5000).should == @mr
184
+ end
181
185
  end
182
186
 
183
187
  describe "executing the map reduce job" do
@@ -514,9 +514,9 @@ describe Riak::RObject do
514
514
  end
515
515
  end
516
516
 
517
- it "should convert to a link having the same url and an empty tag" do
517
+ it "should not convert to link without a tag" do
518
518
  @object = Riak::RObject.new(@bucket, "bar")
519
- @object.to_link.should == Riak::Link.new("/riak/foo/bar", nil)
519
+ lambda { @object.to_link }.should raise_error
520
520
  end
521
521
 
522
522
  it "should convert to a link having the same url and a supplied tag" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Sean Cribbs
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-06 00:00:00 -05:00
17
+ date: 2010-06-08 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency