riak-client 0.9.1 → 0.9.2
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/Gemfile +1 -1
- data/lib/riak.rb +4 -42
- data/lib/riak/bucket.rb +6 -1
- data/lib/riak/cache_store.rb +7 -1
- data/lib/riak/client.rb +11 -10
- data/lib/riak/client/beefcake/messages.rb +0 -2
- data/lib/riak/client/beefcake/object_methods.rb +3 -1
- data/lib/riak/client/beefcake_protobuffs_backend.rb +5 -2
- data/lib/riak/client/curb_backend.rb +4 -1
- data/lib/riak/client/excon_backend.rb +12 -4
- data/lib/riak/client/http_backend.rb +15 -9
- data/lib/riak/client/http_backend/configuration.rb +4 -1
- data/lib/riak/client/http_backend/object_methods.rb +6 -1
- data/lib/riak/client/http_backend/request_headers.rb +2 -1
- data/lib/riak/client/http_backend/transport_methods.rb +4 -1
- data/lib/riak/client/net_http_backend.rb +4 -1
- data/lib/riak/client/protobuffs_backend.rb +1 -0
- data/lib/riak/client/pump.rb +1 -1
- data/lib/riak/failed_request.rb +3 -1
- data/lib/riak/json.rb +9 -0
- data/lib/riak/link.rb +4 -1
- data/lib/riak/locale/en.yml +1 -0
- data/lib/riak/map_reduce.rb +12 -4
- data/lib/riak/map_reduce/filter_builder.rb +2 -1
- data/lib/riak/map_reduce/phase.rb +4 -1
- data/lib/riak/map_reduce_error.rb +1 -1
- data/lib/riak/robject.rb +6 -1
- data/lib/riak/search.rb +1 -1
- data/lib/riak/test_server.rb +1 -1
- data/lib/riak/util/escape.rb +1 -1
- data/lib/riak/util/headers.rb +1 -1
- data/lib/riak/util/multipart.rb +1 -2
- data/lib/riak/util/multipart/stream_parser.rb +2 -1
- data/lib/riak/util/tcp_socket_extensions.rb +1 -0
- data/lib/riak/util/translation.rb +1 -1
- data/lib/riak/walk_spec.rb +3 -1
- data/riak-client.gemspec +3 -3
- data/spec/spec_helper.rb +2 -1
- data/spec/support/http_backend_implementation_examples.rb +37 -0
- metadata +3 -3
- data/lib/riak/invalid_response.rb +0 -25
data/Gemfile
CHANGED
data/lib/riak.rb
CHANGED
@@ -13,52 +13,14 @@
|
|
13
13
|
# limitations under the License.
|
14
14
|
$KCODE = "UTF8" if RUBY_VERSION < "1.9"
|
15
15
|
|
16
|
-
require 'base64'
|
17
|
-
require 'uri'
|
18
|
-
require 'cgi'
|
19
|
-
require 'set'
|
20
|
-
require 'net/http'
|
21
|
-
require 'yaml'
|
22
|
-
require 'riak/i18n'
|
23
|
-
|
24
|
-
# Load JSON
|
25
|
-
unless defined? JSON
|
26
|
-
begin
|
27
|
-
require 'yajl/json_gem'
|
28
|
-
rescue LoadError
|
29
|
-
require 'json'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
16
|
require 'riak/core_ext'
|
17
|
+
require 'riak/client'
|
18
|
+
require 'riak/map_reduce'
|
34
19
|
|
35
|
-
# The Riak module contains all aspects of the
|
36
|
-
#
|
20
|
+
# The Riak module contains all aspects of the client interface to
|
21
|
+
# Riak.
|
37
22
|
module Riak
|
38
|
-
# Domain objects
|
39
|
-
autoload :Bucket, "riak/bucket"
|
40
|
-
autoload :Client, "riak/client"
|
41
|
-
autoload :Link, "riak/link"
|
42
|
-
autoload :WalkSpec, "riak/walk_spec"
|
43
|
-
autoload :RObject, "riak/robject"
|
44
|
-
autoload :MapReduce, "riak/map_reduce"
|
45
|
-
|
46
|
-
# Cache store - only supports Rails 3 style
|
47
|
-
autoload :CacheStore, "riak/cache_store"
|
48
|
-
|
49
|
-
# Exceptions
|
50
|
-
autoload :FailedRequest, "riak/failed_request"
|
51
|
-
autoload :InvalidResponse, "riak/invalid_response"
|
52
|
-
autoload :MapReduceError, "riak/map_reduce_error"
|
53
|
-
|
54
|
-
# Test server
|
55
|
-
autoload :TestServer, "riak/test_server"
|
56
|
-
|
57
23
|
# Utility classes and mixins
|
58
24
|
module Util
|
59
|
-
autoload :Escape, "riak/util/escape"
|
60
|
-
autoload :Headers, "riak/util/headers"
|
61
|
-
autoload :Multipart, "riak/util/multipart"
|
62
|
-
autoload :Translation, "riak/util/translation"
|
63
25
|
end
|
64
26
|
end
|
data/lib/riak/bucket.rb
CHANGED
@@ -11,7 +11,12 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/translation'
|
16
|
+
require 'riak/util/escape'
|
17
|
+
require 'riak/client'
|
18
|
+
require 'riak/robject'
|
19
|
+
require 'riak/failed_request'
|
15
20
|
|
16
21
|
module Riak
|
17
22
|
# Represents and encapsulates operations on a Riak bucket. You may retrieve a bucket
|
data/lib/riak/cache_store.rb
CHANGED
@@ -11,8 +11,14 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'yaml'
|
16
|
+
require 'riak/client'
|
17
|
+
require 'riak/bucket'
|
18
|
+
require 'riak/robject'
|
19
|
+
require 'riak/failed_request'
|
15
20
|
require 'active_support/version'
|
21
|
+
|
16
22
|
if ActiveSupport::VERSION::STRING < "3.0.0"
|
17
23
|
raise LoadError, "ActiveSupport 3.0.0 or greater is required to use Riak::CacheStore."
|
18
24
|
else
|
data/lib/riak/client.rb
CHANGED
@@ -11,10 +11,20 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
15
|
require 'tempfile'
|
16
16
|
require 'delegate'
|
17
|
+
require 'riak'
|
18
|
+
require 'riak/util/translation'
|
19
|
+
require 'riak/util/escape'
|
17
20
|
require 'riak/failed_request'
|
21
|
+
require 'riak/client/http_backend'
|
22
|
+
require 'riak/client/net_http_backend'
|
23
|
+
require 'riak/client/curb_backend'
|
24
|
+
require 'riak/client/excon_backend'
|
25
|
+
require 'riak/client/protobuffs_backend'
|
26
|
+
require 'riak/client/beefcake_protobuffs_backend'
|
27
|
+
require 'riak/bucket'
|
18
28
|
|
19
29
|
module Riak
|
20
30
|
# A client connection to Riak.
|
@@ -22,15 +32,6 @@ module Riak
|
|
22
32
|
include Util::Translation
|
23
33
|
include Util::Escape
|
24
34
|
|
25
|
-
autoload :Pump, "riak/client/pump"
|
26
|
-
autoload :HTTPBackend, "riak/client/http_backend"
|
27
|
-
autoload :NetHTTPBackend, "riak/client/net_http_backend"
|
28
|
-
autoload :CurbBackend, "riak/client/curb_backend"
|
29
|
-
autoload :ExconBackend, "riak/client/excon_backend"
|
30
|
-
|
31
|
-
autoload :ProtobuffsBackend, "riak/client/protobuffs_backend"
|
32
|
-
autoload :BeefcakeProtobuffsBackend, "riak/client/beefcake_protobuffs_backend"
|
33
|
-
|
34
35
|
# When using integer client IDs, the exclusive upper-bound of valid values.
|
35
36
|
MAX_CLIENT_ID = 4294967296
|
36
37
|
|
@@ -11,8 +11,6 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
15
|
-
require 'riak/link'
|
16
14
|
require 'beefcake'
|
17
15
|
|
18
16
|
module Riak
|
@@ -11,7 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
14
|
+
require 'riak/robject'
|
15
|
+
require 'riak/link'
|
16
|
+
require 'riak/client/beefcake/messages'
|
15
17
|
|
16
18
|
module Riak
|
17
19
|
class Client
|
@@ -11,7 +11,10 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/json'
|
16
|
+
require 'riak/client'
|
17
|
+
require 'riak/failed_request'
|
15
18
|
require 'riak/client/protobuffs_backend'
|
16
19
|
require 'riak/client/pump'
|
17
20
|
|
@@ -22,7 +25,7 @@ module Riak
|
|
22
25
|
begin
|
23
26
|
require 'beefcake'
|
24
27
|
require 'riak/client/beefcake/messages'
|
25
|
-
require
|
28
|
+
require 'riak/client/beefcake/object_methods'
|
26
29
|
true
|
27
30
|
rescue LoadError, NameError
|
28
31
|
false
|
@@ -11,8 +11,11 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'thread'
|
16
|
+
require 'riak/client/http_backend'
|
15
17
|
require 'riak/client/pump'
|
18
|
+
require 'riak/failed_request'
|
16
19
|
|
17
20
|
module Riak
|
18
21
|
class Client
|
@@ -11,7 +11,10 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/failed_request'
|
16
|
+
require 'riak/client/http_backend'
|
17
|
+
require 'riak/client/http_backend/request_headers'
|
15
18
|
require 'riak/client/pump'
|
16
19
|
|
17
20
|
module Riak
|
@@ -42,18 +45,23 @@ module Riak
|
|
42
45
|
params[:body] = data if [:put,:post].include?(method)
|
43
46
|
params[:idempotent] = (method != :post)
|
44
47
|
|
45
|
-
|
48
|
+
if block_given?
|
49
|
+
pump = Pump.new(block)
|
50
|
+
# Later versions of Excon pass multiple arguments to the block
|
51
|
+
block = lambda {|*args| pump.pump(args.first) }
|
52
|
+
end
|
46
53
|
|
47
54
|
response = connection.request(params, &block)
|
55
|
+
response_headers.initialize_http_header(response.headers)
|
56
|
+
|
48
57
|
if valid_response?(expect, response.status)
|
49
|
-
response_headers.initialize_http_header(response.headers)
|
50
58
|
result = {:headers => response_headers.to_hash, :code => response.status}
|
51
59
|
if return_body?(method, response.status, block_given?)
|
52
60
|
result[:body] = response.body
|
53
61
|
end
|
54
62
|
result
|
55
63
|
else
|
56
|
-
raise HTTPFailedRequest.new(method, expect, response.status,
|
64
|
+
raise HTTPFailedRequest.new(method, expect, response.status, response_headers.to_hash, response.body)
|
57
65
|
end
|
58
66
|
end
|
59
67
|
|
@@ -11,7 +11,18 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/escape'
|
16
|
+
require 'riak/util/translation'
|
17
|
+
require 'riak/util/multipart'
|
18
|
+
require 'riak/util/multipart/stream_parser'
|
19
|
+
require 'riak/json'
|
20
|
+
require 'riak/client'
|
21
|
+
require 'riak/bucket'
|
22
|
+
require 'riak/robject'
|
23
|
+
require 'riak/client/http_backend/transport_methods'
|
24
|
+
require 'riak/client/http_backend/object_methods'
|
25
|
+
require 'riak/client/http_backend/configuration'
|
15
26
|
|
16
27
|
module Riak
|
17
28
|
class Client
|
@@ -21,18 +32,13 @@ module Riak
|
|
21
32
|
# {TransportMethods#perform} method for library-specific
|
22
33
|
# semantics.
|
23
34
|
class HTTPBackend
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
autoload :Configuration, "riak/client/http_backend/configuration"
|
28
|
-
|
35
|
+
include Util::Escape
|
36
|
+
include Util::Translation
|
37
|
+
|
29
38
|
include TransportMethods
|
30
39
|
include ObjectMethods
|
31
40
|
include Configuration
|
32
41
|
|
33
|
-
include Util::Escape
|
34
|
-
include Util::Translation
|
35
|
-
|
36
42
|
# The Riak::Client that uses this backend
|
37
43
|
attr_reader :client
|
38
44
|
|
@@ -11,7 +11,10 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/failed_request'
|
16
|
+
require 'riak/client/http_backend'
|
17
|
+
require 'riak/link'
|
15
18
|
|
16
19
|
module Riak
|
17
20
|
class Client
|
@@ -11,8 +11,13 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require '
|
14
|
+
require 'uri'
|
15
|
+
require 'set'
|
15
16
|
require 'time'
|
17
|
+
require 'riak/client/http_backend'
|
18
|
+
require 'riak/robject'
|
19
|
+
require 'riak/link'
|
20
|
+
require 'riak/util/multipart'
|
16
21
|
|
17
22
|
module Riak
|
18
23
|
class Client
|
@@ -11,7 +11,8 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/headers'
|
15
16
|
|
16
17
|
module Riak
|
17
18
|
class Client
|
@@ -11,8 +11,11 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
15
|
require 'base64'
|
16
|
+
require 'uri'
|
17
|
+
require 'riak/client'
|
18
|
+
require 'riak/util/headers'
|
16
19
|
|
17
20
|
module Riak
|
18
21
|
class Client
|
@@ -11,7 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/client/http_backend'
|
16
|
+
require 'riak/failed_request'
|
15
17
|
|
16
18
|
module Riak
|
17
19
|
class Client
|
@@ -21,6 +23,7 @@ module Riak
|
|
21
23
|
def self.configured?
|
22
24
|
begin
|
23
25
|
require 'net/http'
|
26
|
+
require 'openssl'
|
24
27
|
true
|
25
28
|
rescue LoadError, NameError
|
26
29
|
false
|
data/lib/riak/client/pump.rb
CHANGED
data/lib/riak/failed_request.rb
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/translation'
|
16
|
+
require 'riak/json'
|
15
17
|
|
16
18
|
module Riak
|
17
19
|
# Exception raised when receiving an unexpected client response from
|
data/lib/riak/json.rb
ADDED
data/lib/riak/link.rb
CHANGED
@@ -11,7 +11,10 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/translation'
|
16
|
+
require 'riak/util/escape'
|
17
|
+
require 'riak/walk_spec'
|
15
18
|
|
16
19
|
module Riak
|
17
20
|
# Represents a link from one object to another in Riak
|
data/lib/riak/locale/en.yml
CHANGED
@@ -32,6 +32,7 @@ en:
|
|
32
32
|
invalid_function_value: "invalid value for function: %{value}"
|
33
33
|
invalid_options: "Invalid configuration options given."
|
34
34
|
invalid_phase_type: "type must be :map, :reduce, or :link"
|
35
|
+
invalid_response: "Expected %{expected} but received %{received} from Riak %{extra}"
|
35
36
|
invalid_ssl_verify_mode: "%{invalid} is not a valid :verify_mode option for SSL. Valid options are 'peer' and 'none'."
|
36
37
|
loading_bucket: "while loading bucket '%{name}'"
|
37
38
|
missing_block: "A block must be given."
|
data/lib/riak/map_reduce.rb
CHANGED
@@ -11,7 +11,18 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/translation'
|
16
|
+
require 'riak/util/escape'
|
17
|
+
require 'riak/json'
|
18
|
+
require 'riak/client'
|
19
|
+
require 'riak/bucket'
|
20
|
+
require 'riak/robject'
|
21
|
+
require 'riak/walk_spec'
|
22
|
+
require 'riak/failed_request'
|
23
|
+
require 'riak/map_reduce_error'
|
24
|
+
require 'riak/map_reduce/phase'
|
25
|
+
require 'riak/map_reduce/filter_builder'
|
15
26
|
|
16
27
|
module Riak
|
17
28
|
# Class for invoking map-reduce jobs using the HTTP interface.
|
@@ -19,9 +30,6 @@ module Riak
|
|
19
30
|
include Util::Translation
|
20
31
|
include Util::Escape
|
21
32
|
|
22
|
-
autoload :Phase, "riak/map_reduce/phase"
|
23
|
-
autoload :FilterBuilder, "riak/map_reduce/filter_builder"
|
24
|
-
|
25
33
|
# @return [Array<[bucket,key]>,String,Hash<:bucket,:filters>] The
|
26
34
|
# bucket/keys for input to the job, or the bucket (all
|
27
35
|
# keys), or a hash containing the bucket and key-filters.
|
@@ -11,7 +11,8 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/util/translation'
|
15
16
|
|
16
17
|
module Riak
|
17
18
|
class MapReduce
|
@@ -11,7 +11,10 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
|
+
require 'riak/json'
|
16
|
+
require 'riak/util/translation'
|
17
|
+
require 'riak/walk_spec'
|
15
18
|
|
16
19
|
module Riak
|
17
20
|
class MapReduce
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
14
|
+
require 'riak/util/translation'
|
15
15
|
|
16
16
|
module Riak
|
17
17
|
# Raised when an error occurred in the Javascript map-reduce chain.
|
data/lib/riak/robject.rb
CHANGED
@@ -11,9 +11,14 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
15
14
|
require 'set'
|
16
15
|
require 'time'
|
16
|
+
require 'yaml'
|
17
|
+
require 'riak/util/translation'
|
18
|
+
require 'riak/util/escape'
|
19
|
+
require 'riak/bucket'
|
20
|
+
require 'riak/link'
|
21
|
+
require 'riak/walk_spec'
|
17
22
|
|
18
23
|
module Riak
|
19
24
|
# Represents the data and metadata stored in a bucket/key pair in
|
data/lib/riak/search.rb
CHANGED
data/lib/riak/test_server.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
|
14
|
+
|
15
15
|
require 'tempfile'
|
16
16
|
require 'expect'
|
17
17
|
require 'open3'
|
data/lib/riak/util/escape.rb
CHANGED
data/lib/riak/util/headers.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require '
|
14
|
+
require 'net/http'
|
15
15
|
|
16
16
|
# Splits headers into < 8KB chunks
|
17
17
|
# @private
|
data/lib/riak/util/multipart.rb
CHANGED
@@ -11,13 +11,12 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
14
|
+
require 'riak/util/headers'
|
15
15
|
|
16
16
|
module Riak
|
17
17
|
module Util
|
18
18
|
# Utility methods for handling multipart/mixed responses
|
19
19
|
module Multipart
|
20
|
-
autoload :StreamParser, "riak/util/multipart/stream_parser"
|
21
20
|
extend self
|
22
21
|
# Parses a multipart/mixed body into its constituent parts, including nested multipart/mixed sections
|
23
22
|
# @param [String] data the multipart body data
|
@@ -10,7 +10,8 @@
|
|
10
10
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License
|
13
|
+
# limitations under the License
|
14
|
+
require 'riak/util/translation'
|
14
15
|
require 'riak/util/multipart'
|
15
16
|
|
16
17
|
module Riak
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
14
|
+
require 'riak/i18n'
|
15
15
|
|
16
16
|
module Riak
|
17
17
|
module Util
|
data/lib/riak/walk_spec.rb
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
require 'riak'
|
14
|
+
require 'riak/util/translation'
|
15
|
+
require 'riak/util/escape'
|
16
|
+
require 'riak/link'
|
15
17
|
|
16
18
|
module Riak
|
17
19
|
# The specification of how to follow links from one object to another in Riak,
|
data/riak-client.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{riak-client}
|
5
|
-
s.version = "0.9.
|
5
|
+
s.version = "0.9.2"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Sean Cribbs"]
|
9
|
-
s.date = %q{2011-04-
|
9
|
+
s.date = %q{2011-04-11}
|
10
10
|
s.description = %q{riak-client is a rich client for Riak, the distributed database by Basho. It supports the full HTTP interface including storage operations, bucket configuration, link-walking and map-reduce.}
|
11
11
|
s.email = %q{sean@basho.com}
|
12
|
-
s.files = ["erl_src/riak_kv_test_backend.beam", "erl_src/riak_kv_test_backend.erl", "Gemfile", "lib/active_support/cache/riak_store.rb", "lib/riak/bucket.rb", "lib/riak/cache_store.rb", "lib/riak/client/beefcake/messages.rb", "lib/riak/client/beefcake/object_methods.rb", "lib/riak/client/beefcake_protobuffs_backend.rb", "lib/riak/client/curb_backend.rb", "lib/riak/client/excon_backend.rb", "lib/riak/client/http_backend/configuration.rb", "lib/riak/client/http_backend/object_methods.rb", "lib/riak/client/http_backend/request_headers.rb", "lib/riak/client/http_backend/transport_methods.rb", "lib/riak/client/http_backend.rb", "lib/riak/client/net_http_backend.rb", "lib/riak/client/protobuffs_backend.rb", "lib/riak/client/pump.rb", "lib/riak/client.rb", "lib/riak/core_ext/blank.rb", "lib/riak/core_ext/extract_options.rb", "lib/riak/core_ext/slice.rb", "lib/riak/core_ext/stringify_keys.rb", "lib/riak/core_ext/symbolize_keys.rb", "lib/riak/core_ext/to_param.rb", "lib/riak/core_ext.rb", "lib/riak/failed_request.rb", "lib/riak/i18n.rb", "lib/riak/
|
12
|
+
s.files = ["erl_src/riak_kv_test_backend.beam", "erl_src/riak_kv_test_backend.erl", "Gemfile", "lib/active_support/cache/riak_store.rb", "lib/riak/bucket.rb", "lib/riak/cache_store.rb", "lib/riak/client/beefcake/messages.rb", "lib/riak/client/beefcake/object_methods.rb", "lib/riak/client/beefcake_protobuffs_backend.rb", "lib/riak/client/curb_backend.rb", "lib/riak/client/excon_backend.rb", "lib/riak/client/http_backend/configuration.rb", "lib/riak/client/http_backend/object_methods.rb", "lib/riak/client/http_backend/request_headers.rb", "lib/riak/client/http_backend/transport_methods.rb", "lib/riak/client/http_backend.rb", "lib/riak/client/net_http_backend.rb", "lib/riak/client/protobuffs_backend.rb", "lib/riak/client/pump.rb", "lib/riak/client.rb", "lib/riak/core_ext/blank.rb", "lib/riak/core_ext/extract_options.rb", "lib/riak/core_ext/slice.rb", "lib/riak/core_ext/stringify_keys.rb", "lib/riak/core_ext/symbolize_keys.rb", "lib/riak/core_ext/to_param.rb", "lib/riak/core_ext.rb", "lib/riak/failed_request.rb", "lib/riak/i18n.rb", "lib/riak/json.rb", "lib/riak/link.rb", "lib/riak/locale/en.yml", "lib/riak/map_reduce/filter_builder.rb", "lib/riak/map_reduce/phase.rb", "lib/riak/map_reduce.rb", "lib/riak/map_reduce_error.rb", "lib/riak/robject.rb", "lib/riak/search.rb", "lib/riak/test_server.rb", "lib/riak/util/escape.rb", "lib/riak/util/fiber1.8.rb", "lib/riak/util/headers.rb", "lib/riak/util/multipart/stream_parser.rb", "lib/riak/util/multipart.rb", "lib/riak/util/tcp_socket_extensions.rb", "lib/riak/util/translation.rb", "lib/riak/walk_spec.rb", "lib/riak.rb", "Rakefile", "riak-client.gemspec", "spec/fixtures/cat.jpg", "spec/fixtures/multipart-blank.txt", "spec/fixtures/multipart-mapreduce.txt", "spec/fixtures/multipart-with-body.txt", "spec/fixtures/server.cert.crt", "spec/fixtures/server.cert.key", "spec/fixtures/test.pem", "spec/integration/riak/cache_store_spec.rb", "spec/integration/riak/http_backends_spec.rb", "spec/integration/riak/protobuffs_backends_spec.rb", "spec/integration/riak/test_server_spec.rb", "spec/riak/bucket_spec.rb", "spec/riak/client_spec.rb", "spec/riak/curb_backend_spec.rb", "spec/riak/escape_spec.rb", "spec/riak/excon_backend_spec.rb", "spec/riak/headers_spec.rb", "spec/riak/http_backend/configuration_spec.rb", "spec/riak/http_backend/object_methods_spec.rb", "spec/riak/http_backend/transport_methods_spec.rb", "spec/riak/http_backend_spec.rb", "spec/riak/link_spec.rb", "spec/riak/map_reduce/filter_builder_spec.rb", "spec/riak/map_reduce/phase_spec.rb", "spec/riak/map_reduce_spec.rb", "spec/riak/multipart_spec.rb", "spec/riak/net_http_backend_spec.rb", "spec/riak/robject_spec.rb", "spec/riak/search_spec.rb", "spec/riak/stream_parser_spec.rb", "spec/riak/walk_spec_spec.rb", "spec/spec_helper.rb", "spec/support/drb_mock_server.rb", "spec/support/http_backend_implementation_examples.rb", "spec/support/mock_server.rb", "spec/support/mocks.rb", "spec/support/test_server.yml.example", "spec/support/unified_backend_examples.rb"]
|
13
13
|
s.homepage = %q{http://seancribbs.github.com/ripple}
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.rubygems_version = %q{1.7.2}
|
data/spec/spec_helper.rb
CHANGED
@@ -21,6 +21,7 @@ require 'fakeweb'
|
|
21
21
|
|
22
22
|
begin
|
23
23
|
require 'yaml'
|
24
|
+
require 'riak/test_server'
|
24
25
|
config = YAML.load_file("spec/support/test_server.yml")
|
25
26
|
$test_server = Riak::TestServer.new(config.symbolize_keys)
|
26
27
|
$test_server.prepare!
|
@@ -35,7 +36,7 @@ Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each {|f| require f }
|
|
35
36
|
|
36
37
|
RSpec.configure do |config|
|
37
38
|
config.mock_with :rspec
|
38
|
-
|
39
|
+
|
39
40
|
config.before(:each) do
|
40
41
|
FakeWeb.clean_registry
|
41
42
|
end
|
@@ -239,4 +239,41 @@ shared_examples_for "HTTP backend" do
|
|
239
239
|
response[:code].should == 200
|
240
240
|
end
|
241
241
|
end
|
242
|
+
|
243
|
+
describe "Invalid responses" do
|
244
|
+
|
245
|
+
def bad_request(method)
|
246
|
+
if method == :post || method == :put
|
247
|
+
@backend.send(method, 200, "/riak/","foo", "body")
|
248
|
+
else
|
249
|
+
@backend.send(method, 200, "/riak/","foo")
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
[:get, :post, :put, :delete].each do |method|
|
254
|
+
context method.to_s do
|
255
|
+
|
256
|
+
before(:each) do
|
257
|
+
setup_http_mock(method, @backend.path("/riak/","foo").to_s, :body => "Failure!", :status => 400, 'Content-Type' => 'text/plain' )
|
258
|
+
end
|
259
|
+
|
260
|
+
it "raises an HTTPFailedRequest exeption" do
|
261
|
+
lambda { bad_request(method) }.should raise_error(Riak::HTTPFailedRequest)
|
262
|
+
end
|
263
|
+
|
264
|
+
it "should normalize the response header keys to lower case" do
|
265
|
+
begin
|
266
|
+
bad_request(method)
|
267
|
+
rescue Riak::HTTPFailedRequest => fr
|
268
|
+
fr.headers.keys.should =~ fr.headers.keys.collect(&:downcase)
|
269
|
+
else
|
270
|
+
fail "No exception raised!"
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
end
|
278
|
+
|
242
279
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: riak-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.9.
|
5
|
+
version: 0.9.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sean Cribbs
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-11 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -138,7 +138,7 @@ files:
|
|
138
138
|
- lib/riak/core_ext.rb
|
139
139
|
- lib/riak/failed_request.rb
|
140
140
|
- lib/riak/i18n.rb
|
141
|
-
- lib/riak/
|
141
|
+
- lib/riak/json.rb
|
142
142
|
- lib/riak/link.rb
|
143
143
|
- lib/riak/locale/en.yml
|
144
144
|
- lib/riak/map_reduce/filter_builder.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# Copyright 2010 Sean Cribbs, Sonian Inc., and Basho Technologies, Inc.
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
# you may not use this file except in compliance with the License.
|
5
|
-
# You may obtain a copy of the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
# See the License for the specific language governing permissions and
|
13
|
-
# limitations under the License.
|
14
|
-
require 'riak'
|
15
|
-
|
16
|
-
module Riak
|
17
|
-
# Raised when Riak returns a response that is in an unexpected format
|
18
|
-
class InvalidResponse < StandardError
|
19
|
-
def initialize(expected, received, extra="")
|
20
|
-
expected = expected.inspect if Hash === expected
|
21
|
-
received = received.inspect if Hash === received
|
22
|
-
super "Expected #{expected} but received #{received} from Riak #{extra}"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|