couchbase-jruby-client 0.1.0-java → 0.1.5-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 +4 -4
- data/.jrubyrc +722 -0
- data/.ruby-version +1 -1
- data/README.md +12 -90
- data/couchbase-jruby-client.gemspec +6 -6
- data/lib/couchbase/async.rb +18 -0
- data/lib/couchbase/bucket.rb +90 -180
- data/lib/couchbase/constants.rb +17 -0
- data/lib/couchbase/design_doc.rb +83 -0
- data/lib/couchbase/error.rb +31 -0
- data/lib/couchbase/operations/arithmetic.rb +17 -0
- data/lib/couchbase/operations/delete.rb +17 -0
- data/lib/couchbase/operations/design_docs.rb +99 -0
- data/lib/couchbase/operations/get.rb +73 -67
- data/lib/couchbase/operations/stats.rb +28 -1
- data/lib/couchbase/operations/store.rb +114 -97
- data/lib/couchbase/operations/touch.rb +49 -19
- data/lib/couchbase/operations/unlock.rb +209 -0
- data/lib/couchbase/operations/utils.rb +22 -10
- data/lib/couchbase/operations.rb +21 -0
- data/lib/couchbase/query.rb +92 -0
- data/lib/couchbase/result.rb +18 -1
- data/lib/couchbase/transcoder.rb +36 -42
- data/lib/couchbase/version.rb +18 -1
- data/lib/couchbase/view.rb +30 -172
- data/lib/couchbase/view_row.rb +38 -98
- data/lib/couchbase.rb +74 -72
- data/test/profile/.jrubyrc +722 -0
- data/test/profile/Gemfile +5 -5
- data/test/profile/benchmark.rb +106 -124
- data/test/profile/profile.rb +59 -0
- data/test/setup.rb +10 -145
- data/test/test_arithmetic.rb +54 -77
- data/test/test_async.rb +74 -102
- data/test/test_bucket.rb +74 -60
- data/test/test_cas.rb +10 -23
- data/test/test_couchbase.rb +11 -3
- data/test/test_delete.rb +41 -43
- data/test/test_design_docs.rb +62 -0
- data/test/test_errors.rb +9 -18
- data/test/test_format.rb +21 -31
- data/test/test_get.rb +107 -151
- data/test/test_query.rb +23 -0
- data/test/test_stats.rb +9 -24
- data/test/test_store.rb +52 -65
- data/test/test_timer.rb +4 -12
- data/test/test_touch.rb +26 -33
- data/test/test_unlock.rb +47 -78
- data/test/test_utils.rb +2 -11
- data/test/test_version.rb +5 -14
- data/test/test_view.rb +87 -0
- metadata +27 -14
- data/lib/couchbase/jruby/couchbase_client.rb +0 -22
- data/lib/couchbase/jruby/future.rb +0 -8
data/test/test_view.rb
ADDED
@@ -0,0 +1,87 @@
|
|
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 TestView < MiniTest::Test
|
21
|
+
|
22
|
+
def setup
|
23
|
+
@path = '_design/users/_view/by_age'
|
24
|
+
cb.save_design_doc(design_doc)
|
25
|
+
{ bob: 32, frank: 25, sam: 42, fred: 21 }.each_pair do |name, age|
|
26
|
+
cb.set(name, { type: 'user', name: name, age: age })
|
27
|
+
end
|
28
|
+
@view = Couchbase::View.new(cb, @path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_initialize
|
32
|
+
assert_equal 'users', @view.design_doc
|
33
|
+
assert_equal 'by_age', @view.name
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_simple_fetch
|
37
|
+
assert results = @view.fetch
|
38
|
+
assert results.is_a?(Couchbase::View::ArrayWithTotalRows)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_fetch_without_stale
|
42
|
+
assert results = @view.fetch(stale: false)
|
43
|
+
assert results.first.is_a?(Couchbase::ViewRow)
|
44
|
+
assert results.first.doc.nil?
|
45
|
+
assert_equal 4, results.total_rows
|
46
|
+
results.each do |result|
|
47
|
+
%w(bob frank sam fred).include?(result.key)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_fetch_with_docs
|
52
|
+
assert results = @view.fetch(stale: false, include_docs: true)
|
53
|
+
assert results.is_a?(Array)
|
54
|
+
assert results.first.doc.is_a?(Hash)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_fetch_with_block
|
58
|
+
refute @view.fetch(stale: false, include_docs: true) { |row|
|
59
|
+
assert row.is_a?(Couchbase::ViewRow)
|
60
|
+
assert row.doc['name'].is_a?(String)
|
61
|
+
assert row.doc['age'].is_a?(Fixnum)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_design_doc_access
|
66
|
+
assert results = cb.design_docs['users'].by_age.to_a
|
67
|
+
assert results.first.is_a?(Couchbase::ViewRow)
|
68
|
+
end
|
69
|
+
|
70
|
+
def design_doc
|
71
|
+
{
|
72
|
+
'_id' => '_design/users',
|
73
|
+
'language' => 'javascript',
|
74
|
+
'views' => {
|
75
|
+
'by_age' => {
|
76
|
+
'map' => <<-JS
|
77
|
+
function (doc, meta) {
|
78
|
+
if (doc.type && doc.type == 'user')
|
79
|
+
emit(meta.id, doc.age);
|
80
|
+
}
|
81
|
+
JS
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
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.1.
|
4
|
+
version: 0.1.5
|
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
|
+
date: 2013-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -25,17 +25,17 @@ dependencies:
|
|
25
25
|
prerelease: false
|
26
26
|
type: :runtime
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: thread_safe
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.2
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
35
35
|
requirements:
|
36
36
|
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
38
|
+
version: 0.1.2
|
39
39
|
prerelease: false
|
40
40
|
type: :runtime
|
41
41
|
- !ruby/object:Gem::Dependency
|
@@ -81,21 +81,21 @@ dependencies:
|
|
81
81
|
prerelease: false
|
82
82
|
type: :development
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: jrjackson
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ~>
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 0.2.3
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
91
91
|
requirements:
|
92
|
-
- -
|
92
|
+
- - ~>
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
94
|
+
version: 0.2.3
|
95
95
|
prerelease: false
|
96
96
|
type: :development
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: active_support
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - '>='
|
@@ -116,6 +116,7 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
|
+
- .jrubyrc
|
119
120
|
- .ruby-version
|
120
121
|
- Gemfile
|
121
122
|
- LICENSE.txt
|
@@ -129,17 +130,19 @@ files:
|
|
129
130
|
- lib/couchbase/bucket.rb
|
130
131
|
- lib/couchbase/cluster.rb
|
131
132
|
- lib/couchbase/constants.rb
|
133
|
+
- lib/couchbase/design_doc.rb
|
132
134
|
- lib/couchbase/error.rb
|
133
|
-
- lib/couchbase/jruby/couchbase_client.rb
|
134
|
-
- lib/couchbase/jruby/future.rb
|
135
135
|
- lib/couchbase/operations.rb
|
136
136
|
- lib/couchbase/operations/arithmetic.rb
|
137
137
|
- lib/couchbase/operations/delete.rb
|
138
|
+
- lib/couchbase/operations/design_docs.rb
|
138
139
|
- lib/couchbase/operations/get.rb
|
139
140
|
- lib/couchbase/operations/stats.rb
|
140
141
|
- lib/couchbase/operations/store.rb
|
141
142
|
- lib/couchbase/operations/touch.rb
|
143
|
+
- lib/couchbase/operations/unlock.rb
|
142
144
|
- lib/couchbase/operations/utils.rb
|
145
|
+
- lib/couchbase/query.rb
|
143
146
|
- lib/couchbase/result.rb
|
144
147
|
- lib/couchbase/transcoder.rb
|
145
148
|
- lib/couchbase/utils.rb
|
@@ -158,8 +161,10 @@ files:
|
|
158
161
|
- lib/jars/spymemcached-2.10.0-sources.jar
|
159
162
|
- lib/jars/spymemcached-2.10.0.jar
|
160
163
|
- test/profile/.gitignore
|
164
|
+
- test/profile/.jrubyrc
|
161
165
|
- test/profile/Gemfile
|
162
166
|
- test/profile/benchmark.rb
|
167
|
+
- test/profile/profile.rb
|
163
168
|
- test/setup.rb
|
164
169
|
- test/test_arithmetic.rb
|
165
170
|
- test/test_async.rb
|
@@ -168,9 +173,11 @@ files:
|
|
168
173
|
- test/test_couchbase.rb
|
169
174
|
- test/test_couchbase_rails_cache_store.rb
|
170
175
|
- test/test_delete.rb
|
176
|
+
- test/test_design_docs.rb
|
171
177
|
- test/test_errors.rb
|
172
178
|
- test/test_format.rb
|
173
179
|
- test/test_get.rb
|
180
|
+
- test/test_query.rb
|
174
181
|
- test/test_stats.rb
|
175
182
|
- test/test_store.rb
|
176
183
|
- test/test_timer.rb
|
@@ -178,6 +185,7 @@ files:
|
|
178
185
|
- test/test_unlock.rb
|
179
186
|
- test/test_utils.rb
|
180
187
|
- test/test_version.rb
|
188
|
+
- test/test_view.rb
|
181
189
|
homepage: https://github.com/mje113/couchbase-jruby-client
|
182
190
|
licenses:
|
183
191
|
- Apache
|
@@ -198,14 +206,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
206
|
version: '0'
|
199
207
|
requirements: []
|
200
208
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.1.
|
209
|
+
rubygems_version: 2.1.9
|
202
210
|
signing_key:
|
203
211
|
specification_version: 4
|
204
212
|
summary: The unofficial jruby client library for use with Couchbase Server.
|
205
213
|
test_files:
|
206
214
|
- test/profile/.gitignore
|
215
|
+
- test/profile/.jrubyrc
|
207
216
|
- test/profile/Gemfile
|
208
217
|
- test/profile/benchmark.rb
|
218
|
+
- test/profile/profile.rb
|
209
219
|
- test/setup.rb
|
210
220
|
- test/test_arithmetic.rb
|
211
221
|
- test/test_async.rb
|
@@ -214,9 +224,11 @@ test_files:
|
|
214
224
|
- test/test_couchbase.rb
|
215
225
|
- test/test_couchbase_rails_cache_store.rb
|
216
226
|
- test/test_delete.rb
|
227
|
+
- test/test_design_docs.rb
|
217
228
|
- test/test_errors.rb
|
218
229
|
- test/test_format.rb
|
219
230
|
- test/test_get.rb
|
231
|
+
- test/test_query.rb
|
220
232
|
- test/test_stats.rb
|
221
233
|
- test/test_store.rb
|
222
234
|
- test/test_timer.rb
|
@@ -224,3 +236,4 @@ test_files:
|
|
224
236
|
- test/test_unlock.rb
|
225
237
|
- test/test_utils.rb
|
226
238
|
- test/test_version.rb
|
239
|
+
- test/test_view.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
module Couchbase
|
2
|
-
module Jruby
|
3
|
-
class CouchbaseClient < Java::ComCouchbaseClient::CouchbaseClient
|
4
|
-
|
5
|
-
# Futures
|
6
|
-
%w(add set append asyncCAS asyncDecr asyncGet asyncGetAndTouch asyncGetBulk
|
7
|
-
asyncGets asyncIncr delete flush prepend replace set touch).each do |op|
|
8
|
-
define_method(op) do |*|
|
9
|
-
super
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def get(*)
|
14
|
-
super
|
15
|
-
end
|
16
|
-
|
17
|
-
VALUE_OPS = %w(
|
18
|
-
|
19
|
-
).freeze
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|