google-cloud-datastore 0.23.0 → 0.24.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
  SHA1:
3
- metadata.gz: 9e09eda35bf315f2e0770ba68fe5e4cf20627620
4
- data.tar.gz: defca69aebef85ab77ced5f07ecbbf112c1029c3
3
+ metadata.gz: 007a60b36f840de3463b248b7eac389ca43d6dc1
4
+ data.tar.gz: d53a54ae030e78ae23bb8452565f86230be64720
5
5
  SHA512:
6
- metadata.gz: 8ae9e6f5e9fd02c0b0e99bffd7a0fce54bf4f3c3516be73218936a50c1b26659ae6ba628e5e97d20a6cdbd8284a53e0e1b26ea9dc11c3f89781d621d249853c9
7
- data.tar.gz: 03cb2770d32794438819844ec56f0264e44b006b71c4df126c02e5076493f26c3deb70fd1930d6343345da4bb1e714d67e256f376465f328c75d5c3633ec086a
6
+ metadata.gz: 7ec35a2806d9b5c437c963d8028e9222b5c9ceeed9ed2a455e7c6e6deb24aed24db09b102e29e89d6dc59bd0133cb0088cfd1fbe051766a2e5f6a9cb7d697731
7
+ data.tar.gz: 2459ba10bf82755451235dee9470ce3afef8ea5a56d09316812fd98f87af0667c3aaa9b7848ad82f212911239cc82e9d8967750ca236527630564473a41cac74
data/.yardopts CHANGED
@@ -1,5 +1,6 @@
1
1
  --no-private
2
2
  --title=Google Cloud Datastore
3
+ --exclude lib/google/datastore/v1
3
4
  --markup markdown
4
5
 
5
6
  ./lib/**/*.rb
@@ -545,6 +545,8 @@ module Google
545
545
  # @param [Integer] timeout Default timeout to use in requests. Optional.
546
546
  # @param [Hash] client_config A hash of values to override the default
547
547
  # behavior of the API client. See Google::Gax::CallSettings. Optional.
548
+ # @param [String] emulator_host Datastore emulator host. Optional.
549
+ # If the param is nil, ENV["DATASTORE_EMULATOR_HOST"] will be used.
548
550
  #
549
551
  # @return [Google::Cloud::Datastore::Dataset]
550
552
  #
@@ -566,16 +568,17 @@ module Google
566
568
  # datastore.save task
567
569
  #
568
570
  def self.new project: nil, keyfile: nil, scope: nil, timeout: nil,
569
- client_config: nil
571
+ client_config: nil, emulator_host: nil
570
572
  project ||= Google::Cloud::Datastore::Dataset.default_project
571
573
  project = project.to_s # Always cast to a string
572
574
  fail ArgumentError, "project is missing" if project.empty?
573
575
 
574
- if ENV["DATASTORE_EMULATOR_HOST"]
576
+ emulator_host ||= ENV["DATASTORE_EMULATOR_HOST"]
577
+ if emulator_host
575
578
  return Google::Cloud::Datastore::Dataset.new(
576
579
  Google::Cloud::Datastore::Service.new(
577
580
  project, :this_channel_is_insecure,
578
- host: ENV["DATASTORE_EMULATOR_HOST"],
581
+ host: emulator_host,
579
582
  client_config: client_config))
580
583
  end
581
584
  credentials = credentials_with_scope keyfile, scope
@@ -1,4 +1,4 @@
1
- # Copyright 2016 Google Inc. All rights reserved.
1
+ # Copyright 2017 Google Inc. All rights reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -13,19 +13,56 @@
13
13
  # limitations under the License.
14
14
 
15
15
 
16
- require "google/cloud/core/grpc_utils"
17
16
  require "google/cloud/datastore/errors"
18
17
  require "stringio"
19
18
  require "base64"
20
19
 
21
20
  module Google
22
21
  module Cloud
