riak-client 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'autospec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'autospec')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'protoc-gen-beefcake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('beefcake', 'protoc-gen-beefcake')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rackup' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rack', 'rackup')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -51,6 +51,7 @@ module Riak
51
51
  def keys(options={}, &block)
52
52
  if block_given?
53
53
  @client.backend.list_keys(self, &block)
54
+ @keys = nil
54
55
  elsif @keys.nil? || options[:reload]
55
56
  @keys = @client.backend.list_keys(self)
56
57
  end
@@ -312,7 +312,7 @@ module Riak
312
312
  end
313
313
  alias :list_buckets :buckets
314
314
 
315
- # Stores a large file/IO object in Riak via the "Luwak" interface.
315
+ # Stores a large file/IO-like object in Riak via the "Luwak" interface.
316
316
  # @overload store_file(filename, content_type, data)
317
317
  # Stores the file at the given key/filename
318
318
  # @param [String] filename the key/filename for the object
@@ -321,7 +321,7 @@ module Riak
321
321
  # @overload store_file(content_type, data)
322
322
  # Stores the file with a server-determined key/filename
323
323
  # @param [String] content_type the MIME Content-Type for the data
324
- # @param [IO, String] data the contents of the file
324
+ # @param [String, #read] data the contents of the file
325
325
  # @return [String] the key/filename where the object was stored
326
326
  def store_file(*args)
327
327
  data, content_type, filename = args.reverse
@@ -128,7 +128,7 @@ module Riak
128
128
  results[msg.phase] += JSON.parse(msg.response)
129
129
  end
130
130
  end
131
- block_given? || results.size == 1 ? results.first : results
131
+ block_given? || results.compact.size == 1 ? results.last : results
132
132
  end
133
133
 
134
134
  private
@@ -128,7 +128,7 @@ module Riak
128
128
  # @param [URI] uri the HTTP URI to request
129
129
  # @param [Hash] headers headers to send along with the request
130
130
  # @param [Fixnum, Array] expect the expected response code(s)
131
- # @param [String, IO] body the PUT or POST request body
131
+ # @param [String, #read] body the PUT or POST request body
132
132
  # @return [Hash] response data, containing :headers, :code and :body keys. Only :headers and :code should be present when the body is streamed or the method is :head.
133
133
  # @yield [chunk] if the method is not :head, successive chunks of the response body will be yielded as strings
134
134
  # @raise [NotImplementedError] if a subclass does not implement this method
@@ -186,7 +186,7 @@ module Riak
186
186
  raise ArgumentError, t("path_and_body_required")
187
187
  end
188
188
 
189
- raise ArgumentError, t("request_body_type") unless String === body || IO === body
189
+ raise ArgumentError, t("request_body_type") unless String === body || body.respond_to?(:read)
190
190
  [args, body]
191
191
  end
192
192
 
@@ -39,7 +39,15 @@ module Riak
39
39
  case data
40
40
  when String
41
41
  request.body = data
42
- when IO
42
+ when data.respond_to?(:read)
43
+ case
44
+ when data.respond_to?(:stat) # IO#stat
45
+ request.content_length = data.stat.size
46
+ when data.respond_to?(:size) # Some IO-like objects
47
+ request.content_length = data.size
48
+ else
49
+ request['Transfer-Encoding'] = 'chunked'
50
+ end
43
51
  request.body_stream = data
44
52
  end
45
53
 
@@ -22,9 +22,9 @@ unless Object.new.respond_to? :to_query and Object.new.respond_to? :to_param
22
22
  end
23
23
 
24
24
  class Hash
25
- def to_param
26
- map do |key, value|
27
- value.to_query(key)
25
+ def to_param(namespace = nil)
26
+ collect do |key, value|
27
+ value.to_query(namespace ? "#{namespace}[#{key}]" : key)
28
28
  end.sort * '&'
29
29
  end
30
30
  end
@@ -42,7 +42,7 @@ en:
42
42
  path_and_body_required: "You must supply both a resource path and a body."
