google-cloud-datastore 2.1.0 → 2.2.0

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: e1693a80cce2df1bf3e9401267925ba11f25415d8c2e663b9b02b4e55cd8013d
4
- data.tar.gz: e53167252c7be95bab289f37e40e5fd574399b4bb705451fda0f049c7631c195
3
+ metadata.gz: 5cc84b3b7cf1ffd53fb9014894883cf4a6245a105365c97c5a4665abd2241ff0
4
+ data.tar.gz: 9b7acbddf571fd3b5c02b926fc676cfa0ed20bcda6eebaf02b7162c819585ae4
5
5
  SHA512:
6
- metadata.gz: b2a060028ced5a5a5b7db06df824657f174110a046bbd45a4d8943d179f769feb3009a99e5d905edb6fb0e9233268dc916ff4a2ca7811133fdfd74382d10c3a4
7
- data.tar.gz: b5ec1693a3838c0813a0f524f62f39995cb88c61dc5e7afa9525c2486d16489e85a1fae6525ada69dbdcef0e6db53c619b097225feb1ef9a402fcbc4c8b75a6c
6
+ metadata.gz: cd15c934e7ca1296df239924f55a02b2c105756cdbd60ffb538371bef4ff94176a04969678ed51e9337ad4b94d6d7faeb3e2366ac5c968225b7ddc9d4da1d86b
7
+ data.tar.gz: 31e397c409100133092611020ca472c671e8be85d1932be97cb3399c4ee576654f8a4018f98c9f6119be3881893d614b622a2243d13298b856ea359a83a58351
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 2.2.0 / 2021-03-10
4
+
5
+ #### Features
6
+
7
+ * Drop support for Ruby 2.4 and add support for Ruby 3.0
8
+
3
9
  ### 2.1.0 / 2020-09-17
4
10
 
5
11
  #### Features
data/CONTRIBUTING.md CHANGED
@@ -24,7 +24,7 @@ be able to accept your pull requests.
24
24
  In order to use the google-cloud-datastore console and run the project's tests,
25
25
  there is a small amount of setup:
26
26
 
27
- 1. Install Ruby. google-cloud-datastore requires Ruby 2.4+. You may choose to
27
+ 1. Install Ruby. google-cloud-datastore requires Ruby 2.5+. You may choose to
28
28
  manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
