couchbase-jruby-client 0.2.0-java → 0.2.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71bccd5819d83c3e1493076d252d676a36fe311f
4
- data.tar.gz: ca2c16285b9d3fc2672d6af3467db5a14d19b8ca
3
+ metadata.gz: 3602c5d2a676e611e016787b1dfaea84f82dd738
4
+ data.tar.gz: a107ce06192daa7153e2e84c3e153404315f1aab
5
5
  SHA512:
6
- metadata.gz: df3f4ddb4342333fe81bc7ed140b934cefcd4f3ce3d5e204c1b3409b88ebe2c7eb7baed3380fe8d11bc8f7efd2682021664f721e6ac4d0fb1d0184a3871af6ae
7
- data.tar.gz: e557ddfa428849542ea131d55d98ac3a0280d367dfd46624391e6402f564932040e4afd73f5ee6070418b6588cb461fee3d10f62be32711a11a56e7deb91c717
6
+ metadata.gz: 0b1fcf6aa920b132318d3b0952b0e578a7220bb948f8ea35dba12f7c1bea9da89a6de07f83fb46a019bb2e2e31e7d54185ee63f2cd23eeef525a17b7ec529b0c
7
+ data.tar.gz: a82c445f29e05d27fb37d558c6258d6978db1c334dc56f103a28cb348d8ea1f3f5439a4d1b1afd5218f4818cfad40dbf688fd8576e7dd05616f54975436fda57
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- jruby-1.7.9
1
+ jruby-1.7.11
@@ -222,7 +222,7 @@ module Couchbase::Operations
222
222
 
223
223
  key = args.size == 1 ? args.first : args
224
224
 
225
- [key, delta, options]
225
+ [validate_key(key), delta, options]
226
226
  end
227
227
 
228
228
  def single_arithmetic(op, key, delta, options = {})
@@ -82,7 +82,7 @@ module Couchbase::Operations
82
82
  key, options = expand_get_args(args)
83
83
 
84
84
  if key.respond_to?(:to_str)
85
- [key, options[:cas], options]
85
+ [validate_key(key), options[:cas], options]
86
86
  else
87
87
  cas = if key.size > 1 &&
88
88
  key.last.respond_to?(:to_int)
@@ -93,7 +93,7 @@ module Couchbase::Operations
93
93
 
94
94
  key = key.size == 1 ? key.first : key
95
95
 
96
- [key, cas, options]
96
+ [validate_key(key), cas, options]
97
97
  end
98
98
  end
99
99
 
@@ -155,6 +155,7 @@ module Couchbase::Operations
155
155
  end
156
156
 
157
157
  def get_bulk(keys, options)
158
+ keys = keys.map { |key| validate_key(key) }
158
159
  results = if options[:extended]
159
160
  get_bulk_extended(keys, options)
160
161
  else
@@ -175,11 +176,13 @@ module Couchbase::Operations
175
176
 
176
177
  case key
177
178
  when String, Symbol
179
+ key = validate_key(key)
178
180
  meta = { op: :get, key: key }
179
181
  future = client.asyncGet(key)
180
182
  when Array
183
+ keys = key.map { |key| validate_key(key) }
181
184
  meta = { op: :get }
182
- future = client.asyncGetBulk(key)
185
+ future = client.asyncGetBulk(keys)
183
186
  when Hash
184
187
  # async_get_and_touch(key, options, &block)
185
188
  end
@@ -203,7 +206,7 @@ module Couchbase::Operations
203
206
  options = extract_options_hash(args)
204
207
  key = args.size == 1 ? args.first : args
205
208
 
206
- [key, options]
209
+ [validate_key(key), options]
207
210
  end
208
211
 
209
212
  def get_single(key, options)
@@ -386,7 +386,7 @@ module Couchbase::Operations
386
386
  ttl = options.delete(:ttl) || default_ttl
387
387
  transcoder = @transcoders[options.delete(:format)] || self.transcoder
388
388
 
389
- [key, value, ttl, transcoder]
389
+ [validate_key(key), value, ttl, transcoder]
390
390
  end
391
391
 
392
392
  def store_op(op, key, value, options = {})
@@ -111,7 +111,7 @@ module Couchbase::Operations
111
111
  end
112
112
  key = args.size > 1 ? args : args.pop
113
113
 
114
- [key, ttl, options]
114
+ [validate_key(key), ttl, options]
115
115
  end
116
116
 
117
117
  def multi_touch_hash(keys, options = {})
@@ -21,11 +21,22 @@ module Couchbase::Operations
21
21
  private
22
22
 
23
23
  def validate_key(key)
24
- if key_prefix
25
- "#{key_prefix}key"
26
- else
27
- key.to_s
24
+ raise ArgumentError, "key cannot be blank" if !key || key.length == 0
25
+ key = key_with_prefix(key)
26
+
27
+ if key.length > 250
28
+ max_length = key_prefix ? 212 - key_prefix.size : 212
29
+ key = "#{key[0, max_length]}:md5:#{Digest::MD5.hexdigest(key)}"
28
30
  end