43
43
  port_invalid: "port must be an integer between 0 and 65535"
44
44
  protobuffs_failed_request: "Expected success from Riak but received %{code}. %{body}"
45
- request_body_type: "Request body must be a String or IO."
45
+ request_body_type: "Request body must be a String or respond to :read."
46
46
  resource_path_short: "Resource path too short"
47
47
  search_docs_require_id: "Search index documents must include the 'id' field."
48
48
  search_remove_requires_id_or_query: "Search index documents to be removed must have 'id' or 'query' keys."
@@ -125,7 +125,7 @@ module Riak
125
125
  @raw_data
126
126
  end
127
127
 
128
- # @param [String, IO] the raw data to be stored in riak at this key, will not be marshaled or manipulated prior to storage. Overrides any data stored by {#data=}
128
+ # @param [String, IO-like] the raw data to be stored in riak at this key, will not be marshaled or manipulated prior to storage. Overrides any data stored by {#data=}
129
129
  # @return [String] the data stored
130
130
  def raw_data=(new_raw_data)
131
131
  @data = nil
@@ -196,7 +196,7 @@ module Riak
196
196
  # be done.
197
197
  # @param [Object] payload the data to serialize
198
198
  def serialize(payload)
199
- return payload if IO === payload
199
+ return payload if payload.respond_to?(:read)
200
200
  case @content_type
201
201
  when /json/
