couchbase 3.4.2-arm64-darwin-20 → 3.4.3-arm64-darwin-20

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
  SHA256:
3
- metadata.gz: faa96b8ef64469a07b7665a4d70a8f25cc43003361ee727c403db2514890b96b
4
- data.tar.gz: 43936d9b52ce4a258d24a83111d85b4d19704d54a3ab26d5169a32c1af5d79d8
3
+ metadata.gz: 7781858dae225372665d58fecb6eccadbd09828de8324398143a6233ac2b8a26
4
+ data.tar.gz: 5f9886de965d9fc967e7c241cff4cffd284002e491e8438b42a054dbcacf7571
5
5
  SHA512:
6
- metadata.gz: 6ca2f3e4cd54458cc4b4ee6399d79ba31e716640f1727aaee9f37d8916a3de13f5cdcb8e4a4849fa4c9d50b6bbe982ed8c728351b957fa4f5484ae96d96ba891
7
- data.tar.gz: 712cf52caa8edfeb978c879575f204d44c69f42f9867d1b2232337d6ce103a4407669136ad27619e721c35f0b2802b6530966662b0d0806bc45aad59810ed1b1
6
+ metadata.gz: da37e980f2852accdaa22c27e214b8a1e9cc6edb5fd690a9c57c5b8db3daddb180b40e34fb4acdd25df5b76292f6a5b3fb158edad4d6ce5f27ea2877c08e90fd
7
+ data.tar.gz: 4c2e1d4aa7ae3f60dacd18e2edcf299ceca355c6f4b2a84264bf928df09e418a0484868a93f7166c89ad53d0b048637ccde0e4e33d608351f69102c11198cb93
data/README.md CHANGED
@@ -23,7 +23,7 @@ The library has been tested with MRI 3.0, 3.1 and 3.2. Supported platforms are L
23
23
  Add this line to your application's Gemfile:
24
24
 
25
25
  ```ruby
26
- gem "couchbase", "3.4.2"
26
+ gem "couchbase", "3.4.3"
27
27
  ```
28
28
 
29
29
  And then execute:
@@ -28,7 +28,6 @@ module Couchbase
28
28
  def initialize(username, password)
29
29
  @username = username
30
30
  @password = password
31
- @allowed_sasl_mechanisms = DEFAULT_SASL_MECHANISMS
32
31
  end
33
32
 
34
33
  # Creates a LDAP compatible password authenticator which is INSECURE if not used with TLS.
@@ -386,8 +386,6 @@ module Couchbase
386
386
  raise ArgumentError, "missing connection_string" unless connection_string
387
387
  raise ArgumentError, "missing username" unless credentials[:username]
388
388
  raise ArgumentError, "missing password" unless credentials[:password]
389
-
390
- open_options[:allowed_sasl_mechanisms] = PasswordAuthenticator::DEFAULT_SASL_MECHANISMS
391
389
  else
392
390
  options = args.shift
393
391
  case options
@@ -396,8 +394,6 @@ module Couchbase
396
394
  credentials[:password] = args.shift
397
395
  raise ArgumentError, "missing username" unless credentials[:username]
398
396
  raise ArgumentError, "missing password" unless credentials[:password]
399
-
400
- open_options[:allowed_sasl_mechanisms] = PasswordAuthenticator::DEFAULT_SASL_MECHANISMS
401
397
  when Options::Cluster
402
398
  open_options = options&.to_backend || {}
403
399
  authenticator = options&.authenticator
@@ -15,7 +15,7 @@
15
15
  module Couchbase
16
16
  module ConfigProfiles
17
17
  class Profiles
18
- attr :profiles
18
+ attr_reader :profiles
19
19
 
20
20
  def initialize
21
21
  @profiles = {}
@@ -14,18 +14,25 @@
14
14
 
15
15
  require "json"
16
16
 
17
+ require "couchbase/transcoder_flags"
18
+
17
19
  module Couchbase