23
- module Core
22
+ module Datastore
23
+ # rubocop:disable all
24
+
24
25
  ##
25
26
  # @private Conversion to/from Datastore GRPC objects.
26
- # This file adds Datastore methods to Core::GRPCUtils.
27
- module GRPCUtils
28
- # rubocop:disable all
27
+ module Convert
28
+ ##
29
+ # @private Convert a Google::Protobuf::Struct to a Hash.
30
+ def self.struct_to_hash struct
31
+ # TODO: ArgumentError if struct is not a Google::Protobuf::Struct
32
+ Hash[struct.fields.map { |k, v| [k, value_to_object(v)] }]
33
+ end
34
+
35
+ ##
36
+ # @private Convert a Google::Protobuf::Value to an Object.
37
+ def self.value_to_object value
38
+ # TODO: ArgumentError if struct is not a Google::Protobuf::Value
39
+ if value.kind == :null_value
40
+ nil
41
+ elsif value.kind == :number_value
42
+ value.number_value
43
+ elsif value.kind == :string_value
44
+ value.string_value
45
+ elsif value.kind == :bool_value
46
+ value.bool_value
47
+ elsif value.kind == :struct_value
48
+ struct_to_hash value.struct_value
49
+ elsif value.kind == :list_value
50
+ value.list_value.values.map { |v| value_to_object(v) }
51
+ else
52
+ nil # just in case
53
+ end
54
+ end
55
+
56
+ ##
57
+ # @private Convert a Google::Protobuf::Map to a Hash
58
+ def self.map_to_hash map
59
+ if map.respond_to? :to_h
60
+ map.to_h
61
+ else
62
+ # Enumerable doesn't have to_h on ruby 2.0...
63
+ Hash[map.to_a]
64
+ end
65
+ end
29
66
 
30
67
  PROP_FILTER_OPS = { "<" => :LESS_THAN,
31
68
  "lt" => :LESS_THAN,
@@ -133,8 +170,9 @@ module Google
133
170
  def self.decode_bytes bytes
134
171
  Base64.decode64(bytes.to_s).force_encoding Encoding::ASCII_8BIT
135
172
  end
136
- # rubocop:enable all
137
173
  end
174
+
175
+ # rubocop:enable all
138
176
  end
139
177
  end
140
178
  end
@@ -63,14 +63,14 @@ module Google
63
63
 
64
64
  # @private byte array as a string
65
65
  def to_grpc
66
- Core::GRPCUtils.decode_bytes(@cursor)
66
+ Convert.decode_bytes(@cursor)
67
67
  end
68
68
 
69
69
  # @private byte array as a string
70
70
  def self.from_grpc grpc
71
71
  grpc = String grpc
72
72
  return nil if grpc.empty?
73
- new Core::GRPCUtils.encode_bytes(grpc)
73
+ new Convert.encode_bytes(grpc)
74
74
  end
75
75
  end
76
76
  end
@@ -14,7 +14,7 @@
14
14
 
15
15
 
16
16
  require "google/cloud/core/environment"
17
- require "google/cloud/datastore/grpc_utils"
17
+ require "google/cloud/datastore/convert"
18
18
  require "google/cloud/datastore/credentials"
19
19
  require "google/cloud/datastore/service"
20
20
  require "google/cloud/datastore/commit"
@@ -131,7 +131,7 @@ module Google
131
131
  if gql_query_param.parameter_type == :cursor
132
132
  [name, Cursor.from_grpc(gql_query_param.cursor)]
133
133
  else
134
- [name, Core::GRPCUtils.from_value(gql_query_param.value)]
134
+ [name, Convert.from_value(gql_query_param.value)]
135
135
  end
136
136
  end]
137
137
  bindings.freeze
@@ -164,7 +164,7 @@ module Google
164
164
  else
165
165
  @grpc.named_bindings[name.to_s] = \
166
166
  Google::Datastore::V1::GqlQueryParameter.new(
167
- value: Core::GRPCUtils.to_value(value))
167
+ value: Convert.to_value(value))
168
168
  end
