couchbase 3.4.1-arm64-darwin-20 → 3.4.2-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: 0c66775f9944c58be71025321c4cd11d33068f47e723ebc3f1116172d4d1b0c2
4
- data.tar.gz: e8cf7b5a11ac1ca879c34d89f1bc063e67e8cfd9ed8de5a435316aea9e488a74
3
+ metadata.gz: faa96b8ef64469a07b7665a4d70a8f25cc43003361ee727c403db2514890b96b
4
+ data.tar.gz: 43936d9b52ce4a258d24a83111d85b4d19704d54a3ab26d5169a32c1af5d79d8
5
5
  SHA512:
6
- metadata.gz: 49a1c6a75d971fb8a79128dfea4212425b8f5c9cb1304c12e34c23dd8587b957826146829ecb031afaabce5b82f0a79e14f9127ffa02e5be5433dde469d662d4
7
- data.tar.gz: 491c19def9f8fbc4e124064150766c3c7be643d8f628d68eea9f4b702586ef6fc61e87820e3418635b245554f28078e9c455b2b472270e7eb415f617ce0e4157
6
+ metadata.gz: 6ca2f3e4cd54458cc4b4ee6399d79ba31e716640f1727aaee9f37d8916a3de13f5cdcb8e4a4849fa4c9d50b6bbe982ed8c728351b957fa4f5484ae96d96ba891
7
+ data.tar.gz: 712cf52caa8edfeb978c879575f204d44c69f42f9867d1b2232337d6ce103a4407669136ad27619e721c35f0b2802b6530966662b0d0806bc45aad59810ed1b1
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.1"
26
+ gem "couchbase", "3.4.2"
27
27
  ```
28
28
 
29
29
  And then execute:
@@ -139,7 +139,7 @@ Now the API reference is accessible using a web browser (where `VERSION` is the
139
139
 
140
140
  The gem is available as open source under the terms of the [Apache2 License](https://opensource.org/licenses/Apache-2.0).
141
141
 
142
- Copyright 2011-2021 Couchbase, Inc.
142
+ Copyright 2011-Present Couchbase, Inc.
143
143
 
144
144
  Licensed under the Apache License, Version 2.0 (the "License");
145
145
  you may not use this file except in compliance with the License.
@@ -32,13 +32,13 @@ module Couchbase
32
32
 
33
33
  # Connect to the Couchbase cluster
34
34
  #
35
- # @overload connect(connection_string, options)
36
- # @param [String] connection_string connection string used to locate the Couchbase Cluster
35
+ # @overload connect(connection_string_or_config, options)
36
+ # @param [String, Configuration] connection_string_or_config connection string used to locate the Couchbase Cluster
37
37
  # @param [Options::Cluster] options custom options when creating the cluster connection
38
38
  #
39
- # @overload connect(connection_string, username, password, options)
39
+ # @overload connect(connection_string_or_config, username, password, options)
40
40
  # Shortcut for {PasswordAuthenticator}
41
- # @param [String] connection_string connection string used to locate the Couchbase Cluster
41
+ # @param [String] connection_string_or_config connection string used to locate the Couchbase Cluster
42
42
  # @param [String] username name of the user
43
43
  # @param [String] password password of the user
44
44
  # @param [Options::Cluster, nil] options custom options when creating the cluster connection
@@ -62,12 +62,16 @@ module Couchbase
62
62
  # @see https://docs.couchbase.com/server/current/manage/manage-security/configure-client-certificates.html
63
63
  #
64
64
  # @return [Cluster]
65
- def self.connect(connection_string, *options)
66
- regexp = /^((couchbases?|http):\/\/.*)$/i
67
- if regexp.match?(connection_string) || !connection_string.include?("://")
68
- Cluster.new(connection_string, *options)
65
+ def self.connect(connection_string_or_config, *options)
66
+ connection_string = if connection_string_or_config.is_a?(Configuration)
67
+ connection_string_or_config.connection_string
68
+ else
69
+ connection_string_or_config
70
+ end
71
+ if connection_string =~ /\Acouchbases?:\/\/.*\z/i || !connection_string.include?("://")
72
+ Cluster.new(connection_string_or_config, *options)
69
73
  else
70
- ClusterRegistry.instance.connect(connection_string, *options)
74
+ ClusterRegistry.instance.connect(connection_string_or_config, *options)
71
75
  end
72
76
  end
73
77
 
@@ -26,9 +26,14 @@ module Couchbase
26
26
  @handlers = {}
27
27
  end
28
28
 
29
- def connect(connection_string, *options)
29
+ def connect(connection_string_or_config, *options)
30
+ connection_string = if connection_string_or_config.is_a?(Configuration)
31
+ connection_string_or_config.connection_string
32
+ else
33
+ connection_string_or_config
34
+ end
30
35
  @handlers.each do |regexp, cluster_class|
31
- return cluster_class.connect(connection_string, *options) if regexp.match?(connection_string)
36
+ return cluster_class.connect(connection_string_or_config, *options) if regexp.match?(connection_string)
32
37
  end
33
38
  raise(Error::FeatureNotAvailable, "Connection string '#{connection_string}' not supported.")
34
39
  end
@@ -33,10 +33,9 @@ module Couchbase
33
33
  private
34
34
 
35
35
  def load_configuration(settings)
36
- configuration = settings.with_indifferent_access
37
- @connection_string = configuration[:connection_string]
38
- @username = configuration[:username]
39
- @password = configuration[:password]
36
+ @connection_string = settings[:connection_string] || settings["connection_string"]
37
+ @username = settings[:username] || settings["username"]
38
+ @password = settings[:password] || settings["password"]
40
39
  end
41
40
 
42
41
  def load_yaml(path, environment)
Binary file
@@ -1029,10 +1029,38 @@ module Couchbase
1029
1029
  # Options for {BinaryCollection#append}
1030
1030
  class Append < Base
1031
1031
  attr_accessor :cas # @return [Integer]
1032
+ attr_accessor :durability_level # @return [Symbol]
1033
+ attr_accessor :replicate_to # @return [Symbol]
1034
+ attr_accessor :persist_to # @return [Symbol]
1032
1035
 
1033
1036
  # Creates an instance of options for {BinaryCollection#append}
1034
1037
  #
1035
1038
  # @param [Integer] cas The default CAS used (0 means no CAS in this context)
1039
+ # @param [Symbol] durability_level level of durability
1040
+ # +:none+::
1041
+ # no enhanced durability required for the mutation
1042
+ # +:majority+::
1043
+ # the mutation must be replicated to a majority of the Data Service nodes
1044
+ # (that is, held in the memory allocated to the bucket)
1045
+ # +:majority_and_persist_to_active+::
1046
+ # The mutation must be replicated to a majority of the Data Service nodes.
1047
+ # Additionally, it must be persisted (that is, written and synchronised to disk) on the
1048
+ # node hosting the active partition (vBucket) for the data.
1049
+ # +:persist_to_majority+::
1050
+ # The mutation must be persisted to a majority of the Data Service nodes.
1051
+ # Accordingly, it will be written to disk on those nodes.
1052
+ # @param [Symbol] replicate_to number of nodes to replicate
1053
+ # +:none+:: do not apply any replication requirements.
1054
+ # +:one+:: wait for replication to at least one node.
1055
+ # +:two+:: wait for replication to at least two nodes.
1056
+ # +:three+:: wait for replication to at least three nodes.
1057
+ # @param [Symbol] persist_to number of nodes to persist
1058
+ # +:none+:: do not apply any persistence requirements.
1059
+ # +:active+:: wait for persistence to active node
1060
+ # +:one+:: wait for persistence to at least one node.
1061
+ # +:two+:: wait for persistence to at least two nodes.
1062
+ # +:three+:: wait for persistence to at least three nodes.
1063
+ # +:four+:: wait for persistence to four nodes (active and replicas).
1036
1064
  #
1037
1065
  # @param [Integer, #in_milliseconds, nil] timeout
1038
1066
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
@@ -1041,12 +1069,23 @@ module Couchbase
1041
1069
  #
1042
1070
  # @yieldparam [Append] self
1043
1071
  def initialize(cas: nil,
1072
+ durability_level: :none,
1073
+ replicate_to: :none,
1074
+ persist_to: :none,
1044
1075
  timeout: nil,
1045
1076
  retry_strategy: nil,
1046
1077
  client_context: nil,
1047
1078
  parent_span: nil)
1048
1079
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
1049
1080
  @cas = cas
1081
+
1082
+ if durability_level != :none && (replicate_to != :none || persist_to != :none)
1083
+ raise ArgumentError, "durability_level conflicts with replicate_to and persist_to options"
1084
+ end
1085
+
1086
+ @durability_level = durability_level
1087
+ @replicate_to = replicate_to
1088
+ @persist_to = persist_to
1050
1089
  yield self if block_given?
1051
1090
  end
1052
1091
 
@@ -1055,6 +1094,9 @@ module Couchbase
1055
1094
  {
1056
1095
  timeout: Utils::Time.extract_duration(@timeout),
1057
1096
  cas: @cas,
1097
+ durability_level: @durability_level,
1098
+ persist_to: @persist_to,
1099
+ replicate_to: @replicate_to,
1058
1100
  }
1059
1101
  end
1060
1102
 
@@ -1064,12 +1106,39 @@ module Couchbase
1064
1106
 
1065
1107
  # Options for {BinaryCollection#prepend}
1066
1108
  class Prepend < Base
1067
- # @return [Integer] The default CAS used (0 means no CAS in this context)
1068
- attr_accessor :cas
1109
+ attr_accessor :cas # @return [Integer]
1110
+ attr_accessor :durability_level # @return [Symbol]
1111
+ attr_accessor :replicate_to # @return [Symbol]
1112
+ attr_accessor :persist_to # @return [Symbol]
1069
1113
 
1070
1114
  # Creates an instance of options for {BinaryCollection#prepend}
1071
1115
  #
1072
1116
  # @param [Integer] cas The default CAS used (0 means no CAS in this context)
1117
+ # @param [Symbol] durability_level level of durability
1118
+ # +:none+::
1119
+ # no enhanced durability required for the mutation
1120
+ # +:majority+::
1121
+ # the mutation must be replicated to a majority of the Data Service nodes
1122
+ # (that is, held in the memory allocated to the bucket)
1123
+ # +:majority_and_persist_to_active+::
1124
+ # The mutation must be replicated to a majority of the Data Service nodes.
1125
+ # Additionally, it must be persisted (that is, written and synchronised to disk) on the
1126
+ # node hosting the active partition (vBucket) for the data.
1127
+ # +:persist_to_majority+::
1128
+ # The mutation must be persisted to a majority of the Data Service nodes.
1129
+ # Accordingly, it will be written to disk on those nodes.
1130
+ # @param [Symbol] replicate_to number of nodes to replicate
1131
+ # +:none+:: do not apply any replication requirements.
1132
+ # +:one+:: wait for replication to at least one node.
1133
+ # +:two+:: wait for replication to at least two nodes.
1134
+ # +:three+:: wait for replication to at least three nodes.
1135
+ # @param [Symbol] persist_to number of nodes to persist
1136
+ # +:none+:: do not apply any persistence requirements.
1137
+ # +:active+:: wait for persistence to active node
1138
+ # +:one+:: wait for persistence to at least one node.
1139
+ # +:two+:: wait for persistence to at least two nodes.
1140
+ # +:three+:: wait for persistence to at least three nodes.
1141
+ # +:four+:: wait for persistence to four nodes (active and replicas).
1073
1142
  #
1074
1143
  # @param [Integer, #in_milliseconds, nil] timeout
1075
1144
  # @param [Proc, nil] retry_strategy the custom retry strategy, if set
@@ -1078,12 +1147,23 @@ module Couchbase
1078
1147
  #
1079
1148
  # @yieldparam [Prepend] self
1080
1149
  def initialize(cas: nil,
1150
+ durability_level: :none,
1151
+ replicate_to: :none,
1152
+ persist_to: :none,
1081
1153
  timeout: nil,
1082
1154
  retry_strategy: nil,
1083
1155
  client_context: nil,
1084
1156
  parent_span: nil)
1085
1157
  super(timeout: timeout, retry_strategy: retry_strategy, client_context: client_context, parent_span: parent_span)
1086
1158
  @cas = cas
1159
+
1160
+ if durability_level != :none && (replicate_to != :none || persist_to != :none)
1161
+ raise ArgumentError, "durability_level conflicts with replicate_to and persist_to options"
1162
+ end
1163
+
1164
+ @durability_level = durability_level
1165
+ @replicate_to = replicate_to
1166
+ @persist_to = persist_to
1087
1167
  yield self if block_given?
1088
1168
  end
1089
1169
 
@@ -1092,6 +1172,9 @@ module Couchbase
1092
1172
  {
1093
1173
  timeout: Utils::Time.extract_duration(@timeout),
1094
1174
  cas: @cas,
1175
+ durability_level: @durability_level,
1176
+ persist_to: @persist_to,
1177
+ replicate_to: @replicate_to,
1095
1178
  }
1096
1179
  end
1097
1180
 
@@ -25,6 +25,16 @@ module Couchbase
25
25
  MatchQuery.new(match, &block)
26
26
  end
27
27
 
28
+ # @return [Hash<Symbol, #to_json>]
29
+ def to_h
30
+ {}
31
+ end
32
+
33
+ # @return [String]
34
+ def to_json(*args)
35
+ to_h.to_json(*args)
36
+ end
37
+
28
38
  # A match query analyzes the input text and uses that analyzed text to query the index.
29
39
  class MatchQuery < SearchQuery
30
40
  # @return [Float]
@@ -53,17 +63,16 @@ module Couchbase
53
63
  yield self if block_given?
54
64
  end
55
65
 
56
- # @return [String]
57
- def to_json(*args)
58
- data = {"match" => @match}
59
- data["boost"] = boost if boost
60
- data["field"] = field if field
61
- data["analyzer"] = analyzer if analyzer
62
- if fuzziness
63
- data["fuzziness"] = fuzziness
64
- data["prefix_length"] = prefix_length if prefix_length
65
- end
66
- data.to_json(*args)
66
+ # @return [Hash<Symbol, #to_json>]
67
+ def to_h
68
+ data = {:match => @match}
69
+ data[:boost] = boost if boost
70
+ data[:field] = field if field
71
+ data[:analyzer] = analyzer if analyzer
72
+ data[:operator] = operator if operator
73
+ data[:fuzziness] = fuzziness if fuzziness
74
+ data[:prefix_length] = prefix_length if prefix_length
75
+ data
67
76
  end
68
77
  end
69
78
 
@@ -82,9 +91,6 @@ module Couchbase
82
91
  # @return [Float]
83
92
  attr_accessor :boost
84
93
 
85
- # @return [nil, :or, :and]
86
- attr_accessor :operator
87
-
88
94
  # @return [String]
89
95
  attr_accessor :field
90
96
 
@@ -100,14 +106,14 @@ module Couchbase
100
106
  yield self if block_given?
101
107
  end
102
108
 
103
- # @return [String]
104
- def to_json(*args)
105
- data = {"match_phrase" => @match_phrase}
106
- data["boost"] = boost if boost
107
- data["operator"] = operator.to_s if operator
108
- data["field"] = field if field
109
- data["analyzer"] = analyzer if analyzer
110
- data.to_json(*args)
109
+ # @return [Hash<Symbol, #to_json>]
110
+ def to_h
111
+ data = {:match_phrase => @match_phrase}
112
+ data[:boost] = boost if boost
113
+ data[:operator] = operator.to_s if operator
114
+ data[:field] = field if field
115
+ data[:analyzer] = analyzer if analyzer
116
+ data
111
117
  end
112
118
  end
113
119
 
@@ -126,9 +132,6 @@ module Couchbase
126
132
  # @return [Float]
127
133
  attr_accessor :boost
128
134
 
129
- # @return [nil, :or, :and]
130
- attr_accessor :operator
131
-
132
135
  # @return [String]
133
136
  attr_accessor :field
134
137
 
@@ -141,13 +144,12 @@ module Couchbase
141
144
  yield self if block_given?
142
145
  end
143
146
 
144
- # @return [String]
145
- def to_json(*args)
146
- data = {"regexp" => @regexp}
147
- data["boost"] = boost if boost
148
- data["operator"] = operator.to_s if operator
149
- data["field"] = field if field
150
- data.to_json(*args)
147
+ # @return [Hash<Symbol, #to_json>]
148
+ def to_h
149
+ data = {:regexp => @regexp}
150
+ data[:boost] = boost if boost
151
+ data[:field] = field if field
152
+ data
151
153
  end
152
154
  end
153
155
 
@@ -166,9 +168,6 @@ module Couchbase
166
168
  # @return [Float]
167
169
  attr_accessor :boost
168
170
 
169
- # @return [nil, :or, :and]
170
- attr_accessor :operator
171
-
172
171
  # @param [String] query_string
173
172
  #
174
173
  # @yieldparam [QueryStringQuery] self
@@ -178,12 +177,11 @@ module Couchbase
178
177
  yield self if block_given?
179
178
  end
180
179
 
181
- # @return [String]
182
- def to_json(*args)
183
- data = {"query" => @query_string}
184
- data["boost"] = boost if boost
185
- data["operator"] = operator.to_s if operator
186
- data.to_json(*args)
180
+ # @return [Hash<Symbol, #to_json>]
181
+ def to_h
182
+ data = {:query => @query_string}
183
+ data[:boost] = boost if boost
184
+ data
187
185
  end
188
186
  end
189
187
 
@@ -202,9 +200,6 @@ module Couchbase
202
200
  # @return [Float]
203
201
  attr_accessor :boost
204
202
 
205
- # @return [nil, :or, :and]
206
- attr_accessor :operator
207
-
208
203
  # @return [String]
209
204
  attr_accessor :field
210
205
 
@@ -217,13 +212,12 @@ module Couchbase
217
212
  yield self if block_given?
218
213
  end
219
214
 
220
- # @return [String]
221
- def to_json(*args)
222
- data = {"wildcard" => @wildcard}
223
- data["boost"] = boost if boost
224
- data["operator"] = operator.to_s if operator
225
- data["field"] = field if field
226
- data.to_json(*args)
215
+ # @return [Hash<Symbol, #to_json>]
216
+ def to_h
217
+ data = {:wildcard => @wildcard}
218
+ data[:boost] = boost if boost
219
+ data[:field] = field if field
220
+ data
227
221
  end
228
222
  end
229
223
 
@@ -242,12 +236,6 @@ module Couchbase
242
236
  # @return [Float]
243
237
  attr_accessor :boost
244
238
 
245
- # @return [nil, :or, :and]
246
- attr_accessor :operator
247
-
248
- # @return [String]
249
- attr_accessor :field
250
-
251
239
  # @param [String...] doc_ids
252
240
  #
253
241
  # @yieldparam [DocIdQuery] self
@@ -257,13 +245,11 @@ module Couchbase
257
245
  yield self if block_given?
258
246
  end
259
247
 
260
- # @return [String]
261
- def to_json(*args)
262
- data = {"doc_ids" => @doc_ids.flatten.uniq}
263
- data["boost"] = boost if boost
264
- data["operator"] = operator.to_s if operator
265
- data["field"] = field if field
266
- data.to_json(*args)
248
+ # @return [Hash<Symbol, #to_json>]
249
+ def to_h
250
+ data = {:ids => @doc_ids.flatten.uniq}
251
+ data[:boost] = boost if boost
252
+ data
267
253
  end
268
254
  end
269
255
 
@@ -282,9 +268,6 @@ module Couchbase
282
268
  # @return [Float]
283
269
  attr_accessor :boost
284
270
 
285
- # @return [nil, :or, :and]
286
- attr_accessor :operator
287
-
288
271
  # @return [String]
289
272
  attr_accessor :field
290
273
 
@@ -297,13 +280,12 @@ module Couchbase
297
280
  yield self if block_given?
298
281
  end
299
282
 
300
- # @return [String]
301
- def to_json(*args)
302
- data = {"bool" => @value}
303
- data["boost"] = boost if boost
304
- data["operator"] = operator.to_s if operator
305
- data["field"] = field if field
306
- data.to_json(*args)
283
+ # @return [Hash<Symbol, #to_json>]
284
+ def to_h
285
+ data = {:bool => @value}
286
+ data[:boost] = boost if boost
287
+ data[:field] = field if field
288
+ data
307
289
  end
308
290
  end
309
291
 
@@ -321,9 +303,6 @@ module Couchbase
321
303
  # @return [Float]
322
304
  attr_accessor :boost
323
305
 
324
- # @return [nil, :or, :and]
325
- attr_accessor :operator
326
-
327
306
  # @return [String]
328
307
  attr_accessor :field
329
308
 
@@ -365,32 +344,31 @@ module Couchbase
365
344
 
366
345
  DATE_FORMAT_RFC3339 = "%Y-%m-%dT%H:%M:%S%:z".freeze
367
346
 
368
- # @return [String]
369
- def to_json(*args)
347
+ # @return [Hash<Symbol, #to_json>]
348
+ def to_h
370
349
  raise ArgumentError, "either start_time or end_time must be set for DateRangeQuery" if @start_time.nil? && @end_time.nil?
371
350
 
372
351
  data = {}
373
- data["boost"] = boost if boost
374
- data["operator"] = operator.to_s if operator
375
- data["field"] = field if field
376
- data["datetime_parser"] = date_time_parser if date_time_parser
352
+ data[:boost] = boost if boost
353
+ data[:field] = field if field
354
+ data[:datetime_parser] = date_time_parser if date_time_parser
377
355
  if @start_time
378
- data["start"] = if @start_time.respond_to?(:strftime)
379
- @start_time.strftime(DATE_FORMAT_RFC3339)
380
- else
381
- @start_time
382
- end
383
- data["inclusive_start"] = @start_inclusive unless @start_inclusive.nil?
356
+ data[:start] = if @start_time.respond_to?(:strftime)
357
+ @start_time.strftime(DATE_FORMAT_RFC3339)
358
+ else
359
+ @start_time
360
+ end
361
+ data[:inclusive_start] = @start_inclusive unless @start_inclusive.nil?
384
362
  end
385
363
  if @end_time
386
- data["end"] = if @end_time.respond_to?(:strftime)
387
- @end_time.strftime(DATE_FORMAT_RFC3339)
388
- else
389
- @end_time
390
- end
391
- data["inclusive_end"] = @end_inclusive unless @end_inclusive.nil?
364
+ data[:end] = if @end_time.respond_to?(:strftime)
365
+ @end_time.strftime(DATE_FORMAT_RFC3339)
366
+ else
367
+ @end_time
368
+ end
369
+ data[:inclusive_end] = @end_inclusive unless @end_inclusive.nil?
392
370
  end
393
- data.to_json(*args)
371
+ data
394
372
  end
395
373
  end
396
374
 
@@ -408,9 +386,6 @@ module Couchbase
408
386
  # @return [Float]
409
387
  attr_accessor :boost
410
388
 
411
- # @return [nil, :or, :and]
412
- attr_accessor :operator
413
-
414
389
  # @return [String]
415
390
  attr_accessor :field
416
391
 
@@ -446,23 +421,22 @@ module Couchbase
446
421
  yield self if block_given?
447
422
  end
448
423
 
449
- # @return [String]
450
- def to_json(*args)
424
+ # @return [Hash<Symbol, #to_json>]
425
+ def to_h
451
426
  raise ArgumentError, "either min or max must be set for NumericRangeQuery" if @min.nil? && @max.nil?
452
427
 
453
428
  data = {}
454
- data["boost"] = boost if boost
455
- data["operator"] = operator.to_s if operator
456
- data["field"] = field if field
429
+ data[:boost] = boost if boost
430
+ data[:field] = field if field
457
431
  if @min
458
- data["min"] = @min
459
- data["inclusive_min"] = @min_inclusive unless @min_inclusive.nil?
432
+ data[:min] = @min
433
+ data[:inclusive_min] = @min_inclusive unless @min_inclusive.nil?
460
434
  end
461
435
  if @max
462
- data["max"] = @max
463
- data["inclusive_max"] = @max_inclusive unless @max_inclusive.nil?
436
+ data[:max] = @max
437
+ data[:inclusive_max] = @max_inclusive unless @max_inclusive.nil?
464
438
  end
465
- data.to_json(*args)
439
+ data
466
440
  end
467
441
  end
468
442
 
@@ -480,9 +454,6 @@ module Couchbase
480
454
  # @return [Float]
481
455
  attr_accessor :boost
482
456
 
483
- # @return [nil, :or, :and]
484
- attr_accessor :operator
485
-
486
457
  # @return [String]
487
458
  attr_accessor :field
488
459
 
@@ -518,23 +489,22 @@ module Couchbase
518
489
  yield self if block_given?
519
490
  end
520
491
 
521
- # @return [String]
522
- def to_json(*args)
492
+ # @return [Hash<Symbol, #to_json>]
493
+ def to_h
523
494
  raise ArgumentError, "either min or max must be set for TermRangeQuery" if @min.nil? && @max.nil?
524
495
 
525
496
  data = {}
526
- data["boost"] = boost if boost
527
- data["operator"] = operator.to_s if operator
528
- data["field"] = field if field
497
+ data[:boost] = boost if boost
498
+ data[:field] = field if field
529
499
  if @min
530
- data["min"] = @min
531
- data["inclusive_min"] = @min_inclusive unless @min_inclusive.nil?
500
+ data[:min] = @min
501
+ data[:inclusive_min] = @min_inclusive unless @min_inclusive.nil?
532
502
  end
533
503
  if @max
534
- data["max"] = @max
535
- data["inclusive_max"] = @max_inclusive unless @max_inclusive.nil?
504
+ data[:max] = @max
505
+ data[:inclusive_max] = @max_inclusive unless @max_inclusive.nil?
536
506
  end
537
- data.to_json(*args)
507
+ data
538
508
  end
539
509
  end
540
510
 
@@ -556,9 +526,6 @@ module Couchbase
556
526
  # @return [Float]
557
527
  attr_accessor :boost
558
528
 
559
- # @return [nil, :or, :and]
560
- attr_accessor :operator
561
-
562
529
  # @return [String]
563
530
  attr_accessor :field
564
531
 
@@ -574,16 +541,15 @@ module Couchbase
574
541
  yield self if block_given?
575
542
  end
576
543
 
577
- # @return [String]
578
- def to_json(*args)
544
+ # @return [Hash<Symbol, #to_json>]
545
+ def to_h
579
546
  data = {
580
- "location" => [@longitude, @latitude],
581
- "distance" => @distance,
547
+ :location => [@longitude, @latitude],
548
+ :distance => @distance,
582
549
  }
583
- data["boost"] = boost if boost
584
- data["operator"] = operator.to_s if operator
585
- data["field"] = field if field
586
- data.to_json(*args)
550
+ data[:boost] = boost if boost
551
+ data[:field] = field if field
552
+ data
587
553
  end
588
554
  end
589
555
 
@@ -606,9 +572,6 @@ module Couchbase
606
572
  # @return [Float]
607
573
  attr_accessor :boost
608
574
 
609
- # @return [nil, :or, :and]
610
- attr_accessor :operator
611
-
612
575
  # @return [String]
613
576
  attr_accessor :field
614
577
 
@@ -627,16 +590,15 @@ module Couchbase
627
590
  yield self if block_given?
628
591
  end
629
592
 
630
- # @return [String]
631
- def to_json(*args)
593
+ # @return [Hash<Symbol, #to_json>]
594
+ def to_h
632
595
  data = {
633
- "top_left" => [@top_left_longitude, @top_left_latitude],
634
- "bottom_right" => [@bottom_right_longitude, @bottom_right_latitude],
596
+ :top_left => [@top_left_longitude, @top_left_latitude],
597
+ :bottom_right => [@bottom_right_longitude, @bottom_right_latitude],
635
598
  }
636
- data["boost"] = boost if boost
637
- data["operator"] = operator.to_s if operator
638
- data["field"] = field if field
639
- data.to_json(*args)
599
+ data[:boost] = boost if boost
600
+ data[:field] = field if field
601
+ data
640
602
  end
641
603
  end
642
604
 
@@ -675,9 +637,6 @@ module Couchbase
675
637
  # @return [Float]
676
638
  attr_accessor :boost
677
639
 
678
- # @return [nil, :or, :and]
679
- attr_accessor :operator
680
-
681
640
  # @return [String]
682
641
  attr_accessor :field
683
642
 
@@ -690,15 +649,14 @@ module Couchbase
690
649
  yield self if block_given?
691
650
  end
692
651
 
693
- # @return [String]
694
- def to_json(*args)
652
+ # @return [Hash<Symbol, #to_json>]
653
+ def to_h
695
654
  data = {
696
- "polygon_points" => @coordinates.map { |coord| [coord.longitude, coord.latitude] },
655
+ :polygon_points => @coordinates.map { |coord| [coord.longitude, coord.latitude] },
697
656
  }
698
- data["boost"] = boost if boost
699
- data["operator"] = operator.to_s if operator
700
- data["field"] = field if field
701
- data.to_json(*args)
657
+ data[:boost] = boost if boost
658
+ data[:field] = field if field
659
+ data
702
660
  end
703
661
  end
704
662
 
@@ -716,9 +674,6 @@ module Couchbase
716
674
  # @return [Float]
717
675
  attr_accessor :boost
718
676
 
719
- # @return [nil, :or, :and]
720
- attr_accessor :operator
721
-
722
677
  # @yieldparam [ConjunctionQuery] self
723
678
  #
724
679
  # @param [*SearchQuery] queries
@@ -737,22 +692,21 @@ module Couchbase
737
692
  @queries.empty?
738
693
  end
739
694
 
740
- # @return [String]
741
- def to_json(*args)
695
+ # @return [Hash<Symbol, #to_json>]
696
+ def to_h
742
697
  raise ArgumentError, "compound conjunction query must have sub-queries" if @queries.nil? || @queries.empty?
743
698
 
744
- data = {"conjuncts" => @queries.uniq}
745
- data["boost"] = boost if boost
746
- data["operator"] = operator.to_s if operator
747
- data.to_json(*args)
699
+ data = {:conjuncts => @queries.uniq.map(&:to_h)}
700
+ data[:boost] = boost if boost
701
+ data
748
702
  end
749
703
  end
750
704
 
751
705
  # Prepare {ConjunctionQuery} body
752
706
  #
753
- # @yieldparam [ConjunctionQuery] query
707
+ # @yieldparam [DisjunctionQuery] query
754
708
  #
755
- # @return [ConjunctionQuery]
709
+ # @return [DisjunctionQuery]
756
710
  def self.disjuncts(...)
757
711
  DisjunctionQuery.new(...)
758
712
  end
@@ -762,9 +716,6 @@ module Couchbase
762
716
  # @return [Float]
763
717
  attr_accessor :boost
764
718
 
765
- # @return [nil, :or, :and]
766
- attr_accessor :operator
767
-
768
719
  # @return [Integer]
769
720
  attr_accessor :min
770
721
 
@@ -786,19 +737,18 @@ module Couchbase
786
737
  @queries.empty?
787
738
  end
788
739
 
789
- # @return [String]
790
- def to_json(*args)
740
+ # @return [Hash<Symbol, #to_json>]
741
+ def to_h
791
742
  raise ArgumentError, "compound disjunction query must have sub-queries" if @queries.nil? || @queries.empty?
792
743
 
793
- data = {"disjuncts" => @queries.uniq}
744
+ data = {:disjuncts => @queries.uniq.map(&:to_h)}
794
745
  if min
795
746
  raise ArgumentError, "disjunction query has fewer sub-queries than configured minimum" if @queries.size < min
796
747
 
797
- data["min"] = min
748
+ data[:min] = min
798
749
  end
799
- data["boost"] = boost if boost
800
- data["operator"] = operator.to_s if operator
801
- data.to_json(*args)
750
+ data[:boost] = boost if boost
751
+ data
802
752
  end
803
753
  end
804
754
 
@@ -816,9 +766,6 @@ module Couchbase
816
766
  # @return [Float]
817
767
  attr_accessor :boost
818
768
 
819
- # @return [nil, :or, :and]
820
- attr_accessor :operator
821
-
822
769
  # @yieldparam [BooleanQuery] self
823
770
  def initialize
824
771
  super()
@@ -852,19 +799,18 @@ module Couchbase
852
799
  self
853
800
  end
854
801
 
855
- # @return [String]
856
- def to_json(*args)
802
+ # @return [Hash<Symbol, #to_json>]
803
+ def to_h
857
804
  if @must.empty? && @must_not.empty? && @should.empty?
858
805
  raise ArgumentError, "BooleanQuery must have at least one non-empty sub-query"
859
806
  end
860
807
 
861
808
  data = {}
862
- data["must"] = @must unless @must.empty?
863
- data["must_not"] = @must_not unless @must_not.empty?
864
- data["should"] = @should unless @should.empty?
865
- data["boost"] = boost if boost
866
- data["operator"] = operator.to_s if operator
867
- data.to_json(*args)
809
+ data[:must] = @must.to_h unless @must.empty?
810
+ data[:must_not] = @must_not.to_h unless @must_not.empty?
811
+ data[:should] = @should.to_h unless @should.empty?
812
+ data[:boost] = boost if boost
813
+ data
868
814
  end
869
815
  end
870
816
 
@@ -884,9 +830,6 @@ module Couchbase
884
830
  # @return [Float]
885
831
  attr_accessor :boost
886
832
 
887
- # @return [nil, :or, :and]
888
- attr_accessor :operator
889
-
890
833
  # @return [String]
891
834
  attr_accessor :field
892
835
 
@@ -905,18 +848,16 @@ module Couchbase
905
848
  yield self if block_given?
906
849
  end
907
850
 
908
- # @return [String]
909
- def to_json(*args)
910
- data = {"term" => @term}
911
- data["boost"] = boost if boost
912
- data["operator"] = operator.to_s if operator
913
- data["operator"] = operator.to_s if operator
914
- data["field"] = field if field
851
+ # @return [Hash<Symbol, #to_json>]
852
+ def to_h
853
+ data = {:term => @term}
854
+ data[:boost] = boost if boost
855
+ data[:field] = field if field
915
856
  if fuzziness
916
- data["fuzziness"] = fuzziness
917
- data["prefix_length"] = prefix_length if prefix_length
857
+ data[:fuzziness] = fuzziness
858
+ data[:prefix_length] = prefix_length if prefix_length
918
859
  end
919
- data.to_json(*args)
860
+ data
920
861
  end
921
862
  end
922
863
 
@@ -950,13 +891,12 @@ module Couchbase
950
891
  yield self if block_given?
951
892
  end
952
893
 
953
- # @return [String]
954
- def to_json(*args)
955
- data = {"prefix" => @prefix}
956
- data["boost"] = boost if boost
957
- data["operator"] = operator.to_s if operator
958
- data["field"] = field if field
959
- data.to_json(*args)
894
+ # @return [Hash<Symbol, #to_json>]
895
+ def to_h
896
+ data = {:prefix => @prefix}
897
+ data[:boost] = boost if boost
898
+ data[:field] = field if field
899
+ data
960
900
  end
961
901
  end
962
902
 
@@ -975,9 +915,6 @@ module Couchbase
975
915
  # @return [Float]
976
916
  attr_accessor :boost
977
917
 
978
- # @return [nil, :or, :and]
979
- attr_accessor :operator
980
-
981
918
  # @return [String]
982
919
  attr_accessor :field
983
920
 
@@ -990,13 +927,12 @@ module Couchbase
990
927
  yield self if block_given?
991
928
  end
992
929
 
993
- # @return [String]
994
- def to_json(*args)
995
- data = {"terms" => @terms.flatten.uniq}
996
- data["boost"] = boost if boost
997
- data["operator"] = operator.to_s if operator
998
- data["field"] = field if field
999
- data.to_json(*args)
930
+ # @return [Hash<Symbol, #to_json>]
931
+ def to_h
932
+ data = {:terms => @terms.flatten.uniq}
933
+ data[:boost] = boost if boost
934
+ data[:field] = field if field
935
+ data
1000
936
  end
1001
937
  end
1002
938
 
@@ -1011,24 +947,15 @@ module Couchbase
1011
947
 
1012
948
  # A query that matches all indexed documents.
1013
949
  class MatchAllQuery < SearchQuery
1014
- # @return [Float]
1015
- attr_accessor :boost
1016
-
1017
- # @return [nil, :or, :and]
1018
- attr_accessor :operator
1019
-
1020
950
  # @yieldparam [MatchAllQuery] self
1021
951
  def initialize
1022
952
  super()
1023
953
  yield self if block_given?
1024
954
  end
1025
955
 
1026
- # @return [String]
1027
- def to_json(*args)
1028
- data = {"match_all" => nil}
1029
- data["boost"] = boost if boost
1030
- data["operator"] = operator.to_s if operator
1031
- data.to_json(*args)
956
+ # @return [Hash<Symbol, #to_json>]
957
+ def to_h
958
+ {:match_all => nil}
1032
959
  end
1033
960
  end
1034
961
 
@@ -1043,24 +970,15 @@ module Couchbase
1043
970
 
1044
971
  # A query that matches nothing.
1045
972
  class MatchNoneQuery < SearchQuery
1046
- # @return [Float]
1047
- attr_accessor :boost
1048
-
1049
- # @return [nil, :or, :and]
1050
- attr_accessor :operator
1051
-
1052
973
  # @yieldparam [MatchNoneQuery] self
1053
974
  def initialize
1054
975
  super()
1055
976
  yield self if block_given?
1056
977
  end
1057
978
 
1058
- # @return [String]
1059
- def to_json(*args)
1060
- data = {"match_none" => nil}
1061
- data["boost"] = boost if boost
1062
- data["operator"] = operator.to_s if operator
1063
- data.to_json(*args)
979
+ # @return [Hash<Symbol, #to_json>]
980
+ def to_h
981
+ {:match_none => nil}
1064
982
  end
1065
983
  end
1066
984
  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.1".freeze)
22
+ VERSION.update(:sdk => "3.4.2".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.1
4
+ version: 3.4.2
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-03-20 00:00:00.000000000 Z
11
+ date: 2023-04-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Modern SDK for Couchbase Server
14
14
  email:
@@ -73,9 +73,9 @@ metadata:
73
73
  homepage_uri: https://docs.couchbase.com/ruby-sdk/current/hello-world/start-using-sdk.html
74
74
  bug_tracker_uri: https://couchbase.com/issues/browse/RCBC
75
75
  mailing_list_uri: https://forums.couchbase.com/c/ruby-sdk
76
- source_code_uri: https://github.com/couchbase/couchbase-ruby-client/tree/3.4.1
77
- changelog_uri: https://github.com/couchbase/couchbase-ruby-client/releases/tag/3.4.1
78
- documentation_uri: https://docs.couchbase.com/sdk-api/couchbase-ruby-client-3.4.1/index.html
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
79
79
  github_repo: ssh://github.com/couchbase/couchbase-ruby-client
80
80
  rubygems_mfa_required: 'true'
81
81
  post_install_message:
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  requirements: []
98
- rubygems_version: 3.4.6
98
+ rubygems_version: 3.4.10
99
99
  signing_key:
100
100
  specification_version: 4
101
101
  summary: SDK for Couchbase Server