18
20
  class JsonTranscoder
19
21
  # @param [Object] document
20
22
  # @return [Array<String, Integer>] pair of encoded document and flags
21
23
  def encode(document)
22
- [JSON.generate(document), (0x02 << 24) | 0x06]
24
+ raise Error::EncodingFailure, "The JsonTranscoder does not support binary data" if document.is_a?(String) && !document.valid_encoding?
25
+
26
+ [JSON.generate(document), TranscoderFlags.new(format: :json, lower_bits: 6).encode]
23
27
  end
24
28
 
25
- # @param [String, nil] blob string of bytes, containing encoded representation of the document
26
- # @param [Integer, :json] _flags bit field, describing how the data encoded
27
- # @return Object decoded document
28
- def decode(blob, _flags)
29
+ # @param [String] blob string of bytes, containing encoded representation of the document
30
+ # @param [Integer, :json] flags bit field, describing how the data encoded
31
+ # @return [Object] decoded document
32
+ def decode(blob, flags)
33
+ format = TranscoderFlags.decode(flags).format
34
+ raise Error::DecodingFailure, "Unable to decode #{format} with the JsonTranscoder" unless format == :json || format.nil?
35
+
29
36
  JSON.parse(blob) unless blob&.empty?
30
37
  end
31
38
  end
Binary file
@@ -14,6 +14,7 @@
14
14
 
15
15
  require "couchbase/management/query_index_manager"
16
16
  require "couchbase/utils/time"
17
+ require "couchbase/errors"
17
18
 
18
19
  module Couchbase
19
20
  module Management
@@ -37,8 +38,18 @@ module Couchbase
37
38
  #
38
39
  # @return [Array<QueryIndex>]
39
40
  #
40
- # @raise [ArgumentError]
41
+ # @raise [Error::InvalidArgument]
41
42
  def get_all_indexes(options = Options::Query::GetAllIndexes.new)
43
+ unless options.scope_name.nil?
44
+ raise Error::InvalidArgument,
45
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
46
+ end
47
+
48
+ unless options.collection_name.nil?
49
+ raise Error::InvalidArgument,
50
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
51
+ end
52
+
42
53
  res = @backend.collection_query_index_get_all(@bucket_name, @scope_name, @collection_name, options.to_backend)
43
54
  res[:indexes].map do |idx|
44
55
  QueryIndex.new do |index|
@@ -64,15 +75,17 @@ module Couchbase
64
75
  #
65
76
  # @return void
66
77
  #
67
- # @raise [ArgumentError]
78
+ # @raise [Error::InvalidArgument]
68
79
  # @raise [Error::IndexExists]
69
80
  def create_index(index_name, fields, options = Options::Query::CreateIndex.new)
70
81
  unless options.scope_name.nil?
71
- raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
82
+ raise Error::InvalidArgument,
83
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
72
84
  end
73
85
 
74
86
  unless options.collection_name.nil?
75
- raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
87
+ raise Error::InvalidArgument,
88
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
76
89
  end
77
90
 
78
91
  @backend.collection_query_index_create(@bucket_name, @scope_name, @collection_name, index_name, fields, options.to_backend)
@@ -84,15 +97,17 @@ module Couchbase
84
97
  #
85
98
  # @return void
86
99
  #
87
- # @raise [ArgumentError]
100
+ # @raise [Error::InvalidArgument]
88
101
  # @raise [Error::IndexExists]
89
102
  def create_primary_index(options = Options::Query::CreatePrimaryIndex.new)
90
103
  unless options.scope_name.nil?
91
- raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
104
+ raise Error::InvalidArgument,
105
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
92
106
  end
93
107
 
94
108
  unless options.collection_name.nil?
95
- raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
109
+ raise Error::InvalidArgument,
110
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
96
111
  end
97
112
 
98
113
  @backend.collection_query_index_create_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
@@ -105,15 +120,17 @@ module Couchbase
105
120
  #
