couchbase-jruby-client 0.2.1-java → 0.2.2-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: 3602c5d2a676e611e016787b1dfaea84f82dd738
4
- data.tar.gz: a107ce06192daa7153e2e84c3e153404315f1aab
3
+ metadata.gz: 8ec71506555414ea67468af719e184392afa4704
4
+ data.tar.gz: 74653b08496b561fcf60bae9c03a836c47acff4c
5
5
  SHA512:
6
- metadata.gz: 0b1fcf6aa920b132318d3b0952b0e578a7220bb948f8ea35dba12f7c1bea9da89a6de07f83fb46a019bb2e2e31e7d54185ee63f2cd23eeef525a17b7ec529b0c
7
- data.tar.gz: a82c445f29e05d27fb37d558c6258d6978db1c334dc56f103a28cb348d8ea1f3f5439a4d1b1afd5218f4818cfad40dbf688fd8576e7dd05616f54975436fda57
6
+ metadata.gz: 5bbc04e04898e8505bc3ffd4ce5223c2ab2f13a0200c4c7eae0ddd3eb8ca61797f1f9e3b244f1aaff7c862c0e108e00469345c42e1420e137ffb5d2992c7ab9e
7
+ data.tar.gz: dfa98216f38e6ce0d8282ef7befe1bc85a2efe5332692df1f113e12d1d94a2e1332784f31e0fa5c9f9b28750ca895f1515461afff9abc062f1ad0b3150b1ec98
@@ -16,5 +16,5 @@
16
16
  #
17
17
 
18
18
  module Couchbase
19
- VERSION = '0.2.1'
19
+ VERSION = '0.2.2'
20
20
  end
@@ -91,7 +91,7 @@ module Couchbase
91
91
  @wrapper_class = params.delete(:wrapper_class) || ViewRow
92
92
  @params = { connection_timeout: 75_000 }.merge(params)
93
93
  unless @wrapper_class.respond_to?(:wrap)
94
- raise ArgumentError, "wrapper class should reposond to :wrap, check the options"
94
+ raise ArgumentError, "wrapper class should respond to :wrap, check the options"
95
95
  end
96
96
  end
97
97
 
@@ -352,7 +352,11 @@ module Couchbase
352
352
  end
353
353
 
354
354
  def wrap_or_parse_data(data)
355
- @wrapper_class.wrap(@bucket, data)
355
+ if data.is_a? ViewRowReduced
356
+ data.value
357
+ else
358
+ @wrapper_class.wrap(@bucket, data)
359
+ end
356
360
  end
357
361
 
358
362
  def send_error(*args)
@@ -23,8 +23,17 @@ module Couchbase
23
23
  java_import com.couchbase.client.protocol.views.SpatialViewRowNoDocs
24
24
  java_import com.couchbase.client.protocol.views.SpatialViewRowWithDocs
25
25
 
26
- module Java::ComCouchbaseClientProtocolViews::ViewRow
26
+ class Java::ComCouchbaseClientProtocolViews::ViewRowNoDocs
27
+ def doc
28
+ {
29
+ id: getId,
30
+ key: getKey,
31
+ value: getValue
32
+ }
33
+ end
34
+ end
27
35
 
36
+ class Java::ComCouchbaseClientProtocolViews::ViewRowWithDocs
28
37
  def doc
29
38
  {
30
39
  'meta' => {
@@ -33,7 +42,9 @@ module Couchbase
33
42
  'value' => document
34
43
  }
35
44
  end
45
+ end
36
46
 
47
+ module Java::ComCouchbaseClientProtocolViews::ViewRow
37
48
  def [](key)
38
49
  if respond_to?(key)
39
50
  send(key)
@@ -43,6 +54,7 @@ module Couchbase
43
54
  end
44
55
  end
45
56
 
57
+
46
58
  # This class encapsulates structured JSON document
47
59
  #
48
60
  # @since 1.2.0
data/test/test_view.rb CHANGED
@@ -91,8 +91,7 @@ class TestView < Minitest::Test
91
91
  def test_fetch_reduce
92
92
  skip unless $mock.real?
93
93
  assert results = reduce_view.fetch(stale: false, include_docs: false)
94
- assert_instance_of Couchbase::ViewRow, results.first
95
- assert_equal 4, results.first.value
94
+ assert_equal '4', results.first
96
95
  end
97
96
 
98
97
  def test_fetch_without_reduce
@@ -0,0 +1,74 @@
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
+
18
+ require File.join(File.dirname(__FILE__), 'setup')
19
+
20
+ class TestViewRow < Minitest::Test
21
+
22
+ def setup
23
+ return unless $mock.real?
24
+
25
+ cb.save_design_doc(design_doc)
26
+ { baltimore: 'md' , philadelphia: 'pa', pittsburgh: 'pa' }.each_pair do |city, state|
27
+ cb.set(city, { type: 'city', city: city, state: state })
28
+ end
29
+ end
30
+
31
+ def view
32
+ @view ||= Couchbase::View.new(cb, '_design/cities/_view/by_state')
33
+ end
34
+
35
+ def test_doc
36
+ skip unless $mock.real?
37
+ assert result = view.fetch(include_docs: true, stale: false).first
38
+
39
+ data = result.data
40
+
41
+ assert_instance_of Java::ComCouchbaseClientProtocolViews::ViewRowWithDocs, data
42
+
43
+ assert_equal({'id' => result.id}, data.doc['meta'])
44
+ assert_equal({'type' => result['type'], 'city' => result['city'], 'state' => result['state']}, data.doc['value'])
45
+ end
46
+
47
+ def test_doc_for_ViewRowNoDocs_objects
48
+ skip unless $mock.real?
49
+ assert result = view.fetch(include_docs: false, stale: false).first
50
+
51
+ data = result.data
52
+
53
+ assert_instance_of Java::ComCouchbaseClientProtocolViews::ViewRowNoDocs, data
54
+ assert_equal({ id: result.id, key: data.key, value: data.value }, data.doc)
55
+ end
56
+
57
+ def design_doc
58
+ {
59
+ '_id' => '_design/cities',
60
+ 'language' => 'javascript',
61
+ 'views' => {
62
+ 'by_state' => {
63
+ 'map' => <<-JS
64
+ function (doc, meta) {
65
+ if (doc.type && doc.type == 'city')
66
+ emit(meta.id, doc.state);
67
+ }
68
+ JS
69
+ }
70
+ }
71
+ }
72
+ end
73
+
74
+ 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.1
4
+ version: 0.2.2
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-03-04 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -208,6 +208,7 @@ files:
208
208
  - test/test_utils.rb
209
209
  - test/test_version.rb
210
210
  - test/test_view.rb
211
+ - test/test_view_row.rb
211
212
  homepage: https://github.com/mje113/couchbase-jruby-client
212
213
  licenses:
213
214
  - Apache
@@ -228,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
229
  version: '0'
229
230
  requirements: []
230
231
  rubyforge_project:
231
- rubygems_version: 2.2.2
232
+ rubygems_version: 2.1.9
232
233
  signing_key:
233
234
  specification_version: 4
234
235
  summary: The unofficial jruby client library for use with Couchbase Server.
@@ -262,3 +263,4 @@ test_files:
262
263
  - test/test_utils.rb
263
264
  - test/test_version.rb
264
265
  - test/test_view.rb
266
+ - test/test_view_row.rb