google-cloud-language 1.1.0 → 1.2.3

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: 1e1359ca7a1a84099d3e3f43f8422eee5e6a21b204b76f486890aef31ac5b4a5
4
- data.tar.gz: 34d7749401d3c669e3283ac93267dea3f183b29085d0be905500dcae5b888b2c
3
+ metadata.gz: 2fe3ebc3b023dbdd9fbc86f64095b4f7d9ef317bd9012fd75fc92228e44e8c48
4
+ data.tar.gz: da788cf6f520d285170a82520dc327290805293dbb276b2d691e20a86b9f2c8d
5
5
  SHA512:
6
- metadata.gz: 89d4f762c92a5850a59b422be11e9fb9e0c06be127c6ba43807af91af4b7d848752cdce53c53b27433c7f966965007fd651903c162b42724b9cd352e64933323
7
- data.tar.gz: cd7c7c2e63c0f151f32d0360ca0cbb294d91887e5666744ca06f669212fa5af91fbc5db91edb97f736e33ac4ed5cf6bacad843148f881e102f531ac4144980c1
6
+ metadata.gz: 27cebf932ac2154cb38ae35c6d60c5d1ac9305dc03cb9a5e3c013f741df2c8d9e6a1cb8521d241d5b20900e9a321cafd03aa2df31b48106b0e0c3967b234dce2
7
+ data.tar.gz: fb904c91522d4500d94611a59ccb2e08cb462169d81664d50205efb0cb97f3ca8553979e95b53663d8f2c00d1a8f70c546f559608ba7b82dbfae72a25436b587
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
- `Google::Cloud::Language::V1::LanguageService::Credentials`):
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 = 10_000
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 = 20_000
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 = 10_000
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: 10_000
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: 10_000
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
@@ -6,9 +6,10 @@ Provides natural language understanding technologies, such as sentiment analysis
6
6
 
7
7
  Actual client classes for the various versions of this API are defined in
8
8
  _versioned_ client gems, with names of the form `google-cloud-language-v*`.
9
- The gem `google-cloud-language` is a convenience wrapper library that brings the
9
+ The gem `google-cloud-language` is the main client library that brings the
10
10
  verisoned gems in as dependencies, and provides high-level methods for
11
- constructing clients.
11
+ constructing clients. More information on versioned clients can be found below
12
+ in the section titled *Which client should I use?*.
12
13
 