106
121
  # @return void
107
122
  #
108
- # @raise [ArgumentError]
123
+ # @raise [Error::InvalidArgument]
109
124
  # @raise [Error::IndexNotFound]
110
125
  def drop_index(index_name, options = Options::Query::DropIndex.new)
111
126
  unless options.scope_name.nil?
112
- raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
127
+ raise Error::InvalidArgument,
128
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
113
129
  end
114
130
 
115
131
  unless options.collection_name.nil?
116
- raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
132
+ raise Error::InvalidArgument,
133
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
117
134
  end
118
135
 
119
136
  @backend.collection_query_index_drop(@bucket_name, @scope_name, @collection_name, index_name, options.to_backend)
@@ -125,15 +142,17 @@ module Couchbase
125
142
  #
126
143
  # @return void
127
144
  #
128
- # @raise [ArgumentError]
145
+ # @raise [Error::InvalidArgument]
129
146
  # @raise [Error::IndexNotFound]
130
147
  def drop_primary_index(options = Options::Query::DropPrimaryIndex.new)
131
148
  unless options.scope_name.nil?
132
- raise ArgumentError, "Scope name cannot be set in the options when using the Query Index manager at the collection level"
149
+ raise Error::InvalidArgument,
150
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
133
151
  end
134
152
 
135
153
  unless options.collection_name.nil?
136
- raise ArgumentError, "Collection name cannot be set in the options when using the Query Index manager at the collection level"
154
+ raise Error::InvalidArgument,
155
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
137
156
  end
138
157
 
139
158
  @backend.collection_query_index_drop_primary(@bucket_name, @scope_name, @collection_name, options.to_backend)
@@ -145,8 +164,18 @@ module Couchbase
145
164
  #
146
165
  # @return void
147
166
  #
148
- # @raise [ArgumentError]
167
+ # @raise [Error::InvalidArgument]
149
168
  def build_deferred_indexes(options = Options::Query::BuildDeferredIndexes.new)
169
+ unless options.scope_name.nil?
170
+ raise Error::InvalidArgument,
171
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
172
+ end
173
+
174
+ unless options.collection_name.nil?
175
+ raise Error::InvalidArgument,
176
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
177
+ end
178
+
150
179
  @backend.collection_query_index_build_deferred(@bucket_name, @scope_name, @collection_name, options.to_backend)
151
180
  end
152
181
 
@@ -156,9 +185,19 @@ module Couchbase
156
185
  # @param [Integer, #in_milliseconds] timeout the time in milliseconds allowed for the operation to complete
157
186
  # @param [Options::Query::WatchIndexes] options
158
187
  #
159
- # @raise [ArgumentError]
188
+ # @raise [Error::InvalidArgument]
160
189
  # @raise [Error::IndexNotFound]
161
190
  def watch_indexes(index_names, timeout, options = Options::Query::WatchIndexes.new)
191
+ unless options.scope_name.nil?
192
+ raise Error::InvalidArgument,
193
+ "Scope name cannot be set in the options when using the Query Index manager at the collection level"
194
+ end
195
+
196
+ unless options.collection_name.nil?
197
+ raise Error::InvalidArgument,
198
+ "Collection name cannot be set in the options when using the Query Index manager at the collection level"
199
+ end
200
+
162
201
  index_names.append("#primary") if options.watch_primary
163
202
 
164
203
  interval_millis = 50
@@ -22,21 +22,40 @@ module Couchbase
22
22
  module Query
23
23
  # Options for {QueryIndexManager#get_all_indexes}
24
24
  class GetAllIndexes < ::Couchbase::Options::Base
25
+ attr_accessor :scope_name # @return [String, nil]
26
+ attr_accessor :collection_name # @return [String, nil]
27
+
25
28
  # Creates an instance of options for {QueryIndexManager#get_all_indexes}
26
29
  #
30
+ # @param [String, nil] scope_name the name of the scope
31
+ # @param [String, nil] collection_name the name of the collection
32
+ #
27
33
  # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