31
+ return key
32
+ end
33
+
34
+ def key_with_prefix(key)
35
+ (prefix = key_prefix) ? "#{prefix}:#{key}" : key
36
+ end
37
+
38
+ def key_without_prefix(key)
39
+ (prefix = key_prefix) ? key.sub(%r(\A#{prefix}:), '') : key
29
40
  end
30
41
 
31
42
  def extract_options_hash(args)
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Couchbase
19
- VERSION = '0.2.0'
19
+ VERSION = '0.2.1'
20
20
  end
@@ -126,10 +126,10 @@ module Couchbase
126
126
  @data = data
127
127
  @key = data.key
128
128
  @last = false
129
+ @id = data.id unless data.is_a?(ViewRowReduced)
129
130
 
130
131
  case data
131
132
  when ViewRowWithDocs, SpatialViewRowWithDocs
132
- @id = data.id
133
133
  @doc = data.document
134
134
  when ViewRowReduced
135
135
  @value = MultiJson.load(data.value)
data/lib/couchbase.rb CHANGED
@@ -22,12 +22,12 @@ end
22
22
 
23
23
  require 'java'
24
24
  require 'jars/commons-codec-1.5.jar'
25
- require 'jars/couchbase-client-1.2.3.jar'
25
+ require 'jars/couchbase-client-1.3.2.jar'
26
26
  require 'jars/jettison-1.1.jar'
27
- require 'jars/httpcore-4.1.1.jar'
27
+ require 'jars/httpcore-4.3.1.jar'
28
+ require 'jars/httpcore-nio-4.3.1.jar'
28
29
  require 'jars/netty-3.5.5.Final.jar'
29
- require 'jars/spymemcached-2.10.3.jar'
30
- require 'jars/httpcore-nio-4.1.1.jar'
30
+ require 'jars/spymemcached-2.10.5.jar'
31
31
  require 'couchbase/version'
32
32
  require 'uri'
33
33
  require 'thread_safe'
Binary file
Binary file
Binary file
data/test/test_store.rb CHANGED
@@ -73,7 +73,7 @@ class TestStore < Minitest::Test
73
73
  cas = cb.set(uniq_id.to_s, "bar")
74
74
  assert cas > 0
75
75
 
76
- assert_raises(TypeError) do
76
+ assert_raises(ArgumentError) do
77
77
  cb.set(nil, "bar")
78
78
  end
79
79
 
data/test/test_utils.rb CHANGED
@@ -19,6 +19,24 @@ require File.join(File.dirname(__FILE__), 'setup')
19
19
 
20
20
  class TestUtils < Minitest::Test
21
21
 
22
+ def test_nil_or_empty_key
23
+ assert_raises ArgumentError do
24
+ cb.set(nil, 'fu')
25
+ end
26
+
27
+ assert_raises ArgumentError do
28
+ cb.set('', 'bar')
29
+ end
30
+ end
31
+
32
+ def test_truncate_long_keys
33
+ key = 'a' * 500
34
+
35
+ assert cb.set(key, 'fu')
36
+ assert_equal 'fu', cb.get(key)
37
+ assert cb.delete(key)
38
+ end
39
+
22
40
  def test_complex_startkey
23
41
  assert_equal "all_docs?startkey=%5B%22Deadmau5%22%2C%22%22%5D", Couchbase::Utils.build_query("all_docs", :startkey => ["Deadmau5", ""])
24
42
  end
data/test/test_view.rb CHANGED
@@ -55,6 +55,19 @@ class TestView < Minitest::Test
55
55
  assert results.first.doc.nil?
56
56
  assert_equal 4, results.total_rows
57
57
  results.each do |result|
58
+ %w(bob frank sam fred).include?(result.id)
59
+ %w(bob frank sam fred).include?(result.key)
60
+ end
61
+ end
62
+
63
+ def test_fetch_no_docs
64
+ skip unless $mock.real?
65
+ assert results = view.fetch(include_docs: false, stale: false)
66
+ assert_instance_of Couchbase::ViewRow, results.first
67
+ assert results.first.doc.nil?
68
+ assert_equal 4, results.total_rows
69
+ results.each do |result|
70
+ %w(bob frank sam fred).include?(result.id)
58
71
  %w(bob frank sam fred).include?(result.key)
59
72
  end
60
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase-jruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: java
6
6
  authors:
7
7
  - Mike Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-12 00:00:00.000000000 Z
11
+ date: 2014-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -166,16 +166,16 @@ files:
166
166
  - lib/couchbase/view.rb
167
167
  - lib/couchbase/view_row.rb
168
168
  - lib/jars/commons-codec-1.5.jar
169
- - lib/jars/couchbase-client-1.2.3-javadoc.jar
170
- - lib/jars/couchbase-client-1.2.3-sources.jar
171
- - lib/jars/couchbase-client-1.2.3.jar
172
- - lib/jars/httpcore-4.1.1.jar
173
- - lib/jars/httpcore-nio-4.1.1.jar
169
+ - lib/jars/couchbase-client-1.3.2-javadoc.jar
170
+ - lib/jars/couchbase-client-1.3.2-sources.jar
171
+ - lib/jars/couchbase-client-1.3.2.jar
172
+ - lib/jars/httpcore-4.3.1.jar
173
+ - lib/jars/httpcore-nio-4.3.1.jar
174
174
  - lib/jars/jettison-1.1.jar
175
175
  - lib/jars/netty-3.5.5.Final.jar
176
- - lib/jars/spymemcached-2.10.3-javadoc.jar
177
- - lib/jars/spymemcached-2.10.3-sources.jar
178
- - lib/jars/spymemcached-2.10.3.jar
176
+ - lib/jars/spymemcached-2.10.5-javadoc.jar
177
+ - lib/jars/spymemcached-2.10.5-sources.jar
178
+ - lib/jars/spymemcached-2.10.5.jar
179
179
  - tasks/benchmark.rake
180
180
  - tasks/test.rake
181
181
  - tasks/util.rake
Binary file
Binary file
Binary file