couchbase-jruby-client 0.1.5-java → 0.1.6-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1492dfae8d156eb6569cbc8df246d5c37ea3532a
4
- data.tar.gz: 495d60f2582a86fc4bb10938e28a82d9ab2f4349
3
+ metadata.gz: 341a7b45aacfd18ca9cc715fa6b3108ecc97b291
4
+ data.tar.gz: 600c38a84cbf86349ec5bbea57241eeb6de3ce88
5
5
  SHA512:
6
- metadata.gz: 58581eb80fd7be86b52d6fdbd7bee4c69d208ade9e7779ebeb39856058166ace542fd9c35e436be44590558e26fb29390ef8d85d6cfd0ef78123b043caafc533
7
- data.tar.gz: 1aad5509aef9573b730b266b85481cba8c67a237cf50c132ec1c0a1c1279fad2cde5cc45b20591d0ffff253defa97cbd71d1f0714a4ac70cf17cf6d16e4ad6af
6
+ metadata.gz: 8d1fd37f303fdbc4489f616e339d933120732b8a269241a41cca30dc851326c56acf1267f4d9c6e42945c8fed26787591642e55cfc152ee70960833ee04ca85b
7
+ data.tar.gz: aa6567764d383fc173411f911840737ba6ca27ae05bf50e1daaef6d7e113b1949ef6d3a7024b42063ca2569f858a0f55689781fb4ba0ef4ce783101a6bca579d
data/.coveralls.yml ADDED
@@ -0,0 +1,2 @@
1
+ service_name: travis-pro
2
+ repo_token: YXFMm3Og960X2Ndrj3eome2KFIjlAlJ77
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ before_install:
2
+ # Couchbase Server
3
+ - sudo service memcached stop
4
+ - sudo wget http://packages.couchbase.com/releases/2.2.0/couchbase-server-enterprise_2.2.0_x86.deb
5
+ - sudo dpkg -i couchbase-server-enterprise_2.2.0_x86.deb
6
+ - sudo service couchbase-server start
7
+ - /opt/couchbase/bin/couchbase-cli cluster-init -c localhost --cluster-init-username=admin --cluster-init-password=password --cluster-init-ramsize=256
8
+ - /opt/couchbase/bin/couchbase-cli bucket-create -c localhost --bucket=default --bucket-type=couchbase --bucket-ramsize=256 -u admin -p password
9
+ notifications:
10
+ email:
11
+ - mike@urlgonomics.com
12
+ language: ruby
13
+ rvm:
14
+ - jruby-19mode
data/Gemfile CHANGED
@@ -2,3 +2,4 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in couchbase-jruby-client.gemspec
4
4
  gemspec
5
+ gem 'coveralls', require: false
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Couchbase JRuby Client
2
2
 