169
169
  end
170
170
  end
@@ -181,7 +181,7 @@ module Google
181
181
  if gql_query_param.parameter_type == :cursor
182
182
  Cursor.from_grpc gql_query_param.cursor
183
183
  else
184
- Core::GRPCUtils.from_value gql_query_param.value
184
+ Convert.from_value gql_query_param.value
185
185
  end
186
186
  end
187
187
  bindings.freeze
@@ -213,7 +213,7 @@ module Google
213
213
  else
214
214
  @grpc.positional_bindings << \
215
215
  Google::Datastore::V1::GqlQueryParameter.new(
216
- value: Core::GRPCUtils.to_value(value))
216
+ value: Convert.to_value(value))
217
217
  end
218
218
  end
219
219
  end
@@ -73,15 +73,15 @@ module Google
73
73
  alias_method :to_hash, :to_h
74
74
 
75
75
  def to_grpc
76
- Hash[@hash.map { |(k, v)| [k.to_s, Core::GRPCUtils.to_value(v)] }]
76
+ Hash[@hash.map { |(k, v)| [k.to_s, Convert.to_value(v)] }]
77
77
  end
78
78
 
79
79
  def self.from_grpc grpc_map
80
80
  # For some reason Google::Protobuf::Map#map isn't returning the value.
81
81
  # It returns nil every time. COnvert to Hash to get actual objects.
82
- grpc_hash = Core::GRPCUtils.map_to_hash grpc_map
82
+ grpc_hash = Convert.map_to_hash grpc_map
83
83
  grpc_array = grpc_hash.map do |(k, v)|
84
- [k.to_s, Core::GRPCUtils.from_value(v)]
84
+ [k.to_s, Convert.from_value(v)]
85
85
  end
86
86
  new Hash[grpc_array]
87
87
  end
@@ -97,7 +97,7 @@ module Google
97
97
  end
98
98
 
99
99
  # rubocop:disable all
100
- # Disabled rubocop because this needs to match Core::GRPCUtils.to_value
100
+ # Disabled rubocop because this needs to match Convert.to_value
101
101
 
102
102
  ##
103
103
  # Ensures the value is a type that can be persisted,
@@ -177,8 +177,8 @@ module Google
177
177
  property_filter: Google::Datastore::V1::PropertyFilter.new(
178
178
  property: Google::Datastore::V1::PropertyReference.new(
179
179
  name: name),
180
- op: Core::GRPCUtils.to_prop_filter_op(operator),
181
- value: Core::GRPCUtils.to_value(value)
180
+ op: Convert.to_prop_filter_op(operator),
181
+ value: Convert.to_value(value)
182
182
  )
183
183
  )
184
184
 
@@ -331,7 +331,7 @@ module Google
331
331
  if cursor.is_a? Cursor
332
332
  @grpc.start_cursor = cursor.to_grpc
333
333
  elsif cursor.is_a? String
334
- @grpc.start_cursor = Core::GRPCUtils.decode_bytes cursor
334
+ @grpc.start_cursor = Convert.decode_bytes cursor
335
335
  else
336
336
  fail ArgumentError, "Can't set a cursor using a #{cursor.class}."
337
337
  end