28
34
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
29
35
  # @param [Hash, nil] client_context the client context data, if set
30
36
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
31
37
  #
32
38
  # @yieldparam [GetAllScopes] self
33
- def initialize(timeout: nil,
39
+ def initialize(scope_name: nil,
40
+ collection_name: nil,
41
+ timeout: nil,
34
42
  retry_strategy: nil,
35
43
  client_context: nil,
36
44
  parent_span: nil)
37
- super
45
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
46
+ @scope_name = scope_name
47
+ @collection_name = collection_name
38
48
  yield self if block_given?
39
49
  end
50
+
51
+ # @api private
52
+ def to_backend
53
+ {
54
+ timeout: Utils::Time.extract_duration(@timeout),
55
+ scope_name: @scope_name,
56
+ collection_name: @collection_name,
57
+ }
58
+ end
40
59
  end
41
60
 
42
61
  # Options for {QueryIndexManager#create_index}
@@ -102,6 +121,7 @@ module Couchbase
102
121
  attr_accessor :ignore_if_exists # @return [Boolean]
103
122
  attr_accessor :num_replicas # @return [Integer, nil]
104
123
  attr_accessor :deferred # @return [Boolean]
124
+ attr_accessor :index_name # @return [String. nil]
105
125
  attr_accessor :scope_name # @return [String, nil]
106
126
  attr_accessor :collection_name # @return [String, nil]
107
127
 
@@ -110,6 +130,7 @@ module Couchbase
110
130
  # @param [Boolean] ignore_if_exists do not raise error if the index already exist
111
131
  # @param [Integer] num_replicas the number of replicas that this index should have
112
132
  # @param [Boolean] deferred whether the index should be created as a deferred index.
133
+ # @param [String, nil] index_name the custom name of the primary index.
113
134
  # @param [String, nil] scope_name the name of the scope
114
135
  # @param [String, nil] collection_name the name of the collection
115
136
  #
@@ -122,6 +143,7 @@ module Couchbase
122
143
  def initialize(ignore_if_exists: false,
123
144
  num_replicas: nil,
124
145
  deferred: false,
146
+ index_name: nil,
125
147
  scope_name: nil,
126
148
  collection_name: nil,
127
149
  timeout: nil,
@@ -132,6 +154,7 @@ module Couchbase
132
154
  @ignore_if_exists = ignore_if_exists
133
155
  @num_replicas = num_replicas
134
156
  @deferred = deferred
157
+ @index_name = index_name
135
158
  @scope_name = scope_name
136
159
  @collection_name = collection_name
137
160
  yield self if block_given?
@@ -144,6 +167,7 @@ module Couchbase
144
167
  ignore_if_exists: @ignore_if_exists,
145
168
  deferred: @deferred,
146
169
  num_replicas: @num_replicas,
170
+ index_name: @index_name,
147
171
  scope_name: @scope_name,
148
172
  collection_name: @collection_name,
149
173
  }
@@ -238,7 +262,12 @@ module Couchbase
238
262
 
239
263
  # Options for {QueryIndexManager#build_deferred_indexes}
240
264
  class BuildDeferredIndexes < ::Couchbase::Options::Base
265
+ attr_accessor :scope_name # @return [String, nil]
266
+ attr_accessor :collection_name # @return [String, nil]
267
+
241
268
  # Creates an instance of options for {QueryIndexManager#build_deferred_indexes}
269
+ # @param [String, nil] scope_name the name of the scope
270
+ # @param [String, nil] collection_name the name of the collection
242
271
  #
243
272
  # @param [Integer, #in_milliseconds, nil] timeout the time in milliseconds allowed for the operation to complete
244
273
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
@@ -246,33 +275,55 @@ module Couchbase
246
275
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
247
276
  #
248
277
  # @yieldparam [GetAllScopes] self
249
- def initialize(timeout: nil,
278
+ def initialize(scope_name: nil,
279
+ collection_name: nil,
280
+ timeout: nil,
250
281
  retry_strategy: nil,
251
282
  client_context: nil,
252
283
  parent_span: nil)
253
- super
284
+ super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
285
+ @scope_name = scope_name
286
+ @collection_name = collection_name
254
287
  yield self if block_given?
255
288
  end
289
+
290
+ # @api private
291
+ def to_backend
292
+ {
293
+ timeout: Utils::Time.extract_duration(@timeout),
294
+ scope_name: @scope_name,
295
+ collection_name: @collection_name,
296
+ }
297
+ end
256
298
  end
257
299
 
258
300
  # Options for {QueryIndexManager#watch_indexes}
259
301
  class WatchIndexes < ::Couchbase::Options::Base
260
302
  attr_accessor :watch_primary # @return [Boolean]
303
+ attr_accessor :scope_name # @return [String, nil]
304
+ attr_accessor :collection_name # @return [String, nil]
261
305
 
262
306
  # Creates an instance of options for {QueryIndexManager#watch_indexes}
263
307
  #
264
308
  # @param [Boolean] watch_primary whether or not to watch the primary index
309
+ # @param [String, nil] scope_name the name of the scope
310
+ # @param [String, nil] collection_name the name of the collection
311
+ #
265
312
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
266
313
  # @param [Hash, nil] client_context the client context data, if set
267
314
  # @param [Span, nil] parent_span if set holds the parent span, that should be used for this request
268
315
  #
269
316
  # @yieldparam [GetAllScopes] self
270
317
  def initialize(watch_primary: false,
318
+ scope_name: nil,
319
+ collection_name: nil,
271
320
  retry_strategy: nil,
272
321
  client_context: nil,
273
322
  parent_span: nil)
274
323
  super(timeout: nil, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
275
324
  @watch_primary = watch_primary
325
+ @scope_name = scope_name
326
+ @collection_name = collection_name
276
327
  yield self if block_given?
277
328
  end
278
329
 
@@ -280,6 +331,8 @@ module Couchbase
280
331
  def to_backend
281
332
  {
282
333
  watch_primary: @watch_primary,
334
+ scope_name: @scope_name,
335
+ collection_name: @collection_name,
283
336
  }
284
337
  end
285
338
  end
@@ -343,6 +396,10 @@ module Couchbase
343
396
  #
344
397
  # @raise [ArgumentError]
345
398
  def get_all_indexes(bucket_name, options = GetAllIndexOptions.new)
399
+ unless options.scope_name.nil? && options.collection_name.nil?
400
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
401
+ end
402
+
346
403
  res = @backend.query_index_get_all(bucket_name, options.to_backend)
347
404
  res[:indexes].map do |idx|
348
405
  QueryIndex.new do |index|
@@ -436,10 +493,14 @@ module Couchbase
436
493
  # @param [String] bucket_name name of the bucket
437
494
  # @param [Options::Query::BuildDeferredIndexes] options
438
495
  #
439
- # @return void
496
+ # @return
440
497
  #
441
498
  # @raise [ArgumentError]
442
499
  def build_deferred_indexes(bucket_name, options = Options::Query::BuildDeferredIndexes.new)
500
+ unless options.scope_name.nil? && options.collection_name.nil?
501
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
502
+ end
503
+
443
504
  @backend.query_index_build_deferred(bucket_name, options.to_backend)
444
505
  end
445
506
 
@@ -453,6 +514,10 @@ module Couchbase
453
514
  # @raise [ArgumentError]
454
515
  # @raise [Error::IndexNotFound]
455
516
  def watch_indexes(bucket_name, index_names, timeout, options = Options::Query::WatchIndexes.new)
517
+ unless options.scope_name.nil? && options.collection_name.nil?
518
+ warn "The attributes 'scope_name' and 'collection_name' have been deprecated. Use 'collection.query_indexes' instead"
519
+ end
520
+
456
521
  index_names.append("#primary") if options.watch_primary
457
522
 
458
523
  interval_millis = 50
@@ -0,0 +1,37 @@
1
+ # Copyright 2023. Couchbase, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "couchbase/transcoder_flags"
16
+
17
+ module Couchbase
18
+ class RawBinaryTranscoder
19
+ # @param [String] document
20
+ # @return [Array<String, Integer>] pair of encoded document and flags
21
+ def encode(document)
22
+ raise Error::EncodingFailure, "Only binary data supported by RawBinaryTranscoder" unless document.is_a?(String)
23
+
24
+ [document, TranscoderFlags.new(format: :binary).encode]
25
+ end
26
+
27
+ # @param [String] blob string of bytes, containing encoded representation of the document
28
+ # @param [Integer] flags bit field, describing how the data encoded
29
+ # @return [String] decoded document
30
+ def decode(blob, flags)
31
+ format = TranscoderFlags.decode(flags).format
32
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawBinaryTranscoder" unless format == :binary || format.nil?
33
+
34
+ blob
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,38 @@
1
+ # Copyright 2023. Couchbase, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "couchbase/transcoder_flags"
16
+ require "couchbase/errors"
17
+
18
+ module Couchbase
19
+ class RawJsonTranscoder
20
+ # @param [String] document
21
+ # @return [Array<String, Integer>] pair of encoded document and flags
22
+ def encode(document)
23
+ raise Error::EncodingFailure, "Only String and binary data supported by RawJsonTranscoder" unless document.is_a?(String)
24
+
25
+ [document, TranscoderFlags.new(format: :json).encode]
26
+ end
27
+
28
+ # @param [String] blob string of bytes, containing encoded representation of the document
29
+ # @param [Integer] flags bit field, describing how the data encoded
30
+ # @return [String] decoded document
31
+ def decode(blob, flags)
32
+ format = TranscoderFlags.decode(flags).format
33
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawJsonTranscoder" unless format == :json || format.nil?
34
+
35
+ blob
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,40 @@
1
+ # Copyright 2023. Couchbase, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require "couchbase/transcoder_flags"
16
+ require "couchbase/errors"
17
+
18
+ module Couchbase
19
+ class RawStringTranscoder
20
+ # @param [String] document
21
+ # @return [Array<String, Integer>] pair of encoded document and flags
22
+ def encode(document)
23
+ unless document.is_a?(String) && document.valid_encoding?
24
+ raise Error::EncodingFailure, "Only String data supported by RawStringTranscoder"
25
+ end
26
+
27
+ [document, TranscoderFlags.new(format: :string).encode]
28
+ end
29
+
30
+ # @param [String] blob string of bytes, containing encoded representation of the document
31
+ # @param [Integer] flags bit field, describing how the data encoded
32
+ # @return [String] decoded document
33
+ def decode(blob, flags)
34
+ format = TranscoderFlags.decode(flags).format
35
+ raise Error::DecodingFailure, "Unable to decode #{format} with the RawStringTranscoder" unless format == :string || format.nil?
36
+
37
+ blob
38
+ end
39
+ end
40
+ end
@@ -1225,6 +1225,11 @@ module Couchbase
1225
1225
 
1226
1226
  # @return [Array<Integer>] the positions of the term within any elements.
1227
1227
  attr_accessor :array_positions
1228
+
1229
+ # @yieldparam [SearchRowLocation] self
1230
+ def initialize
1231
+ yield self if block_given?
1232
+ end
1228
1233
  end
1229
1234
 
1230
1235
  class SearchRowLocations
@@ -0,0 +1,62 @@
1
+ # Copyright 2023. Couchbase, Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Couchbase
16
+ # @api private
17
+ class TranscoderFlags
18
+ FORMAT_MAP = {
19
+ reserved: 0,
20
+ private: 1,
21
+ json: 2,
22
+ binary: 3,
23
+ string: 4,
24
+ }.freeze
25
+ INV_FORMAT_MAP = FORMAT_MAP.invert.freeze
26
+
27
+ COMPRESSION_MAP = {none: 0}.freeze
28
+ INV_COMPRESSION_MAP = COMPRESSION_MAP.invert
29
+
30
+ attr_reader :format
31
+ attr_reader :compression
32
+ attr_reader :lower_bits
33
+
34
+ def initialize(format:, compression: :none, lower_bits: 0)
35
+ @format = format
36
+ @compression = compression
37
+ @lower_bits = lower_bits
38
+ end
39
+
40
+ def self.decode(flags)
41
+ return TranscoderFlags.new(format: flags) if flags.is_a?(Symbol)
42
+
43
+ common_flags = flags >> 24
44
+ lower_bits = flags & 0x00ffff
45
+
46
+ return TranscoderFlags.new(format: nil, lower_bits: lower_bits) if common_flags.zero?
47
+
48
+ compression_bits = common_flags >> 5
49
+ format_bits = common_flags & 0x0f
50
+ TranscoderFlags.new(
51
+ format: INV_FORMAT_MAP[format_bits],
52
+ compression: INV_COMPRESSION_MAP[compression_bits],
53
+ lower_bits: lower_bits
54
+ )
55
+ end
56
+
57
+ def encode
58
+ common_flags = (COMPRESSION_MAP[@compression] << 5) | FORMAT_MAP[@format]
59
+ (common_flags << 24) | @lower_bits
60
+ end
61
+ end
62
+ end
@@ -19,5 +19,5 @@ module Couchbase
19
19
  # $ ruby -rcouchbase -e 'pp Couchbase::VERSION'
20
20
  # {:sdk=>"3.4.0", :ruby_abi=>"3.1.0", :revision=>"416fe68e6029ec8a4c40611cf6e6b30d3b90d20f"}
21
21
  VERSION = {} unless defined?(VERSION) # rubocop:disable Style/MutableConstant
22
- VERSION.update(:sdk => "3.4.2".freeze)
22
+ VERSION.update(:sdk => "3.4.3".freeze)
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: couchbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.2
4
+ version: 3.4.3
5
5
  platform: arm64-darwin-20
6
6
  authors:
7
7
  - Sergey Avseyev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-12 00:00:00.000000000 Z
11
+ date: 2023-05-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modern SDK for Couchbase Server
14
14
  email:
@@ -56,9 +56,13 @@ files:
56
56
  - lib/couchbase/options.rb
57
57
  - lib/couchbase/query_options.rb
58
58
  - lib/couchbase/railtie.rb
59
+ - lib/couchbase/raw_binary_transcoder.rb
60
+ - lib/couchbase/raw_json_transcoder.rb
61
+ - lib/couchbase/raw_string_transcoder.rb
59
62
  - lib/couchbase/scope.rb
60
63
  - lib/couchbase/search_options.rb
61
64
  - lib/couchbase/subdoc.rb
65
+ - lib/couchbase/transcoder_flags.rb
62
66
  - lib/couchbase/utils.rb
63
67
  - lib/couchbase/utils/generic_logger_adapter.rb
64
68
  - lib/couchbase/utils/stdlib_logger_adapter.rb
@@ -73,9 +77,9 @@ metadata:
73
77
  homepage_uri: https://docs.couchbase.com/ruby-sdk/current/hello-world/start-using-sdk.html
74
78
  bug_tracker_uri: https://couchbase.com/issues/browse/RCBC
75
79
  mailing_list_uri: https://forums.couchbase.com/c/ruby-sdk
76
- source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.2
77
- changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.2
78
- documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.2/index.html
80
+ source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.3
81
+ changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.3
82
+ documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.3/index.html
79
83
  github_repo: ssh://github.com/couchbase/couchbase-ruby-client
80
84
  rubygems_mfa_required: 'true'
81
85
  post_install_message: