google-cloud-language 1.0.0 → 1.2.2
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/AUTHENTICATION.md +1 -1
- data/MIGRATING.md +59 -5
- data/README.md +1 -1
- data/lib/google-cloud-language.rb +1 -17
- data/lib/google/cloud/language.rb +33 -7
- data/lib/google/cloud/language/version.rb +1 -1
- metadata +16 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24596b6b6e6884b88a1d042cd290e2d140c2a579c6cc0fbc4b173a5041d388a1
|
4
|
+
data.tar.gz: 057b19c65cc069da794ef478438111a21f019467be07535469e28b8369b35196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cbcfe84cd17d70765f84734025116c42aebbf7fee9f43f8a816a2b84ee70a952b21b18a9a82f0c5dcfbcfc0e532baaed9a903e08cf5958b826cfa9b9c0030cf9
|
7
|
+
data.tar.gz: 1bcfca1a82f1c44301650c28cef807a3e558a12ed7272c8848c1e2d1aa6dea0677166b0bc29971e949732d407db566cab7b3e0b81637e67b0bcf10cf13503eec
|
data/AUTHENTICATION.md
CHANGED
@@ -64,7 +64,7 @@ containers where writing files is difficult or not encouraged.
|
|
64
64
|
|
65
65
|
The environment variables that google-cloud-language
|
66
66
|
checks for credentials are configured on the service Credentials class (such as
|
67
|
-
|
67
|
+
`::Google::Cloud::Language::V1::LanguageService::Credentials`):
|
68
68
|
|
69
69
|
1. `LANGUAGE_CREDENTIALS` - Path to JSON file, or JSON contents
|
70
70
|
2. `LANGUAGE_KEYFILE` - Path to JSON file, or JSON contents
|
data/MIGRATING.md
CHANGED
@@ -26,6 +26,10 @@ To summarize:
|
|
26
26
|
specifies whether they are required or optional. Additionally, you can pass
|
27
27
|
a proto request object instead of separate arguments. See
|
28
28
|
[Passing Arguments](#passing-arguments) for more info.
|
29
|
+
* Previously, clients reported RPC errors by raising instances of
|
30
|
+
`Google::Gax::GaxError` and its subclasses. Now, RPC exceptions are of type
|
31
|
+
`Google::Cloud::Error` and its subclasses. See
|
32
|
+
[Handling Errors](#handling-errors) for more info.
|
29
33
|
* Some classes have moved into different namespaces. See
|
30
34
|
[Class Namespaces](#class-namespaces) for more info.
|
31
35
|
|
@@ -71,7 +75,7 @@ timeout for all Language V1 clients:
|
|
71
75
|
```
|
72
76
|
Google::Cloud::Language::V1::LanguageService::Client.configure do |config|
|
73
77
|
config.credentials = "/path/to/credentials.json"
|
74
|
-
config.timeout =
|
78
|
+
config.timeout = 10.0
|
75
79
|
end
|
76
80
|
```
|
77
81
|
|
@@ -80,7 +84,7 @@ timeout for the `analyze_sentiment` call:
|
|
80
84
|
|
81
85
|
```
|
82
86
|
Google::Cloud::Language::V1::LanguageService::Client.configure do |config|
|
83
|
-
config.rpcs.analyze_sentinment.timeout =
|
87
|
+
config.rpcs.analyze_sentinment.timeout = 20.0
|
84
88
|
end
|
85
89
|
```
|
86
90
|
|
@@ -90,7 +94,7 @@ globally:
|
|
90
94
|
```
|
91
95
|
Google::Cloud::Language.configure do |config|
|
92
96
|
config.credentials = "/path/to/credentials.json"
|
93
|
-
config.timeout =
|
97
|
+
config.timeout = 10.0
|
94
98
|
end
|
95
99
|
```
|
96
100
|
|
@@ -193,7 +197,7 @@ document = {
|
|
193
197
|
type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT
|
194
198
|
}
|
195
199
|
|
196
|
-
options = Google::Gax::CallOptions.new timeout:
|
200
|
+
options = Google::Gax::CallOptions.new timeout: 10.0
|
197
201
|
|
198
202
|
response = client.analyze_sentiment document, options: options
|
199
203
|
```
|
@@ -212,10 +216,60 @@ encoding = Google:Cloud::Language::V1::EncodingType::UTF8
|
|
212
216
|
# then add further keyword arguments for the call options.
|
213
217
|
response = client.analyze_sentiment(
|
214
218
|
{ document: document, encoding_type: encoding },
|
215
|
-
timeout:
|
219
|
+
timeout: 10.0
|
216
220
|
)
|
217
221
|
```
|
218
222
|
|
223
|
+
### Handling Errors
|
224
|
+
|
225
|
+
The client reports standard
|
226
|
+
[gRPC error codes](https://github.com/grpc/grpc/blob/master/doc/statuscodes.md)
|
227
|
+
by raising exceptions. In older releases, these exceptions were located in the
|
228
|
+
`Google::Gax` namespace and were subclasses of the `Google::Gax::GaxError` base
|
229
|
+
exception class, defined in the `google-gax` gem. However, these classes were
|
230
|
+
different from the standard exceptions (subclasses of `Google::Cloud::Error`)
|
231
|
+
thrown by other client libraries such as `google-cloud-storage`.
|
232
|
+
|
233
|
+
The 1.0 client library now uses the `Google::Cloud::Error` exception hierarchy,
|
234
|
+
for consistency across all the Google Cloud client libraries. In general, these
|
235
|
+
exceptions have the same name as their counterparts from older releases, but
|
236
|
+
are located in the `Google::Cloud` namespace rather than the `Google::Gax`
|
237
|
+
namespace.
|
238
|
+
|
239
|
+
Old:
|
240
|
+
```
|
241
|
+
client = Google::Cloud::Language.new
|
242
|
+
|
243
|
+
document = {
|
244
|
+
content: "I love API calls!",
|
245
|
+
type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT
|
246
|
+
}
|
247
|
+
encoding = Google:Cloud::Language::V1::EncodingType::UTF8
|
248
|
+
|
249
|
+
begin
|
250
|
+
response = client.analyze_sentiment document, encoding_type: encoding
|
251
|
+
rescue Google::Gax::Error => e
|
252
|
+
# Handle exceptions that subclass Google::Gax::Error
|
253
|
+
end
|
254
|
+
```
|
255
|
+
|
256
|
+
New:
|
257
|
+
```
|
258
|
+
client = Google::Cloud::Language.language_service
|
259
|
+
|
260
|
+
document = {
|
261
|
+
content: "I love API calls!",
|
262
|
+
type: Google::Cloud::Language::V1::Document::Type::PLAIN_TEXT
|
263
|
+
}
|
264
|
+
encoding = Google:Cloud::Language::V1::EncodingType::UTF8
|
265
|
+
|
266
|
+
begin
|
267
|
+
response = client.analyze_sentiment document: document, encoding_type: encoding
|
268
|
+
rescue Google::Cloud::Error => e
|
269
|
+
# Handle exceptions that subclass Google::Cloud::Error
|
270
|
+
end
|
271
|
+
```
|
272
|
+
|
219
273
|
### Class Namespaces
|
220
274
|
|
221
275
|
In older releases, the client object was of class
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ See the {file:MIGRATING.md MIGRATING.md} document for more information.
|
|
47
47
|
To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
48
48
|
The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) as shown below,
|
49
49
|
or a [`Google::Cloud::Logging::Logger`](https://googleapis.dev/ruby/google-cloud-logging/latest)
|
50
|
-
that will write logs to [
|
50
|
+
that will write logs to [Cloud Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
51
51
|
and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
52
52
|
|
53
53
|
Configuring a Ruby stdlib logger:
|
@@ -16,20 +16,4 @@
|
|
16
16
|
|
17
17
|
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
18
|
|
19
|
-
|
20
|
-
require "google/cloud" unless defined? Google::Cloud.new
|
21
|
-
require "google/cloud/config"
|
22
|
-
require "googleauth"
|
23
|
-
|
24
|
-
# Set the default configuration
|
25
|
-
Google::Cloud.configure.add_config! :language do |config|
|
26
|
-
config.add_field! :credentials, nil, match: [String, Hash, Google::Auth::Credentials]
|
27
|
-
config.add_field! :lib_name, nil, match: String
|
28
|
-
config.add_field! :lib_version, nil, match: String
|
29
|
-
config.add_field! :interceptors, nil, match: Array
|
30
|
-
config.add_field! :timeout, nil, match: Numeric
|
31
|
-
config.add_field! :metadata, nil, match: Hash
|
32
|
-
config.add_field! :retry_policy, nil, match: [Hash, Proc]
|
33
|
-
end
|
34
|
-
|
35
|
-
require "google/cloud/language/version"
|
19
|
+
require "google/cloud/language" unless defined? Google::Cloud::Language::VERSION
|
@@ -16,7 +16,30 @@
|
|
16
16
|
|
17
17
|
# Auto-generated by gapic-generator-ruby. DO NOT EDIT!
|
18
18
|
|
19
|
-
|
19
|
+
# Require this file early so that the version constant gets defined before
|
20
|
+
# requiring "google/cloud". This is because google-cloud-core will load the
|
21
|
+
# entrypoint (gem name) file, which in turn re-requires this file (hence
|
22
|
+
# causing a require cycle) unless the version constant is already defined.
|
23
|
+
require "google/cloud/language/version"
|
24
|
+
|
25
|
+
require "googleauth"
|
26
|
+
gem "google-cloud-core"
|
27
|
+
require "google/cloud" unless defined? ::Google::Cloud.new
|
28
|
+
require "google/cloud/config"
|
29
|
+
|
30
|
+
# Set the default configuration
|
31
|
+
::Google::Cloud.configure.add_config! :language do |config|
|
32
|
+
config.add_field! :endpoint, "language.googleapis.com", match: ::String
|
33
|
+
config.add_field! :credentials, nil, match: [::String, ::Hash, ::Google::Auth::Credentials]
|
34
|
+
config.add_field! :scope, nil, match: [::Array, ::String]
|
35
|
+
config.add_field! :lib_name, nil, match: ::String
|
36
|
+
config.add_field! :lib_version, nil, match: ::String
|
37
|
+
config.add_field! :interceptors, nil, match: ::Array
|
38
|
+
config.add_field! :timeout, nil, match: ::Numeric
|
39
|
+
config.add_field! :metadata, nil, match: ::Hash
|
40
|
+
config.add_field! :retry_policy, nil, match: [::Hash, ::Proc]
|
41
|
+
config.add_field! :quota_project, nil, match: ::String
|
42
|
+
end
|
20
43
|
|
21
44
|
module Google
|
22
45
|
module Cloud
|
@@ -37,7 +60,7 @@ module Google
|
|
37
60
|
# Provides text analysis operations such as sentiment analysis and entity
|
38
61
|
# recognition.
|
39
62
|
#
|
40
|
-
# @param version [String, Symbol] The API version to connect to. Optional.
|
63
|
+
# @param version [::String, ::Symbol] The API version to connect to. Optional.
|
41
64
|
# Defaults to `:v1`.
|
42
65
|
# @return [LanguageService::Client] A client object for the specified version.
|
43
66
|
#
|
@@ -66,8 +89,8 @@ module Google
|
|
66
89
|
# The library version as recorded in instrumentation and logging.
|
67
90
|
# * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
|
68
91
|
# An array of interceptors that are run before calls are executed.
|
69
|
-
# * `timeout` (*type:* `
|
70
|
-
# Default timeout in
|
92
|
+
# * `timeout` (*type:* `Numeric`) -
|
93
|
+
# Default timeout in seconds.
|
71
94
|
# * `metadata` (*type:* `Hash{Symbol=>String}`) -
|
72
95
|
# Additional gRPC headers to be sent with the call.
|
73
96
|
# * `retry_policy` (*type:* `Hash`) -
|
@@ -78,13 +101,16 @@ module Google
|
|
78
101
|
# * `:retry_codes` (*type:* `Array<String>`) -
|
79
102
|
# The error codes that should trigger a retry.
|
80
103
|
#
|
81
|
-
# @return [Google::Cloud::Config] The default configuration used by this library
|
104
|
+
# @return [::Google::Cloud::Config] The default configuration used by this library
|
82
105
|
#
|
83
106
|
def self.configure
|
84
|
-
yield Google::Cloud.configure.language if block_given?
|
107
|
+
yield ::Google::Cloud.configure.language if block_given?
|
85
108
|
|
86
|
-
Google::Cloud.configure.language
|
109
|
+
::Google::Cloud.configure.language
|
87
110
|
end
|
88
111
|
end
|
89
112
|
end
|
90
113
|
end
|
114
|
+
|
115
|
+
helper_path = ::File.join __dir__, "language", "helpers.rb"
|
116
|
+
require "google/cloud/language/helpers" if ::File.file? helper_path
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-language
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Google LLC
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-cloud-core
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0.1'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: autotest-suffix
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.1'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '1.1'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: google-style
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,56 +72,56 @@ dependencies:
|
|
86
72
|
requirements:
|
87
73
|
- - "~>"
|
88
74
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
75
|
+
version: '5.14'
|
90
76
|
type: :development
|
91
77
|
prerelease: false
|
92
78
|
version_requirements: !ruby/object:Gem::Requirement
|
93
79
|
requirements:
|
94
80
|
- - "~>"
|
95
81
|
- !ruby/object:Gem::Version
|
96
|
-
version: '5.
|
82
|
+
version: '5.14'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
|
-
name: minitest-
|
84
|
+
name: minitest-focus
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
100
86
|
requirements:
|
101
87
|
- - "~>"
|
102
88
|
- !ruby/object:Gem::Version
|
103
|
-
version: '1.
|
89
|
+
version: '1.1'
|
104
90
|
type: :development
|
105
91
|
prerelease: false
|
106
92
|
version_requirements: !ruby/object:Gem::Requirement
|
107
93
|
requirements:
|
108
94
|
- - "~>"
|
109
95
|
- !ruby/object:Gem::Version
|
110
|
-
version: '1.
|
96
|
+
version: '1.1'
|
111
97
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: minitest-
|
98
|
+
name: minitest-rg
|
113
99
|
requirement: !ruby/object:Gem::Requirement
|
114
100
|
requirements:
|
115
101
|
- - "~>"
|
116
102
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
103
|
+
version: '5.2'
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
107
|
requirements:
|
122
108
|
- - "~>"
|
123
109
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
110
|
+
version: '5.2'
|
125
111
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
112
|
+
name: rake
|
127
113
|
requirement: !ruby/object:Gem::Requirement
|
128
114
|
requirements:
|
129
|
-
- - "
|
115
|
+
- - ">="
|
130
116
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
117
|
+
version: '12.0'
|
132
118
|
type: :development
|
133
119
|
prerelease: false
|
134
120
|
version_requirements: !ruby/object:Gem::Requirement
|
135
121
|
requirements:
|
136
|
-
- - "
|
122
|
+
- - ">="
|
137
123
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
124
|
+
version: '12.0'
|
139
125
|
- !ruby/object:Gem::Dependency
|
140
126
|
name: redcarpet
|
141
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
198
|
- !ruby/object:Gem::Version
|
213
199
|
version: '0'
|
214
200
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
201
|
+
rubygems_version: 3.2.6
|
216
202
|
signing_key:
|
217
203
|
specification_version: 4
|
218
204
|
summary: API Client library for the Cloud Natural Language API
|