@@ -2,13 +2,11 @@
2
2
  "interfaces": {
3
3
  "google.datastore.v1.Datastore": {
4
4
  "retry_codes": {
5
- "retry_codes_def": {
6
5
  "idempotent": [
7
6
  "DEADLINE_EXCEEDED",
8
7
  "UNAVAILABLE"
9
8
  ],
10
9
  "non_idempotent": []
11
- }
12
10
  },
13
11
  "retry_params": {
14
12
  "default": {
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Datastore
19
- VERSION = "0.23.0"
19
+ VERSION = "0.24.0"
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: 0.23.0
4
+ version: 0.24.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: 2016-12-09 00:00:00.000000000 Z
12
+ date: 2017-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -25,76 +25,34 @@ dependencies:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: 0.21.0
28
- - !ruby/object:Gem::Dependency
29
- name: grpc
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: '1.0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: '1.0'
42
- - !ruby/object:Gem::Dependency
43
- name: google-protobuf
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '3.0'
49
- type: :runtime
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '3.0'
56
- - !ruby/object:Gem::Dependency
57
- name: googleapis-common-protos
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - "~>"
61
- - !ruby/object:Gem::Version
62
- version: '1.3'
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '1.3'
70
28
  - !ruby/object:Gem::Dependency
71
29
  name: google-gax
72
30
  requirement: !ruby/object:Gem::Requirement
73
31
  requirements:
74
32
  - - "~>"
75
33
  - !ruby/object:Gem::Version
76
- version: 0.6.0
34
+ version: 0.8.0
77
35
  type: :runtime
78
36
  prerelease: false
79
37
  version_requirements: !ruby/object:Gem::Requirement
80
38
  requirements:
81
39
  - - "~>"
82
40
  - !ruby/object:Gem::Version
83
- version: 0.6.0
41
+ version: 0.8.0
84
42
  - !ruby/object:Gem::Dependency
85
43
  name: minitest
86
44
  requirement: !ruby/object:Gem::Requirement
87
45
  requirements:
88
46
  - - "~>"
89
47
  - !ruby/object:Gem::Version
90
- version: '5.9'
48
+ version: '5.10'
91
49
  type: :development
92
50
  prerelease: false
93
51
  version_requirements: !ruby/object:Gem::Requirement
94
52
  requirements:
95
53
  - - "~>"
96
54
  - !ruby/object:Gem::Version
97
- version: '5.9'
55
+ version: '5.10'
98
56
  - !ruby/object:Gem::Dependency
99
57
  name: minitest-autotest
100
58
  requirement: !ruby/object:Gem::Requirement
@@ -197,14 +155,14 @@ dependencies:
197
155
  name: yard-doctest
198
156
  requirement: !ruby/object:Gem::Requirement
199
157
  requirements:
200
- - - "~>"
158
+ - - "<="
201
159
  - !ruby/object:Gem::Version
202
160
  version: 0.1.8
203
161
  type: :development
204
162
  prerelease: false
205
163
  version_requirements: !ruby/object:Gem::Requirement
206
164
  requirements:
207
- - - "~>"
165
+ - - "<="
208
166
  - !ruby/object:Gem::Version
209
167
  version: 0.1.8
210
168
  description: google-cloud-datastore is the official library for Google Cloud Datastore.
@@ -221,6 +179,7 @@ files:
221
179
  - lib/google-cloud-datastore.rb
222
180
  - lib/google/cloud/datastore.rb
223
181
  - lib/google/cloud/datastore/commit.rb
182
+ - lib/google/cloud/datastore/convert.rb
224
183
  - lib/google/cloud/datastore/credentials.rb
225
184
  - lib/google/cloud/datastore/cursor.rb
226
185
  - lib/google/cloud/datastore/dataset.rb
@@ -229,7 +188,6 @@ files:
229
188
  - lib/google/cloud/datastore/entity.rb
230
189
  - lib/google/cloud/datastore/errors.rb
231
190
  - lib/google/cloud/datastore/gql_query.rb
232
- - lib/google/cloud/datastore/grpc_utils.rb
233
191
  - lib/google/cloud/datastore/key.rb
234
192
  - lib/google/cloud/datastore/properties.rb
235
193
  - lib/google/cloud/datastore/query.rb
@@ -267,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
225
  version: '0'
268
226
  requirements: []
269
227
  rubyforge_project:
270
- rubygems_version: 2.4.5.1
228
+ rubygems_version: 2.6.10
271
229
  signing_key:
272
230
  specification_version: 4
273
231
  summary: API Client library for Google Cloud Datastore