13
14
  View the [Client Library Documentation](https://googleapis.dev/ruby/google-cloud-language/latest)
14
15
  for this library, google-cloud-language, to see the convenience methods for
@@ -78,3 +79,61 @@ in security maintenance, and not end of life. Currently, this means Ruby 2.4
78
79
  and later. Older versions of Ruby _may_ still work, but are unsupported and not
79
80
  recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
80
81
  about the Ruby support schedule.
82
+
83
+ ## Which client should I use?
84
+
85
+ Most modern Ruby client libraries for Google APIs come in two flavors: the main
86
+ client library with a name such as `google-cloud-language`,
87
+ and lower-level _versioned_ client libraries with names such as
88
+ `google-cloud-language-v1`.
89
+ _In most cases, you should install the main client._
90
+
91
+ ### What's the difference between the main client and a versioned client?
92
+
93
+ A _versioned client_ provides a basic set of data types and client classes for
94
+ a _single version_ of a specific service. (That is, for a service with multiple
95
+ versions, there might be a separate versioned client for each service version.)
96
+ Most versioned clients are written and maintained by a code generator.
97
+
98
+ The _main client_ is designed to provide you with the _recommended_ client
99
+ interfaces for the service. There will be only one main client for any given
100
+ service, even a service with multiple versions. The main client includes
101
+ factory methods for constructing the client objects we recommend for most
102
+ users. In some cases, those will be classes provided by an underlying versioned
103
+ client; in other cases, they will be handwritten higher-level client objects
104
+ with additional capabilities, convenience methods, or best practices built in.
105
+ Generally, the main client will default to a recommended service version,
106
+ although in some cases you can override this if you need to talk to a specific
107
+ service version.
108
+
109
+ ### Why would I want to use the main client?
110
+
111
+ We recommend that most users install the main client gem for a service. You can
112
+ identify this gem as the one _without_ a version in its name, e.g.
113
+ `google-cloud-language`.
114
+ The main client is recommended because it will embody the best practices for
115
+ accessing the service, and may also provide more convenient interfaces or
116
+ tighter integration into frameworks and third-party libraries. In addition, the
117
+ documentation and samples published by Google will generally demonstrate use of
118
+ the main client.
119
+
120
+ ### Why would I want to use a versioned client?
121
+
122
+ You can use a versioned client if you are content with a possibly lower-level
123
+ class interface, you explicitly want to avoid features provided by the main
124
+ client, or you want to access a specific service version not be covered by the
125
+ main client. You can identify versioned client gems because the service version
126
+ is part of the name, e.g. `google-cloud-language-v1`.
127
+
128
+ ### What about the google-apis-<name> clients?
129
+
130
+ Client library gems with names that begin with `google-apis-` are based on an
131
+ older code generation technology. They talk to a REST/JSON backend (whereas
132
+ most modern clients talk to a [gRPC](https://grpc.io/) backend) and they may
133
+ not offer the same performance, features, and ease of use provided by more
134
+ modern clients.
135
+
136
+ The `google-apis-` clients have wide coverage across Google services, so you
137
+ might need to use one if there is no modern client available for the service.
138
+ However, if a modern client is available, we generally recommend it over the
139
+ older `google-apis-` clients.
@@ -16,4 +16,4 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
19
- require "google/cloud/language"
19
+ require "google/cloud/language" unless defined? Google::Cloud::Language::VERSION
@@ -16,21 +16,29 @@
16
16
 
17
17
  # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
18
 
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.
19
23
  require "google/cloud/language/version"
24
+
20
25
  require "googleauth"
21
26
  gem "google-cloud-core"
22
- require "google/cloud" unless defined? Google::Cloud.new
27
+ require "google/cloud" unless defined? ::Google::Cloud.new
23
28
  require "google/cloud/config"
24
29
 
25
30
  # Set the default configuration
26
- Google::Cloud.configure.add_config! :language do |config|
27
- config.add_field! :credentials, nil, match: [String, Hash, Google::Auth::Credentials]
28
- config.add_field! :lib_name, nil, match: String
29
- config.add_field! :lib_version, nil, match: String
30
- config.add_field! :interceptors, nil, match: Array
31
- config.add_field! :timeout, nil, match: Numeric
32
- config.add_field! :metadata, nil, match: Hash
33
- config.add_field! :retry_policy, nil, match: [Hash, Proc]
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
34
42
  end
35
43
 
36
44
  module Google
@@ -52,7 +60,7 @@ module Google
52
60
  # Provides text analysis operations such as sentiment analysis and entity
53
61
  # recognition.
54
62
  #
55
- # @param version [String, Symbol] The API version to connect to. Optional.
63
+ # @param version [::String, ::Symbol] The API version to connect to. Optional.
56
64
  # Defaults to `:v1`.
57
65
  # @return [LanguageService::Client] A client object for the specified version.
58
66
  #
@@ -81,8 +89,8 @@ module Google
81
89
  # The library version as recorded in instrumentation and logging.
82
90
  # * `interceptors` (*type:* `Array<GRPC::ClientInterceptor>`) -
83
91
  # An array of interceptors that are run before calls are executed.
84
- # * `timeout` (*type:* `Integer`) -
85
- # Default timeout in milliseconds.
92
+ # * `timeout` (*type:* `Numeric`) -
93
+ # Default timeout in seconds.
86
94
  # * `metadata` (*type:* `Hash{Symbol=>String}`) -
87
95
  # Additional gRPC headers to be sent with the call.
88
96
  # * `retry_policy` (*type:* `Hash`) -
@@ -93,13 +101,16 @@ module Google
93
101
  # * `:retry_codes` (*type:* `Array<String>`) -
94
102
  # The error codes that should trigger a retry.
95
103
  #
96
- # @return [Google::Cloud::Config] The default configuration used by this library
104
+ # @return [::Google::Cloud::Config] The default configuration used by this library
97
105
  #
98
106
  def self.configure
99
- yield Google::Cloud.configure.language if block_given?
107
+ yield ::Google::Cloud.configure.language if block_given?
100
108
 
101
- Google::Cloud.configure.language
109
+ ::Google::Cloud.configure.language
102
110
  end
103
111
  end
104
112
  end
105
113
  end
114
+
115
+ helper_path = ::File.join __dir__, "language", "helpers.rb"
116
+ require "google/cloud/language/helpers" if ::File.file? helper_path
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Language
19
- VERSION = "1.1.0".freeze
19
+ VERSION = "1.2.3".freeze
20
20
  end
21
21
  end
22
22
  end
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.1.0
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Google LLC
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-13 00:00:00.000000000 Z
11
+ date: 2021-02-03 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.10'
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.10'
82
+ version: '5.14'
97
83
  - !ruby/object:Gem::Dependency
98
- name: minitest-autotest
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.0'
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.0'
96
+ version: '1.1'
111
97
  - !ruby/object:Gem::Dependency
112
- name: minitest-focus
98
+ name: minitest-rg
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: '1.1'
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: '1.1'
110
+ version: '5.2'
125
111
  - !ruby/object:Gem::Dependency
126
- name: minitest-rg
112
+ name: rake
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
- - - "~>"
115
+ - - ">="
130
116
  - !ruby/object:Gem::Version
131
- version: '5.2'
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: '5.2'
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.0.6
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