3
+ [![Build Status](https://api.travis-ci.org/mje113/couchbase-jruby-client.png)](http://travis-ci.org/mje113/couchbase-jruby-client)
4
+ [![Code Climate](https://codeclimate.com/github/mje113/couchbase-jruby-client.png)](https://codeclimate.com/github/mje113/couchbase-jruby-client)
5
+ [![Coverage Status](https://coveralls.io/repos/mje113/couchbase-jruby-client/badge.png)](https://coveralls.io/r/mje113/couchbase-jruby-client)
6
+ [![Dependency Status](https://gemnasium.com/mje113/couchbase-jruby-client.png)](https://gemnasium.com/mje113/couchbase-jruby-client)
7
+
3
8
  Attempt to recreate the ruby Couchbase client api in JRuby and the
4
9
  Couchbase Java SDK.
5
10
 
@@ -267,3 +272,7 @@ the key and stats as key-value pairs.
267
272
  3. Commit your changes (`git commit -am 'Add some feature'`)
268
273
  4. Push to the branch (`git push origin my-new-feature`)
269
274
  5. Create new Pull Request
275
+
276
+
277
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mje113/couchbase-jruby-client/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
278
+
@@ -19,12 +19,12 @@ Gem::Specification.new do |s|
19
19
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
20
20
  s.require_paths = ['lib']
21
21
 
22
- s.add_runtime_dependency 'multi_json', '~> 1.0'
23
- s.add_runtime_dependency 'thread_safe', '~> 0.1.2'
22
+ s.add_runtime_dependency 'multi_json', '>= 1.0'
23
+ s.add_runtime_dependency 'thread_safe', '>= 0.1.2'
24
24
 
25
- s.add_development_dependency 'bundler', '~> 1.3'
25
+ s.add_development_dependency 'bundler', '>= 1.3'
26
26
  s.add_development_dependency 'rake'
27
- s.add_development_dependency 'minitest', '~> 5.0.4'
28
- s.add_development_dependency 'jrjackson', '~> 0.2.3'
29
- s.add_development_dependency 'active_support'
27
+ s.add_development_dependency 'minitest', '>= 5.1.0'
28
+ s.add_development_dependency 'jrjackson', '>= 0.2.3'
29
+ s.add_development_dependency 'pry'
30
30
  end
@@ -37,7 +37,7 @@ module Couchbase
37
37
 
38
38
  attr_accessor :quiet, :hostname, :port, :pool, :bucket, :username,
39
39
  :password, :default_ttl, :timeout, :default_format,
40
- :default_arithmetic_init, :transcoder
40
+ :default_arithmetic_init, :transcoder, :transcoders
41
41
 
42
42
  attr_reader :client, :key_prefix, :default_format
43
43
 
@@ -249,7 +249,7 @@ module Couchbase
249
249
  end
250
250
 
251
251
  def transcoder
252
- @transcoders[@default_format]
252
+ transcoders[default_format]
253
253
  end
254
254
 
255
255
  def on_connect(&block)
@@ -17,8 +17,15 @@
17
17
 
18
18
  module Couchbase
19
19
 
20
+ class ClusterError < Error::Base; end
21
+
20
22
  class Cluster
21
23
 
24
+ java_import java.net.URI
25
+ java_import com.couchbase.client.clustermanager.BucketType
26
+ java_import com.couchbase.client.clustermanager.FlushResponse
27
+ java_import com.couchbase.client.clustermanager.AuthType
28
+
22
29
  # Establish connection to the cluster for administration
23
30
  #
24
31
  # @param [Hash] options The connection parameter
@@ -27,11 +34,33 @@ module Couchbase
27
34
  # @option options [String] :pool ("default") The pool name
28
35
  # @option options [String] :hostname ("localhost") The hostname
29
36
  # @option options [String] :port (8091) The port
30
- def initialize(options = {})
37
+ def initialize(options)
31
38
  if options[:username].nil? || options[:password].nil?
32
39
  raise ArgumentError, "username and password mandatory to connect to the cluster"
33
40
  end
34
- @connection = Bucket.new(options.merge(:type => :cluster))
41
+
42
+ options = {
43
+ hostname: 'localhost',
44
+ port: 8091
45
+ }.merge(options)
46
+
47
+ cluster_uri = "http://#{options[:hostname]}:#{options[:port]}"
48
+
49
+ uri_list = Array(URI.new(cluster_uri))
50
+ @manager = Java::ComCouchbaseClient::ClusterManager.new(uri_list, options[:username], options[:password])
51
+ end
52
+
53
+ # List available buckets
54
+ def list_buckets
55
+ @manager.listBuckets
56
+ end
57
+
58
+ # Delete the data bucket
59
+ #
60
+ # @param [String] name The name of the bucket
61
+ # @param [Hash] options
62
+ def delete_bucket(bucket)
63
+ @manager.deleteBucket(bucket)
35
64
  end
36
65
 
37
66
  # Create data bucket
@@ -48,58 +77,40 @@ module Couchbase
48
77
  # port for "none"
49
78
  # @option options [Fixnum] :proxy_port The port for moxi
50
79
  def create_bucket(name, options = {})
51
- defaults = {
52
- :type => "couchbase",
53
- :ram_quota => 100,
54
- :replica_number => 1,
55
- :auth_type => "sasl",
56
- :sasl_password => "",
57
- :proxy_port => nil
58
- }
59
- options = defaults.merge(options)
60
- params = {"name" => name}
61
- params["bucketType"] = options[:type]
62
- params["ramQuotaMB"] = options[:ram_quota]
63
- params["replicaNumber"] = options[:replica_number]
64
- params["authType"] = options[:auth_type]
65
- params["saslPassword"] = options[:sasl_password]
66
- params["proxyPort"] = options[:proxy_port]
67
- payload = Utils.encode_params(params.reject!{|k, v| v.nil?})
68
- request = @connection.make_http_request("/pools/default/buckets",
69
- :content_type => "application/x-www-form-urlencoded",
70
- :type => :management,
71
- :method => :post,
72
- :extended => true,
73
- :body => payload)
74
- response = nil
75
- request.on_body do |r|
76
- response = r
77
- response.instance_variable_set("@operation", :create_bucket)
78
- yield(response) if block_given?
80
+ ram_quota = options[:ram_quota] || 100
81
+ replicas = options[:replica_number] || 0
82
+ flush = options.fetch(:flush) { true }
83
+ password = options[:password]
84
+ proxy_port = options[:proxy_port]
85
+ auth_type = options[:auth_type] || 'sasl'
86
+ bucket_type = options[:bucket_type] == 'memcached' ? BucketType::MEMCACHED : BucketType::COUCHBASE
87
+
88
+ if name == 'default'
89
+ @manager.createDefaultBucket(bucket_type, ram_quota, replicas, flush)
90
+ elsif auth == 'sasl'
91
+ @manager.createPortBucket(bucket_type, name, ram_quota, replicas, proxy_port, flush)
92
+ else
93
+ @manager.createNamedBucket(bucket_type, name, ram_quota, replicas, password, flush)
79
94
  end
80
- request.continue
81
- response
95
+ true
96
+ rescue Java::JavaLang::RuntimeException => e
97
+ raise ClusterError, e
82
98
  end
83
99
 
84
- # Delete the data bucket
85
- #
86
- # @param [String] name The name of the bucket
87
- # @param [Hash] options
88
- def delete_bucket(name, options = {})
89
- request = @connection.make_http_request("/pools/default/buckets/#{name}",
90
- :type => :management,
91
- :method => :delete,
92
- :extended => true)
93
- response = nil
94
- request.on_body do |r|
95
- response = r
96
- response.instance_variable_set("@operation", :delete_bucket)
97
- yield(response) if block_given?
98
- end
99
- request.continue
100
- response
100
+ def flush_bucket(bucket)
101
+ @manager.flushBucket(bucket) == FlushResponse::OK
101
102
  end
102
103
 
104
+ def update_bucket(name, options)
105
+ # implement
106
+ end
107
+
108
+ def self.manage(cluster_uri, username, password, &block)
109
+ manager = new(cluster_uri, username, password)
110
+ yield manager
111
+ ensure
112
+ manager.shutdown
113
+ end
103
114
  end
104
115
 
105
116
  end
@@ -0,0 +1,31 @@
1
+ # Author:: Joe Winter <jwinter@jwinter.org>
2
+ # Copyright:: 2013 jwinter.org
3
+ # Author:: Mike Evans <mike@urlgonomics.com>
4
+ # Copyright:: 2013 Urlgonomics LLC.
5
+ # License:: Apache License, Version 2.0
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+
20
+ module Couchbase::Operations
21
+ module Fetch
22
+
23
+ def fetch(key, set_options = {}, &block)
24
+ raise ArgumentError('Must pass a block to #fetch') unless block_given?
25
+ get(key, :quiet => false)
26
+ rescue Couchbase::Error::NotFound
27
+ yield(block).tap {|value| set(key, value, set_options) }
28
+ end
29
+
30
+ end
31
+ end
@@ -223,6 +223,8 @@ module Couchbase::Operations
223
223
  else
224
224
  value = if options.key?(:ttl)
225
225
  client_get_and_touch(key, options[:ttl])
226
+ elsif options[:format]
227
+ client.get(key, transcoders[options[:format]])
226
228
  else
227
229
  client.get(key)
228
230
  end
@@ -230,6 +232,8 @@ module Couchbase::Operations
230
232
  not_found_error(value.nil?, options)
231
233
  value.nil? ? nil : value
232
234
  end
235
+ rescue Java::JavaLang::RuntimeException
236
+ get_single(key, options.merge(format: :plain))
233
237
  end
234
238
 
235
239
  def get_extended(key, options = {})
@@ -262,7 +266,8 @@ module Couchbase::Operations
262
266
  def get_bulk_extended(keys, options = {})
263
267
  {}.tap do |results|
264
268
  keys.each do |key|
265
- results[key] = get_extended(key, options)
269
+ result = get_extended(key, options)
270
+ results[key] = result unless result.nil?
266
271
  end
267
272
  end
268
273
  end
@@ -15,6 +15,12 @@
15
15
  # limitations under the License.
16
16
  #
17
17
 
18
+ # java_import com.couchbase.client.CouchbaseClient
19
+
20
+ # class CouchbaseClient
21
+ # java_alias :java_set, :set, [java.lang.String, Java::int, java.lang.Object, Java::net.spy.memcached.transcoders.Transcoder.java_class]
22
+ # end
23
+
18
24
  module Couchbase::Operations
19
25
  module Store
20
26
 
@@ -22,8 +28,8 @@ module Couchbase::Operations
22
28
  set: -> client, key, value, ttl, transcoder { client.set(key, ttl, value, transcoder) },
23
29
  add: -> client, key, value, ttl, transcoder { client.add(key, ttl, value, transcoder) },
24
30
  replace: -> client, key, value, ttl, transcoder { client.replace(key, ttl, value, transcoder) },
25
- append: -> client, key, value, ttl, transcoder { client.append(key, value) },
26
- prepend: -> client, key, value, ttl, transcoder { client.prepend(key, value) }
31
+ append: -> client, key, value, ttl, transcoder { client.append(key, value, transcoder) },
32
+ prepend: -> client, key, value, ttl, transcoder { client.prepend(key, value, transcoder) }
27
33
  }.freeze
28
34
 
29
35
  # Unconditionally store the object in the Couchbase
@@ -428,6 +434,7 @@ module Couchbase::Operations
428
434
  if options[:cas] && op == :set
429
435
  client_cas(key, value, ttl, options[:cas], transcoder)
430
436
  else
437
+ transcoder = op == :append || op == :prepend ? transcoders[:plain] : transcoder
431
438
  future = client_store_op(op, key, value, ttl, transcoder)
432
439
  if cas = future_cas(future)
433
440
  cas
@@ -18,6 +18,7 @@
18
18
  require 'couchbase/operations/touch'
19
19
  require 'couchbase/operations/store'
20
20
  require 'couchbase/operations/get'
21
+ require 'couchbase/operations/fetch'
21
22
  require 'couchbase/operations/delete'
22
23
  require 'couchbase/operations/unlock'
23
24
  require 'couchbase/operations/arithmetic'
@@ -31,6 +32,7 @@ module Couchbase
31
32
  def self.included(klass)
32
33
  klass.send(:include, Store)
33
34
  klass.send(:include, Get)
35
+ klass.send(:include, Fetch)
34
36
  klass.send(:include, Touch)
35
37
  klass.send(:include, Delete)
36
38
  klass.send(:include, Unlock)
@@ -37,6 +37,8 @@ module Couchbase
37
37
  MultiJson.load(data)
38
38
  rescue MultiJson::LoadError
39
39
  ::Marshal.load(data)
40
+ rescue TypeError
41
+ data
40
42
  end
41
43
 
42
44
  def encode(o)
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Couchbase
19
- VERSION = '0.1.5'
19
+ VERSION = '0.1.6'
20
20
  end
data/lib/couchbase.rb CHANGED
@@ -22,11 +22,11 @@ end
22
22
 
23
23
  require 'java'
24
24
  require 'jars/commons-codec-1.5.jar'
25
- require 'jars/couchbase-client-1.2.0.jar'
25
+ require 'jars/couchbase-client-1.2.3.jar'
26
26
  require 'jars/jettison-1.1.jar'
27
27
  require 'jars/httpcore-4.1.1.jar'
28
28
  require 'jars/netty-3.5.5.Final.jar'
29
- require 'jars/spymemcached-2.10.0.jar'
29
+ require 'jars/spymemcached-2.10.3.jar'
30
30
  require 'jars/httpcore-nio-4.1.1.jar'
31
31
  require 'couchbase/version'
32
32
  require 'uri'
@@ -48,8 +48,6 @@ require 'couchbase/query'
48
48
 
49
49
  include Java
50
50
 
51
- java_import Java::com.couchbase.client.CouchbaseClient
52
-
53
51
  at_exit do
54
52
  Couchbase.disconnect
55
53
  end
Binary file
Binary file
data/test/profile/Gemfile CHANGED
@@ -4,3 +4,4 @@ gem 'benchmark-ips'
4
4
  gem 'jrjackson', '~> 0.2.3'
5
5
  gem 'multi_json', '~> 1.0'
6
6
  gem 'atomic', '~> 1.1.14'
7
+ gem 'thread_safe'
data/test/setup.rb CHANGED
@@ -16,6 +16,8 @@
16
16
  #
17
17
 
18
18
  gem 'minitest'
19
+ require 'coveralls'
20
+ Coveralls.wear!
19
21
  require 'minitest/autorun'
20
22
  require 'couchbase'
21
23
 
@@ -0,0 +1,33 @@
1
+ # Author:: Mike Evans <mike@urlgonomics.com>
2
+ # Copyright:: 2013 Urlgonomics LLC.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+ require File.join(File.dirname(__FILE__), 'setup')
18
+
19
+ class TestCluster < MiniTest::Test
20
+
21
+ def setup
22
+ @cluster = Couchbase::Cluster.new(username: 'admin', password: 'password')
23
+ end
24
+
25
+ def test_that_it_can_connect_to_cluster_manager
26
+ assert @cluster
27
+ end
28
+
29
+ def test_can_list_buckets
30
+ assert @cluster.list_buckets.include?('default')
31
+ end
32
+
33
+ end
data/test/test_delete.rb CHANGED
@@ -17,7 +17,7 @@
17
17
 
18
18
  require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
- class TestStore < MiniTest::Test
20
+ class TestDelete < MiniTest::Test
21
21
 
22
22
  def test_trivial_delete
23
23
  cb.set(uniq_id, "bar")
@@ -0,0 +1,50 @@
1
+ # Author:: Joe Winter <jwinter@jwinter.org>
2
+ # Copyright:: 2013 jwinter.org
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestFetch < MiniTest::Test
21
+
22
+ def test_trivial_fetch
23
+ cb.fetch(uniq_id) do
24
+ 123
25
+ end
26
+ val = cb.get(uniq_id)
27
+ assert_equal 123, val
28
+ end
29
+
30
+ def test_returns_existing_key_if_exists
31
+ cb.set(uniq_id, 'abc')
32
+
33
+ cb.fetch(uniq_id) do
34
+ 'xyz'
35
+ end
36
+
37
+ assert_equal 'abc', cb.get(uniq_id)
38
+ end
39
+
40
+ def test_fetch_works_with_quiet_mode
41
+ cb.quiet = true
42
+ cb.fetch(uniq_id) do
43
+ 'xyz'
44
+ end
45
+ assert_equal 'xyz', cb.get(uniq_id)
46
+ ensure
47
+ cb.quiet = false
48
+ end
49
+
50
+ end
data/test/test_get.rb CHANGED
@@ -49,8 +49,6 @@ class TestGet < MiniTest::Test
49
49
  end
50
50
 
51
51
  def test_multi_get_extended
52
- skip 'Looking like Java client doesnt support multi_get_extended'
53
-
54
52
  cas1 = cb.set(uniq_id(1), "foo1")
55
53
  cas2 = cb.set(uniq_id(2), "foo2")
56
54
 
@@ -251,8 +249,7 @@ class TestGet < MiniTest::Test
251
249
  end
252
250
 
253
251
  def test_it_allows_to_store_nil
254
- skip "TODO: figure out nil storage"
255
-
252
+ skip
256
253
  orig_cas = cb.set(uniq_id, nil)
257
254
  assert orig_cas.is_a?(Numeric)
258
255
 
@@ -267,8 +264,7 @@ class TestGet < MiniTest::Test
267
264
  end
268
265
 
269
266
  def test_zero_length_string_is_not_nil
270
- skip("zero length string")
271
-
267
+ skip
272
268
  cb.set(uniq_id, "", :format => :document)
273
269
  assert_equal "", cb.get(uniq_id)
274
270
 
@@ -295,12 +291,10 @@ class TestGet < MiniTest::Test
295
291
  cb.set(uniq_id, '{"foo":"bar"}', :format => :plain)
296
292
  value, flags, _ = cb.get(uniq_id, :extended => true)
297
293
  assert_equal '{"foo":"bar"}', value
298
- assert_equal 0x02, flags
299
294
 
300
295
  value, flags, _ = cb.get(uniq_id, :extended => true, :format => :document)
301
296
  expected = {"foo" => "bar"}
302
297
  assert_equal expected, value
303
- assert_equal 0x02, flags
304
298
 
305
299
  cb.prepend(uniq_id, "NOT-A-JSON")
306
300
  assert_raises Couchbase::Error::ValueFormat do
@@ -310,7 +304,6 @@ class TestGet < MiniTest::Test
310
304
 
311
305
  # http://www.couchbase.com/issues/browse/RCBC-31
312
306
  def test_consistent_behaviour_for_arrays
313
-
314
307
  cas = cb.set(uniq_id("foo"), "foo")
315
308
  cb.set(uniq_id("bar"), "bar")
316
309
 
data/test/test_store.rb CHANGED
@@ -25,7 +25,6 @@ class TestStore < MiniTest::Test
25
25
  end
26
26
 
27
27
  def test_set_with_cas
28
-
29
28
  cas1 = cb.set(uniq_id, "bar1")
30
29
  assert cas1 > 0
31
30
 
@@ -44,7 +43,6 @@ class TestStore < MiniTest::Test
44
43
  end
45
44
 
46
45
  def test_add
47
-
48
46
  cas1 = cb.add(uniq_id, "bar")
49
47
  assert cas1 > 0
50
48
 
@@ -58,7 +56,6 @@ class TestStore < MiniTest::Test
58
56
  end
59
57
 
60
58
  def test_replace
61
-
62
59
  assert_raises(Couchbase::Error::NotFound) do
63
60
  cb.replace(uniq_id, "bar")
64
61
  end
@@ -70,7 +67,6 @@ class TestStore < MiniTest::Test
70
67
  end
71
68
 
72
69
  def test_acceptable_keys
73
-
74
70
  cas = cb.set(uniq_id.to_sym, "bar")
75
71
  assert cas > 0
76
72
 
@@ -120,9 +116,7 @@ class TestStore < MiniTest::Test
120
116
  end
121
117
 
122
118
  def test_append
123
- cb.default_format = :plain
124
-
125
- cas1 = cb.set(uniq_id, "foo")
119
+ cas1 = cb.set(uniq_id, "foo", format: :plain)
126
120
  assert cas1 > 0
127
121
  cas2 = cb.append(uniq_id, "bar")
128
122
  assert cas2 > 0
@@ -130,12 +124,9 @@ class TestStore < MiniTest::Test
130
124
 
131
125
  val = cb.get(uniq_id)
132
126
  assert_equal "foobar", val
133
- ensure
134
- cb.default_format = :document
135
127
  end
136
128
 
137
129
  def test_prepend
138
- skip 'Plain encoding isnt working correctly'
139
130
  cb.default_format = :plain
140
131
 
141
132
  cas1 = cb.set(uniq_id, "foo")
@@ -165,19 +156,22 @@ class TestStore < MiniTest::Test
165
156
 
166
157
  ArbitraryData = Struct.new(:baz)
167
158
 
159
+ def test_set_with_marshal
160
+ cb.set(uniq_id, ArbitraryData.new('thing'), format: :marshal)
161
+ val = cb.get(uniq_id)
162
+ assert val.is_a?(ArbitraryData)
163
+ assert_equal "thing", val.baz
164
+ end
165
+
168
166
  def test_set_using_brackets
169
167
  cb[uniq_id(1)] = "foo"
170
168
  val = cb.get(uniq_id(1))
171
169
  assert_equal "foo", val
172
170
 
173
- # if RUBY_VERSION =~ /^1\.9/
174
- # eval <<-EOC
175
- # connection[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
176
- # val = cb.get(uniq_id(3))
177
- # assert val.is_a?(ArbitraryData)
178
- # assert_equal "thing", val.baz
179
- # EOC
180
- # end
171
+ cb[uniq_id(3), :format => :marshal] = ArbitraryData.new("thing")
172
+ val = cb.get(uniq_id(3))
173
+ assert val.is_a?(ArbitraryData)
174
+ assert_equal "thing", val.baz
181
175
  end
182
176
 
183
177
  def test_multi_store
metadata CHANGED
@@ -1,25 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-jruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: java
6
6
  authors:
7
7
  - Mike Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-20 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  version_requirements: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  requirement: !ruby/object:Gem::Requirement
21
21
  requirements:
22
- - - ~>
22
+ - - '>='
23
23
  - !ruby/object:Gem::Version
24
24
  version: '1.0'
25
25
  prerelease: false
@@ -28,12 +28,12 @@ dependencies:
28
28
  name: thread_safe
29
29
  version_requirements: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 0.1.2
34
34
  requirement: !ruby/object:Gem::Requirement
35
35
  requirements:
36
- - - ~>
36
+ - - '>='
37
37
  - !ruby/object:Gem::Version
38
38
  version: 0.1.2
39
39
  prerelease: false
@@ -42,12 +42,12 @@ dependencies:
42
42
  name: bundler
43
43
  version_requirements: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.3'
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  requirements:
50
- - - ~>
50
+ - - '>='
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.3'
53
53
  prerelease: false
@@ -70,32 +70,32 @@ dependencies:
70
70
  name: minitest
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
- version: 5.0.4
75
+ version: 5.1.0
76
76
  requirement: !ruby/object:Gem::Requirement
77
77
  requirements:
78
- - - ~>
78
+ - - '>='
79
79
  - !ruby/object:Gem::Version
80
- version: 5.0.4
80
+ version: 5.1.0
81
81
  prerelease: false
82
82
  type: :development
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: jrjackson
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - '>='
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.2.3
90
90
  requirement: !ruby/object:Gem::Requirement
91
91
  requirements:
92
- - - ~>
92
+ - - '>='
93
93
  - !ruby/object:Gem::Version
94
94
  version: 0.2.3
95
95
  prerelease: false
96
96
  type: :development
97
97
  - !ruby/object:Gem::Dependency
98
- name: active_support
98
+ name: pry
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - '>='
@@ -115,9 +115,11 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - .coveralls.yml
118
119
  - .gitignore
119
120
  - .jrubyrc
120
121
  - .ruby-version
122
+ - .travis.yml
121
123
  - Gemfile
122
124
  - LICENSE.txt
123
125
  - README.md
@@ -136,6 +138,7 @@ files:
136
138
  - lib/couchbase/operations/arithmetic.rb
137
139
  - lib/couchbase/operations/delete.rb
138
140
  - lib/couchbase/operations/design_docs.rb
141
+ - lib/couchbase/operations/fetch.rb
139
142
  - lib/couchbase/operations/get.rb
140
143
  - lib/couchbase/operations/stats.rb
141
144
  - lib/couchbase/operations/store.rb
@@ -150,16 +153,16 @@ files:
150
153
  - lib/couchbase/view.rb
151
154
  - lib/couchbase/view_row.rb
152
155
  - lib/jars/commons-codec-1.5.jar
153
- - lib/jars/couchbase-client-1.2.0-javadoc.jar
154
- - lib/jars/couchbase-client-1.2.0-sources.jar
155
- - lib/jars/couchbase-client-1.2.0.jar
156
+ - lib/jars/couchbase-client-1.2.3-javadoc.jar
157
+ - lib/jars/couchbase-client-1.2.3-sources.jar
158
+ - lib/jars/couchbase-client-1.2.3.jar
156
159
  - lib/jars/httpcore-4.1.1.jar
157
160
  - lib/jars/httpcore-nio-4.1.1.jar
158
161
  - lib/jars/jettison-1.1.jar
159
162
  - lib/jars/netty-3.5.5.Final.jar
160
- - lib/jars/spymemcached-2.10.0-javadoc.jar
161
- - lib/jars/spymemcached-2.10.0-sources.jar
162
- - lib/jars/spymemcached-2.10.0.jar
163
+ - lib/jars/spymemcached-2.10.3-javadoc.jar
164
+ - lib/jars/spymemcached-2.10.3-sources.jar
165
+ - lib/jars/spymemcached-2.10.3.jar
163
166
  - test/profile/.gitignore
164
167
  - test/profile/.jrubyrc
165
168
  - test/profile/Gemfile
@@ -170,11 +173,13 @@ files:
170
173
  - test/test_async.rb
171
174
  - test/test_bucket.rb
172
175
  - test/test_cas.rb
176
+ - test/test_cluster.rb
173
177
  - test/test_couchbase.rb
174
178
  - test/test_couchbase_rails_cache_store.rb
175
179
  - test/test_delete.rb
176
180
  - test/test_design_docs.rb
177
181
  - test/test_errors.rb
182
+ - test/test_fetch.rb
178
183
  - test/test_format.rb
179
184
  - test/test_get.rb
180
185
  - test/test_query.rb
@@ -221,11 +226,13 @@ test_files:
221
226
  - test/test_async.rb
222
227
  - test/test_bucket.rb
223
228
  - test/test_cas.rb
229
+ - test/test_cluster.rb
224
230
  - test/test_couchbase.rb
225
231
  - test/test_couchbase_rails_cache_store.rb
226
232
  - test/test_delete.rb
227
233
  - test/test_design_docs.rb
228
234
  - test/test_errors.rb
235
+ - test/test_fetch.rb
229
236
  - test/test_format.rb
230
237
  - test/test_get.rb
231
238
  - test/test_query.rb
Binary file
Binary file