29
  [rbenv](https://github.com/rbenv/rbenv), or
30
30
  [chruby](https://github.com/postmodern/chruby).
@@ -45,7 +45,7 @@ there is a small amount of setup:
45
45
 
46
46
  ```sh
47
47
  $ cd google-cloud-datastore/
48
- $ bundle exec rake bundleupdate
48
+ $ bundle install
49
49
  ```
50
50
 
51
51
  ## Console
data/LOGGING.md CHANGED
@@ -3,7 +3,7 @@
3
3
  To enable logging for this library, set the logger for the underlying
4
4
  [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
5
  that you set may be a Ruby stdlib
6
- [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
6
+ [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as
7
7
  shown below, or a
8
8
  [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
9
9
  that will write logs to [Stackdriver
@@ -535,9 +535,9 @@ module Google
535
535
  begin
536
536
  yield tx
537
537
  tx.commit
538
- rescue Google::Cloud::UnavailableError => err
538
+ rescue Google::Cloud::UnavailableError => e
539
539
  # Re-raise if deadline has passed
540
- raise err if Time.now - start_time > deadline
540
+ raise e if Time.now - start_time > deadline
541
541
 
542
542
  # Sleep with incremental backoff
543
543
  sleep backoff *= 1.3
@@ -878,7 +878,7 @@ module Google
878
878
 
879
879
  def validate_deadline deadline
880
880
  return 60 unless deadline.is_a? Numeric
881
- return 60 if deadline < 0
881
+ return 60 if deadline.negative?
882
882
  deadline
883
883
  end
884
884
 
@@ -167,17 +167,17 @@ module Google
167
167
  # puts "Task #{t.key.id} (#cursor)"
168
168
  # end
169
169
  #
170
- def all request_limit: nil
170
+ def all request_limit: nil, &block
171
171
  request_limit = request_limit.to_i if request_limit
172
172
  unless block_given?
173
173
  return enum_for :all, request_limit: request_limit
174
174
  end
175
175
  results = self
176
176
  loop do
177
- results.each { |r| yield r }
177
+ results.each(&block)
178
178
  if request_limit
179
179
  request_limit -= 1
180
- break if request_limit < 0
180
+ break if request_limit.negative?
181
181
  end
182
182
  break unless results.next?
183
183
  results = results.next
@@ -187,14 +187,14 @@ module Google
187
187
  ##
188
188
  # @private New Dataset::LookupResults from a
189
189
  # Google::Dataset::V1::LookupResponse object.
190
- def self.from_grpc lookup_res, service, consistency = nil, tx = nil
190
+ def self.from_grpc lookup_res, service, consistency = nil, transaction = nil
191
191
  entities = to_gcloud_entities lookup_res.found
192
192
  deferred = to_gcloud_keys lookup_res.deferred
193
193
  missing = to_gcloud_entities lookup_res.missing
194
194
  new(entities).tap do |lr|
195
195
  lr.instance_variable_set :@service, service
196
196
  lr.instance_variable_set :@consistency, consistency
197
- lr.instance_variable_set :@transaction, tx
197
+ lr.instance_variable_set :@transaction, transaction
198
198
  lr.instance_variable_set :@deferred, deferred
199
199
  lr.instance_variable_set :@missing, missing
200
200
  end
@@ -266,17 +266,17 @@ module Google
266
266
  # puts "Task #{t.key.id} (#cursor)"
267
267
  # end
268
268
  #
269
- def all request_limit: nil
269
+ def all request_limit: nil, &block
270
270
  request_limit = request_limit.to_i if request_limit
271
271
  unless block_given?
272
272
  return enum_for :all, request_limit: request_limit
273
273
  end
274
274
  results = self
275
275
  loop do
276
- results.each { |r| yield r }
276
+ results.each(&block)
277
277
  if request_limit
278
278
  request_limit -= 1
279
- break if request_limit < 0
279
+ break if request_limit.negative?
280
280
  end
281
281
  break unless results.next?
282
282
  results = results.next
@@ -335,7 +335,7 @@ module Google
335
335
  # puts "Task #{task.key.id} (#cursor)"
336
336
  # end
337
337
  #
338
- def all_with_cursor request_limit: nil
338
+ def all_with_cursor request_limit: nil, &block
339
339
  request_limit = request_limit.to_i if request_limit
340
340
  unless block_given?
341
341
  return enum_for :all_with_cursor, request_limit: request_limit
@@ -343,10 +343,10 @@ module Google
343
343
  results = self
344
344
 
345
345
  loop do
346
- results.zip(results.cursors).each { |r, c| yield r, c }
346
+ results.zip(results.cursors).each(&block)
347
347
  if request_limit
348
348
  request_limit -= 1
349
- break if request_limit < 0
349
+ break if request_limit.negative?
350
350
  end
351
351
  break unless results.next?
352
352
  results = results.next
@@ -293,7 +293,7 @@ module Google
293
293
  # task.persisted? #=> true
294
294
  #
295
295
  def persisted?
296
- @key && @key.frozen?
296
+ @key&.frozen?
297
297
  end
298
298
 
299
299
  ##
@@ -157,17 +157,15 @@ module Google
157
157
  def named_bindings= new_named_bindings
158
158
  @grpc.named_bindings.clear
159
159
  new_named_bindings.map do |name, value|
160
- if value.is_a? Google::Cloud::Datastore::Cursor
161
- @grpc.named_bindings[name.to_s] = \
162
- Google::Cloud::Datastore::V1::GqlQueryParameter.new(
163
- cursor: value.to_grpc
164
- )
165
- else
166
- @grpc.named_bindings[name.to_s] = \
167
- Google::Cloud::Datastore::V1::GqlQueryParameter.new(
168
- value: Convert.to_value(value)
169
- )
170
- end
160
+ @grpc.named_bindings[name.to_s] = if value.is_a? Google::Cloud::Datastore::Cursor
161
+ Google::Cloud::Datastore::V1::GqlQueryParameter.new(
162
+ cursor: value.to_grpc
163
+ )
164
+ else
165
+ Google::Cloud::Datastore::V1::GqlQueryParameter.new(
166
+ value: Convert.to_value(value)
167
+ )
168
+ end
171
169
  end
172
170
  end
173
171
 
@@ -208,17 +206,15 @@ module Google
208
206
  def positional_bindings= new_positional_bindings
209
207
  @grpc.positional_bindings.clear
210
208
  new_positional_bindings.map do |value|
211
- if value.is_a? Google::Cloud::Datastore::Cursor
212
- @grpc.positional_bindings << \
213
- Google::Cloud::Datastore::V1::GqlQueryParameter.new(
214
- cursor: value.to_grpc
215
- )
216
- else
217
- @grpc.positional_bindings << \
218
- Google::Cloud::Datastore::V1::GqlQueryParameter.new(
219
- value: Convert.to_value(value)
220
- )
221
- end
209
+ @grpc.positional_bindings << if value.is_a? Google::Cloud::Datastore::Cursor
210
+ Google::Cloud::Datastore::V1::GqlQueryParameter.new(
211
+ cursor: value.to_grpc
212
+ )
213
+ else
214
+ Google::Cloud::Datastore::V1::GqlQueryParameter.new(
215
+ value: Convert.to_value(value)
216
+ )
217
+ end
222
218
  end
223
219
  end
224
220
 
@@ -272,9 +272,10 @@ module Google
272
272
  def to_grpc
273
273
  grpc_path = path.map do |pe_kind, pe_id_or_name|
274
274
  path_args = { kind: pe_kind }
275
- if pe_id_or_name.is_a? Integer
275
+ case pe_id_or_name
276
+ when Integer
276
277
  path_args[:id] = pe_id_or_name
277
- elsif pe_id_or_name.is_a? String
278
+ when String
278
279
  path_args[:name] = pe_id_or_name unless pe_id_or_name.empty?
279
280
  end
280
281
  Google::Cloud::Datastore::V1::Key::PathElement.new path_args
@@ -305,7 +306,7 @@ module Google
305
306
  key.project = key_grpc.partition_id.project_id
306
307
  key.namespace = key_grpc.partition_id.namespace_id
307
308
  end
308
- key.parent = Key.from_grpc key_grpc if key_grpc.path.count > 0
309
+ key.parent = Key.from_grpc key_grpc if key_grpc.path.count.positive?
309
310
  # Freeze the key to make it immutable.
310
311
  key.freeze
311
312
  key
@@ -340,9 +340,10 @@ module Google
340
340
  # tasks = datastore.run query
341
341
  #
342
342
  def start cursor
343
- if cursor.is_a? Cursor
343
+ case cursor
344
+ when Cursor
344
345
  @grpc.start_cursor = cursor.to_grpc
345
- elsif cursor.is_a? String
346
+ when String
346
347
  @grpc.start_cursor = Convert.decode_bytes cursor
347
348
  else
348
349
  raise ArgumentError, "Can't set a cursor using a #{cursor.class}."
@@ -25,7 +25,10 @@ module Google
25
25
  # @private Represents the GAX Datastore service, including all the API
26
26
  # methods.
27
27
  class Service
28
- attr_accessor :project, :credentials, :host, :timeout
28
+ attr_accessor :project
29
+ attr_accessor :credentials
30
+ attr_accessor :host
31
+ attr_accessor :timeout
29
32
 
30
33
  ##
31
34
  # Creates a new Service instance.
@@ -50,7 +50,7 @@ module Google
50
50
  # @private Creates a new Transaction instance.
51
51
  # Takes a Service instead of project and Credentials.
52
52
  def initialize service, previous_transaction: nil
53
- @service = service
53
+ super service
54
54
  @previous_transaction = previous_transaction
55
55
  reset!
56
56
  start
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Datastore
19
- VERSION = "2.1.0".freeze
19
+ VERSION = "2.2.0".freeze
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google-cloud-datastore
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Moore
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-17 00:00:00.000000000 Z
12
+ date: 2021-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: 1.24.0
48
+ version: 1.25.1
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: 1.24.0
55
+ version: 1.25.1
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -228,14 +228,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  requirements:
229
229
  - - ">="
230
230
  - !ruby/object:Gem::Version
231
- version: '2.4'
231
+ version: '2.5'
232
232
  required_rubygems_version: !ruby/object:Gem::Requirement
233
233
  requirements:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  requirements: []
238
- rubygems_version: 3.1.4
238
+ rubygems_version: 3.2.13
239
239
  signing_key:
240
240
  specification_version: 4
241
241
  summary: API Client library for Google Cloud Datastore