202
202
  payload.to_json(Riak.json_options)
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ $: << File.expand_path("../../lib", __FILE__)
5
+ require 'riak'
6
+ require 'benchmark'
7
+
8
+ http = Riak::Client.new(:http_backend => :Excon)
9
+ pbc = Riak::Client.new(:protocol => "pbc")
10
+
11
+ ops = {
12
+ :list_buckets => [5],
13
+ :list_keys => [20,"riakjs_http"],
14
+ :ping => [100],
15
+ :get_bucket_props => [1000,"riakjs_airlines"],
16
+ :set_bucket_props => [100,"foo", {:n_val => 2}]
17
+ }
18
+
19
+ def textobj(c,key=nil)
20
+ obj = c['bench'].new(key)
21
+ obj.content_type = "text/plain"
22
+ obj.raw_data = "This is a message to all out there who like to benchmark."
23
+ obj
24
+ end
25
+
26
+ KEYS = 1000
27
+
28
+ OPERATIONS = [
29
+ [:ping, lambda {|client| 100.times { client.ping }}],
30
+ [:buckets, lambda {|client| 10.times { client.buckets } }],
31
+ [:get_bucket, lambda {|client| 1000.times { client.backend.get_bucket_props('foo') }}],
32
+ [:set_bucket, lambda {|client| 100.times { client['foo'].props = {"n_val" => 2}}}],
33
+ [:store_new, lambda {|client| KEYS.times { textobj(client).store }}],
34
+ [:store_key, lambda {|client| KEYS.times {|i| textobj(client, "#{client.protocol}#{i}").store }}],
35
+ [:fetch_key, lambda {|client| KEYS.times {|i| client['bench'].get("#{client.protocol}#{i}") } }],
36
+ [:keys, lambda {|client| 5.times { client.backend.list_keys('bench') }}],
37
+ [:key_stream, lambda {|client| 5.times { client['bench'].keys {|ks| "." }}}]
38
+ ]
39
+
40
+ Benchmark.bmbm(25) do |x|
41
+ OPERATIONS.each do |op|
42
+ [http, pbc].each do |c|
43
+ x.report("#{c.protocol.ljust(6)}#{op[0]}") do
44
+ op[1][c]
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,21 @@
1
+ require 'riak'
2
+
3
+ riak = Riak::Client.new( :http_backend => :Excon )
4
+
5
+ bucket_names = ["foobar"]
6
+ bucket_names.each do |bucket_name|
7
+ bucket = riak.bucket(bucket_name)
8
+ 10.times do
9
+ new_one = Riak::RObject.new(bucket, "#{rand}")
10
+ new_one.content_type = "application/javascript" # You must set the content type.
11
+ new_one.data = "Hello, World!')"
12
+ new_one.store
13
+ end
14
+
15
+ bucket.keys do |keys|
16
+ keys.each do |key|
17
+ puts key
18
+ bucket.delete(key)
19
+ end
20
+ end
21
+ end
Binary file
@@ -0,0 +1,35 @@
1
+ require 'bundler/setup'
2
+ require 'riak'
3
+ require 'riak/test_server'
4
+
5
+ OUTER = 100
6
+ INNER = 1000
7
+
8
+ ts = Riak::TestServer.new(:bin_dir => "/usr/local/bin",
9
+ :temp_dir => "./rel")
10
+ $expect_verbose = true
11
+ ts.prepare!
12
+ ts.start
13
+
14
+ c = Riak::Client.new(:port => 9000, :http_backend => :Excon)
15
+
16
+ OUTER.times do
17
+ warn "NOT STARTED, WTF?" unless ts.started?
18
+ INNER.times do
19
+ unless rand > 0.8
20
+ c['test'].new.tap do |o|
21
+ o.data = "Some test data" * rand(10)
22
+ o.content_type = "text/plain"
23
+ o.store
24
+ end
25
+ print "."
26
+ end
27
+ end
28
+ puts
29
+
30
+ ts.recycle
31
+ end
32
+
33
+ ts.stop
34
+ ts.cleanup
35
+ $expect_verbose = false
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{riak-client}
5
- s.version = "0.9.4"
5
+ s.version = "0.9.5"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Sean Cribbs"]
9
- s.date = %q{2011-05-10}
8
+ s.authors = [%q{Sean Cribbs}]
9
+ s.date = %q{2011-06-14}
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/key_streamer.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/beefcake_protobuffs_backend_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"]
12
+ s.files = [%q{erl_src/riak_kv_test_backend.beam}, %q{erl_src/riak_kv_test_backend.erl}, %q{Gemfile}, %q{lib/active_support/cache/riak_store.rb}, %q{lib/riak/bucket.rb}, %q{lib/riak/cache_store.rb}, %q{lib/riak/client/beefcake/messages.rb}, %q{lib/riak/client/beefcake/object_methods.rb}, %q{lib/riak/client/beefcake_protobuffs_backend.rb}, %q{lib/riak/client/curb_backend.rb}, %q{lib/riak/client/excon_backend.rb}, %q{lib/riak/client/http_backend/configuration.rb}, %q{lib/riak/client/http_backend/key_streamer.rb}, %q{lib/riak/client/http_backend/object_methods.rb}, %q{lib/riak/client/http_backend/request_headers.rb}, %q{lib/riak/client/http_backend/transport_methods.rb}, %q{lib/riak/client/http_backend.rb}, %q{lib/riak/client/net_http_backend.rb}, %q{lib/riak/client/protobuffs_backend.rb}, %q{lib/riak/client/pump.rb}, %q{lib/riak/client.rb}, %q{lib/riak/core_ext/blank.rb}, %q{lib/riak/core_ext/extract_options.rb}, %q{lib/riak/core_ext/slice.rb}, %q{lib/riak/core_ext/stringify_keys.rb}, %q{lib/riak/core_ext/symbolize_keys.rb}, %q{lib/riak/core_ext/to_param.rb}, %q{lib/riak/core_ext.rb}, %q{lib/riak/failed_request.rb}, %q{lib/riak/i18n.rb}, %q{lib/riak/json.rb}, %q{lib/riak/link.rb}, %q{lib/riak/locale/en.yml}, %q{lib/riak/map_reduce/filter_builder.rb}, %q{lib/riak/map_reduce/phase.rb}, %q{lib/riak/map_reduce.rb}, %q{lib/riak/map_reduce_error.rb}, %q{lib/riak/robject.rb}, %q{lib/riak/search.rb}, %q{lib/riak/test_server.rb}, %q{lib/riak/util/escape.rb}, %q{lib/riak/util/fiber1.8.rb}, %q{lib/riak/util/headers.rb}, %q{lib/riak/util/multipart/stream_parser.rb}, %q{lib/riak/util/multipart.rb}, %q{lib/riak/util/tcp_socket_extensions.rb}, %q{lib/riak/util/translation.rb}, %q{lib/riak/walk_spec.rb}, %q{lib/riak.rb}, %q{pkg/httpvpbuf.rb}, %q{pkg/lk.rb}, %q{pkg/riak-client-0.9.4.gem}, %q{pkg/ts.rb}, %q{Rakefile}, %q{riak-client.gemspec}, %q{spec/fixtures/cat.jpg}, %q{spec/fixtures/multipart-blank.txt}, %q{spec/fixtures/multipart-mapreduce.txt}, %q{spec/fixtures/multipart-with-body.txt}, %q{spec/fixtures/server.cert.crt}, %q{spec/fixtures/server.cert.key}, %q{spec/fixtures/test.pem}, %q{spec/integration/riak/cache_store_spec.rb}, %q{spec/integration/riak/http_backends_spec.rb}, %q{spec/integration/riak/protobuffs_backends_spec.rb}, %q{spec/integration/riak/test_server_spec.rb}, %q{spec/riak/beefcake_protobuffs_backend_spec.rb}, %q{spec/riak/bucket_spec.rb}, %q{spec/riak/client_spec.rb}, %q{spec/riak/core_ext/to_param_spec.rb}, %q{spec/riak/curb_backend_spec.rb}, %q{spec/riak/escape_spec.rb}, %q{spec/riak/excon_backend_spec.rb}, %q{spec/riak/headers_spec.rb}, %q{spec/riak/http_backend/configuration_spec.rb}, %q{spec/riak/http_backend/object_methods_spec.rb}, %q{spec/riak/http_backend/transport_methods_spec.rb}, %q{spec/riak/http_backend_spec.rb}, %q{spec/riak/link_spec.rb}, %q{spec/riak/map_reduce/filter_builder_spec.rb}, %q{spec/riak/map_reduce/phase_spec.rb}, %q{spec/riak/map_reduce_spec.rb}, %q{spec/riak/multipart_spec.rb}, %q{spec/riak/net_http_backend_spec.rb}, %q{spec/riak/robject_spec.rb}, %q{spec/riak/search_spec.rb}, %q{spec/riak/stream_parser_spec.rb}, %q{spec/riak/walk_spec_spec.rb}, %q{spec/spec_helper.rb}, %q{spec/support/drb_mock_server.rb}, %q{spec/support/http_backend_implementation_examples.rb}, %q{spec/support/mock_server.rb}, %q{spec/support/mocks.rb}, %q{spec/support/test_server.yml.example}, %q{spec/support/unified_backend_examples.rb}]
13
13
  s.homepage = %q{http://seancribbs.github.com/ripple}
14
- s.require_paths = ["lib"]
15
- s.rubygems_version = %q{1.7.2}
14
+ s.require_paths = [%q{lib}]
15
+ s.rubygems_version = %q{1.8.5}
16
16
  s.summary = %q{riak-client is a rich client for Riak, the distributed database by Basho.}
17
- s.test_files = ["lib/riak/walk_spec.rb", "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/beefcake_protobuffs_backend_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"]
17
+ s.test_files = [%q{lib/riak/walk_spec.rb}, %q{spec/integration/riak/cache_store_spec.rb}, %q{spec/integration/riak/http_backends_spec.rb}, %q{spec/integration/riak/protobuffs_backends_spec.rb}, %q{spec/integration/riak/test_server_spec.rb}, %q{spec/riak/beefcake_protobuffs_backend_spec.rb}, %q{spec/riak/bucket_spec.rb}, %q{spec/riak/client_spec.rb}, %q{spec/riak/core_ext/to_param_spec.rb}, %q{spec/riak/curb_backend_spec.rb}, %q{spec/riak/escape_spec.rb}, %q{spec/riak/excon_backend_spec.rb}, %q{spec/riak/headers_spec.rb}, %q{spec/riak/http_backend/configuration_spec.rb}, %q{spec/riak/http_backend/object_methods_spec.rb}, %q{spec/riak/http_backend/transport_methods_spec.rb}, %q{spec/riak/http_backend_spec.rb}, %q{spec/riak/link_spec.rb}, %q{spec/riak/map_reduce/filter_builder_spec.rb}, %q{spec/riak/map_reduce/phase_spec.rb}, %q{spec/riak/map_reduce_spec.rb}, %q{spec/riak/multipart_spec.rb}, %q{spec/riak/net_http_backend_spec.rb}, %q{spec/riak/robject_spec.rb}, %q{spec/riak/search_spec.rb}, %q{spec/riak/stream_parser_spec.rb}, %q{spec/riak/walk_spec_spec.rb}]
18
18
 
19
19
  if s.respond_to? :specification_version then
20
20
  s.specification_version = 3
@@ -42,4 +42,30 @@ describe "HTTP" do
42
42
  end
43
43
  end
44
44
  end
45
+
46
+ class Reader < Array
47
+ def read(*args)
48
+ shift
49
+ end
50
+
51
+ def size
52
+ join.size
53
+ end
54
+ end
55
+
56
+ class SizelessReader < Reader
57
+ undef :size
58
+ end
59
+
60
+ describe 'NetHTTPBackend' do
61
+ subject { Riak::Client::NetHTTPBackend.new(@client) }
62
+ let(:file) { File.open(__FILE__) }
63
+ let(:sized) { Reader.new(["foo", "bar", "baz"]) }
64
+ let(:sizeless) { SizelessReader.new(["foo", "bar", "baz"]) }
65
+ it "should set the content-length or transfer-encoding properly on IO uploads" do
66
+ lambda { subject.put(204, "/riak/nethttp", "test-file", file, {"Content-Type" => "text/plain"}) }.should_not raise_error
67
+ lambda { subject.put(204, "/riak/nethttp", "test-sized", sized, {"Content-Type" => "text/plain"}) }.should_not raise_error
68
+ lambda { subject.put(204, "/riak/nethttp", "test-file", sizeless, {"Content-Type" => "text/plain"}) }.should_not raise_error
69
+ end
70
+ end
45
71
  end
@@ -38,3 +38,22 @@ describe Riak::Client::BeefcakeProtobuffsBackend do
38
38
  @backend.list_keys(exp_bucket).should == exp_keys
39
39
  end
40
40
  end
41
+
42
+ describe Riak::Client::BeefcakeProtobuffsBackend, '#mapred' do
43
+ before(:each) do
44
+ @client = Riak::Client.new
45
+ @backend = Riak::Client::BeefcakeProtobuffsBackend.new(@client)
46
+ @backend.instance_variable_set(:@server_config, {})
47
+ end
48
+
49
+ it "should not return nil for previous phases that don't return anything" do
50
+ socket = stub(:socket).as_null_object
51
+ socket.stub(:read).and_return(stub(:socket_header, :unpack => [2, 24]), stub(:socket_message), stub(:socket_header_2, :unpack => [0, 1]))
52
+ message = stub(:message, :phase => 1, :response => [{}].to_json)
53
+ message.stub(:done).and_return(false, true)
54
+ Riak::Client::BeefcakeProtobuffsBackend::RpbMapRedResp.stub(:decode => message)
55
+ TCPSocket.stub(:new => socket)
56
+
57
+ @backend.mapred('').should == [{}]
58
+ end
59
+ end
@@ -57,6 +57,17 @@ describe Riak::Bucket do
57
57
  end
58
58
  all_keys.should == ["bar", "baz"]
59
59
  end
60
+
61
+ it "should invalidate the key cache when streaming" do
62
+ @backend.should_receive(:list_keys).once.and_return(['a'])
63
+ @backend.should_receive(:list_keys).once.and_yield(['b'])
64
+ @backend.should_receive(:list_keys).once.and_return(['c'])
65
+ @bucket.keys.should == ['a']
66
+ keys = []
67
+ @bucket.keys {|kl| keys.concat(kl) }
68
+ keys.should == ['b']
69
+ @bucket.keys.should == ['c']
70
+ end
60
71
  end
61
72
 
62
73
  describe "setting the bucket properties" do
@@ -0,0 +1,15 @@
1
+
2
+ describe Riak do
3
+ require 'riak/core_ext/to_param'
4
+
5
+ it "should do param conversion correctly" do
6
+ { :name => 'David', :nationality => 'Danish' }.to_param.should == "name=David&nationality=Danish"
7
+ end
8
+
9
+ # Based on the activesupport implementation.
10
+ # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/object/to_param.rb
11
+ it "should do param conversion correctly with a namespace" do
12
+ { :name => 'David', :nationality => 'Danish' }.to_param('user').should == "user%5Bname%5D=David&user%5Bnationality%5D=Danish"
13
+ end
14
+
15
+ end
@@ -54,9 +54,10 @@ describe Riak::Client::HTTPBackend::TransportMethods do
54
54
  data.should == "This is the body."
55
55
  end
56
56
 
57
- it "should raise an error if the body is not a string or IO" do
57
+ it "should raise an error if the body is not a string or IO or IO-like (responds to :read)" do
58
58
  lambda { @backend.verify_path_and_body!(["/riak/", "foo", nil]) }.should raise_error(ArgumentError)
59
59
  lambda { @backend.verify_path_and_body!(["/riak/", "foo", File.open("spec/fixtures/cat.jpg")]) }.should_not raise_error(ArgumentError)
60
+ lambda { @backend.verify_path_and_body!(["/riak/", "foo", Tempfile.new('riak-spec')]) }.should_not raise_error(ArgumentError)
60
61
  end
61
62
 
62
63
  it "should raise an error if a body is not given" do
metadata CHANGED
@@ -1,114 +1,119 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: riak-client
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.5
4
5
  prerelease:
5
- version: 0.9.4
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Sean Cribbs
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-05-10 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-06-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: rspec
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2151933920 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
18
+ requirements:
21
19
  - - ~>
22
- - !ruby/object:Gem::Version
20
+ - !ruby/object:Gem::Version
23
21
  version: 2.4.0
24
22
  type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: fakeweb
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2151933920
25
+ - !ruby/object:Gem::Dependency
26
+ name: fakeweb
27
+ requirement: &2151932640 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "1.2"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '1.2'
35
33
  type: :development
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rack
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *2151932640
36
+ - !ruby/object:Gem::Dependency
37
+ name: rack
38
+ requirement: &2151931000 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "1.0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '1.0'
46
44
  type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: curb
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *2151931000
47
+ - !ruby/object:Gem::Dependency
48
+ name: curb
49
+ requirement: &2151929760 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0.6"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0.6'
57
55
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: excon
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *2151929760
58
+ - !ruby/object:Gem::Dependency
59
+ name: excon
60
+ requirement: &2151928760 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
62
+ requirements:
65
63
  - - ~>
66
- - !ruby/object:Gem::Version
64
+ - !ruby/object:Gem::Version
67
65
  version: 0.5.7
68
66
  type: :development
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: i18n
72
67
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *2151928760
69
+ - !ruby/object:Gem::Dependency
70
+ name: i18n
71
+ requirement: &2151927680 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
78
76
  version: 0.4.0
79
77
  type: :runtime
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: builder
83
78
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *2151927680
80
+ - !ruby/object:Gem::Dependency
81
+ name: builder
82
+ requirement: &2151926600 !ruby/object:Gem::Requirement
85
83
  none: false
86
- requirements:
84
+ requirements:
87
85
  - - ~>
88
- - !ruby/object:Gem::Version
86
+ - !ruby/object:Gem::Version
89
87
  version: 2.1.2
90
88
  type: :runtime
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: beefcake
94
89
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *2151926600
91
+ - !ruby/object:Gem::Dependency
92
+ name: beefcake
93
+ requirement: &2151924800 !ruby/object:Gem::Requirement
96
94
  none: false
97
- requirements:
95
+ requirements:
98
96
  - - ~>
99
- - !ruby/object:Gem::Version
97
+ - !ruby/object:Gem::Version
100
98
  version: 0.3.0
101
99
  type: :runtime
102
- version_requirements: *id008
103
- description: 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.
100
+ prerelease: false
101
+ version_requirements: *2151924800
102
+ description: riak-client is a rich client for Riak, the distributed database by Basho.
103
+ It supports the full HTTP interface including storage operations, bucket configuration,
104
+ link-walking and map-reduce.
104
105
  email: sean@basho.com
105
106
  executables: []
106
-
107
107
  extensions: []
108
-
109
108
  extra_rdoc_files: []
110
-
111
- files:
109
+ files:
110
+ - bin/autospec
111
+ - bin/htmldiff
112
+ - bin/ldiff
113
+ - bin/protoc-gen-beefcake
114
+ - bin/rackup
115
+ - bin/rake
116
+ - bin/rspec
112
117
  - erl_src/riak_kv_test_backend.beam
113
118
  - erl_src/riak_kv_test_backend.erl
114
119
  - Gemfile
@@ -158,6 +163,10 @@ files:
158
163
  - lib/riak/util/translation.rb
159
164
  - lib/riak/walk_spec.rb
160
165
  - lib/riak.rb
166
+ - pkg/httpvpbuf.rb
167
+ - pkg/lk.rb
168
+ - pkg/riak-client-0.9.4.gem
169
+ - pkg/ts.rb
161
170
  - Rakefile
162
171
  - riak-client.gemspec
163
172
  - spec/fixtures/cat.jpg
@@ -174,6 +183,7 @@ files:
174
183
  - spec/riak/beefcake_protobuffs_backend_spec.rb
175
184
  - spec/riak/bucket_spec.rb
176
185
  - spec/riak/client_spec.rb
186
+ - spec/riak/core_ext/to_param_spec.rb
177
187
  - spec/riak/curb_backend_spec.rb
178
188
  - spec/riak/escape_spec.rb
179
189
  - spec/riak/excon_backend_spec.rb
@@ -201,32 +211,29 @@ files:
201
211
  - spec/support/unified_backend_examples.rb
202
212
  homepage: http://seancribbs.github.com/ripple
203
213
  licenses: []
204
-
205
214
  post_install_message:
206
215
  rdoc_options: []
207
-
208
- require_paths:
216
+ require_paths:
209
217
  - lib
210
- required_ruby_version: !ruby/object:Gem::Requirement
218
+ required_ruby_version: !ruby/object:Gem::Requirement
211
219
  none: false
212
- requirements:
213
- - - ">="
214
- - !ruby/object:Gem::Version
215
- version: "0"
216
- required_rubygems_version: !ruby/object:Gem::Requirement
220
+ requirements:
221
+ - - ! '>='
222
+ - !ruby/object:Gem::Version
223
+ version: '0'
224
+ required_rubygems_version: !ruby/object:Gem::Requirement
217
225
  none: false
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- version: "0"
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
222
230
  requirements: []
223
-
224
231
  rubyforge_project:
225
- rubygems_version: 1.7.2
232
+ rubygems_version: 1.8.5
226
233
  signing_key:
227
234
  specification_version: 3
228
235
  summary: riak-client is a rich client for Riak, the distributed database by Basho.
229
- test_files:
236
+ test_files:
230
237
  - lib/riak/walk_spec.rb
231
238
  - spec/integration/riak/cache_store_spec.rb
232
239
  - spec/integration/riak/http_backends_spec.rb
@@ -235,6 +242,7 @@ test_files:
235
242
  - spec/riak/beefcake_protobuffs_backend_spec.rb
236
243
  - spec/riak/bucket_spec.rb
237
244
  - spec/riak/client_spec.rb
245
+ - spec/riak/core_ext/to_param_spec.rb
238
246
  - spec/riak/curb_backend_spec.rb
239
247
  - spec/riak/escape_spec.rb
240
248
  - spec/riak/excon_backend_spec.rb