google-cloud-language 0.24.0 → 0.25.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: f4746ad71299b97d1c90269c16d10011255303e5
4
- data.tar.gz: 38a1b60ef127d27c7272f580e83163ab4595f89b
3
+ metadata.gz: df16876f8d54ce54873bd66d47d90b207e65bd89
4
+ data.tar.gz: f60733814fec29c26b3f8f8a40e8f18de13e911b
5
5
  SHA512:
6
- metadata.gz: eb9797c45b158d81f825900385e9e06bfdd2e26974c6b007df8a4d84c5785b2db93b52de3f5b289c37e3a2b080b5a00626a7c1a8e8c29f84511910fe863a68be
7
- data.tar.gz: 87d8d3b512ad3c3d9b8eac5d5323084a1b9188160972d2da14e585bdd6dfd38c73c682cadd5339ce676be2a5b2a6d825e71eb93a80cbd00a535b8cee437c1539
6
+ metadata.gz: 75373df4a6ac03614b09f34557085f411b455868a7af9cf703f954802b3c63f594370d2c32e662cc481cc368ef27c109817828b78c15f9551f7ef55117bb207b
7
+ data.tar.gz: 9a9dd67b2e28594d51a7fb91deff73f5645bff688971c96acc41a3d7d982cef30ed18f98f4698d35d77391ba01ae733bd07d392f1e9994a57bddfca73f0463a4
@@ -53,14 +53,11 @@ module Google
53
53
  #
54
54
  # ## Creating documents
55
55
  #
56
- # Cloud Natural Language API supports UTF-8, UTF-16, and UTF-32 encodings.
57
- # (Ruby uses UTF-8 natively, which is the default sent to the API, so unless
58
- # you're working with text processed in different platform, you should not
59
- # need to set the encoding type.) Be aware that only English, Spanish, and
60
- # Japanese language content are supported.
61
- #
62
56
  # Use {Language::Project#document} to create documents for the Cloud Natural
63
- # Language service. You can provide text or HTML content as a string:
57
+ # Language service. (The Cloud Natural Language API currently supports
58
+ # English, Spanish, and Japanese.)
59
+ #
60
+ # You can provide text or HTML content as a string:
64
61
  #
65
62
  # ```ruby
66
63
  # require "google/cloud/language"
@@ -188,9 +185,8 @@ module Google
188
185
  #
189
186
  # content = "Star Wars is a great movie. The Death Star is fearsome."
190
187
  # document = language.document content
191
- # annotation = document.annotate entities: true, text: true
188
+ # annotation = document.annotate entities: true, syntax: true
192
189
  #
193
- # annotation.sentiment #=> nil
194
190
  # annotation.entities.count #=> 3
195
191
  # annotation.sentences.count #=> 2
196
192
  # annotation.tokens.count #=> 13
@@ -240,9 +240,17 @@ module Google
240
240
  # Represents a piece of text including relative location.
241
241
  #
242
242
  # @attr_reader [String] text The content of the output text.
243
- # @attr_reader [Integer] offset The API calculates the beginning offset
244
- # of the content in the original document according to the `encoding`
245
- # specified in the API request.
243
+ # @attr_reader [Integer] offset The beginning offset
244
+ # of the content in the original document.
245
+ #
246
+ # The API calculates the beginning offset according to the client
247
+ # system's default encoding. In Ruby this defaults to UTF-8. To change
248
+ # the offset calculation you will need to change Ruby's default
249
+ # encoding. This is commonly done by setting
250
+ # `Encoding.default_internal` to `Encoding::UTF_16` or
251
+ # `Encoding::UTF_32`. If the system is configured to use an encoding
252
+ # other than UTF-16 or UTF-32 the offset will be calculated using
253
+ # UTF-8.
246
254
  #
247
255
  # @example
248
256
  # require "google/cloud/language"
@@ -384,9 +392,17 @@ module Google
384
392
  alias_method :content, :text
385
393
 
386
394
  ##
387
- # The API calculates the beginning offset of the content in the
388
- # original document according to the `encoding` specified in the
389
- # API request. See {TextSpan#offset}.
395
+ # The beginning offset of the content in the original document. See
396
+ # {TextSpan#offset}.
397
+ #
398
+ # The API calculates the beginning offset according to the client
399
+ # system's default encoding. In Ruby this defaults to UTF-8. To change
400
+ # the offset calculation you will need to change Ruby's default
401
+ # encoding. This is commonly done by setting
402
+ # `Encoding.default_internal` to `Encoding::UTF_16` or
403
+ # `Encoding::UTF_32`. If the system is configured to use an encoding
404
+ # other than UTF-16 or UTF-32 the offset will be calculated using
405
+ # UTF-8.
390
406
  #
391
407
  # @return [Integer]
392
408
  #
@@ -535,11 +551,31 @@ module Google
535
551
  @lemma = lemma
536
552
  end
537
553
 
554
+ ##
555
+ # The content of the output text. See {TextSpan#text}.
556
+ #
557
+ # @return [String]
558
+ #
538
559
  def text
539
560
  @text_span.text
540
561
  end
541
562
  alias_method :content, :text
542
563
 
564
+ ##
565
+ # The beginning offset of the content in the original document. See
566
+ # {TextSpan#offset}.
567
+ #
568
+ # The API calculates the beginning offset according to the client
569
+ # system's default encoding. In Ruby this defaults to UTF-8. To change
570
+ # the offset calculation you will need to change Ruby's default
571
+ # encoding. This is commonly done by setting
572
+ # `Encoding.default_internal` to `Encoding::UTF_16` or
573
+ # `Encoding::UTF_32`. If the system is configured to use an encoding
574
+ # other than UTF-16 or UTF-32 the offset will be calculated using
575
+ # UTF-8.
576
+ #
577
+ # @return [Integer]
578
+ #
543
579
  def offset
544
580
  @text_span.offset
545
581
  end
@@ -632,8 +668,7 @@ module Google
632
668
  #
633
669
  # entities = annotation.entities
634
670
  # entities.count #=> 3
635
- # entities.people.count #=> 1
636
- # entities.artwork.count #=> 1
671
+ # entities.artwork.first.name #=> "Star Wars"
637
672
  #
638
673
  class Entities < DelegateClass(::Array)
639
674
  attr_accessor :language
@@ -941,9 +976,17 @@ module Google
941
976
  alias_method :content, :text
942
977
 
943
978
  ##
944
- # The API calculates the beginning offset of the content in the
945
- # original document according to the `encoding` specified in the
946
- # API request. See {TextSpan#offset}.
979
+ # The beginning offset of the content in the original document. See
980
+ # {TextSpan#offset}.
981
+ #
982
+ # The API calculates the beginning offset according to the client
983
+ # system's default encoding. In Ruby this defaults to UTF-8. To
984
+ # change the offset calculation you will need to change Ruby's
985
+ # default encoding. This is commonly done by setting
986
+ # `Encoding.default_internal` to `Encoding::UTF_16` or
987
+ # `Encoding::UTF_32`. If the system is configured to use an encoding
988
+ # other than UTF-16 or UTF-32 the offset will be calculated using
989
+ # UTF-8.
947
990
  #
948
991
  # @return [Integer]
949
992
  #
@@ -23,11 +23,6 @@ module Google
23
23
  #
24
24
  # Represents a document for the Language service.
25
25
  #
26
- # Cloud Natural Language API supports UTF-8, UTF-16, and UTF-32 encodings.
27
- # (Ruby uses UTF-8 natively, which is the default sent to the API, so
28
- # unless you're working with text processed in different platform, you
29
- # should not need to set the encoding type.)
30
- #
31
26
  # Be aware that only English, Spanish, and Japanese language content are
32
27
  # supported.
33
28
  #
@@ -70,7 +65,7 @@ module Google
70
65
  ##
71
66
  # @private Whether the document source is a Google Cloud Storage URI.
72
67
  #
73
- def url?
68
+ def gcs_url?
74
69
  @grpc.source == :gcs_content_uri
75
70
  end
76
71
 
@@ -99,6 +94,10 @@ module Google
99
94
  # `:html`.
100
95
  #
101
96
  # @example
97
+ # require "google/cloud/language"
98
+ #
99
+ # language = Google::Cloud::Language.new
100
+ #
102
101
  # document = language.document "<p>The Old Man and the Sea</p>"
103
102
  # document.format = :html
104
103
  #
@@ -156,6 +155,10 @@ module Google
156
155
  # accepted.
157
156
  #
158
157
  # @example
158
+ # require "google/cloud/language"
159
+ #
160
+ # language = Google::Cloud::Language.new
161
+ #
159
162
  # document = language.document "<p>El viejo y el mar</p>"
160
163
  # document.language = "es"
161
164
  #
@@ -179,8 +182,6 @@ module Google
179
182
  # @param [Boolean] syntax Whether to perform syntactic analysis.
180
183
  # Optional. The default is `false`. If every feature option is
181
184
  # `false`, **all** features will be performed.
182
- # @param [String] encoding The encoding type used by the API to
183
- # calculate offsets. Optional.
184
185
  #
185
186
  # @return [Annotation] The results of the content analysis.
186
187
  #
@@ -206,20 +207,17 @@ module Google
206
207
  #
207
208
  # content = "Star Wars is a great movie. The Death Star is fearsome."
208
209
  # document = language.document content
209
- # annotation = document.annotate entities: true, text: true
210
+ # annotation = document.annotate entities: true, syntax: true
210
211
  #
211
- # annotation.sentiment #=> nil
212
212
  # annotation.entities.count #=> 3
213
213
  # annotation.sentences.count #=> 2
214
214
  # annotation.tokens.count #=> 13
215
215
  #
216
- def annotate sentiment: false, entities: false, syntax: false,
217
- encoding: nil
216
+ def annotate sentiment: false, entities: false, syntax: false
218
217
  ensure_service!
219
218
  grpc = service.annotate to_grpc, sentiment: sentiment,
220
219
  entities: entities,
221
- syntax: syntax,
222
- encoding: encoding
220
+ syntax: syntax
223
221
  Annotation.from_grpc grpc
224
222
  end
225
223
  alias_method :mark, :annotate
@@ -230,9 +228,6 @@ module Google
230
228
  # given text into a series of sentences and tokens (generally, word
231
229
  # boundaries), providing further analysis on those tokens.
232
230
  #
233
- # @param [String] encoding The encoding type used by the API to
234
- # calculate offsets. Optional.
235
- #
236
231
  # @return [Annotation::Syntax] The results for the content analysis.
237
232
  #
238
233
  # @example
@@ -259,9 +254,9 @@ module Google
259
254
  # token.label #=> :TITLE
260
255
  # token.lemma #=> "Star"
261
256
  #
262
- def syntax encoding: nil
257
+ def syntax
263
258
  ensure_service!
264
- grpc = service.syntax to_grpc, encoding: encoding
259
+ grpc = service.syntax to_grpc
265
260
  Annotation::Syntax.from_grpc grpc
266
261
  end
267
262
 
@@ -270,9 +265,6 @@ module Google
270
265
  # nouns such as public figures, landmarks, etc.) and returns information
271
266
  # about those entities.
272
267
  #
273
- # @param [String] encoding The encoding type used by the API to
274
- # calculate offsets. Optional.
275
- #
276
268
  # @return [Annotation::Entities] The results for the entities analysis.
277
269
  #
278
270
  # @example
@@ -289,9 +281,9 @@ module Google
289
281
  # entities.first.type #=> :WORK_OF_ART
290
282
  # entities.first.mid #=> "/m/06mmr"
291
283
  #
292
- def entities encoding: nil
284
+ def entities
293
285
  ensure_service!
294
- grpc = service.entities to_grpc, encoding: encoding
286
+ grpc = service.entities to_grpc
295
287
  Annotation::Entities.from_grpc grpc
296
288
  end
297
289
 
@@ -301,9 +293,6 @@ module Google
301
293
  # a writer's attitude as positive, negative, or neutral. Currently, only
302
294
  # English is supported for sentiment analysis.
303
295
  #
304
- # @param [String] encoding The encoding type used by the API to
305
- # calculate offsets. Optional.
306
- #
307
296
  # @return [Annotation::Sentiment] The results for the sentiment
308
297
  # analysis.
309
298
  #
@@ -325,9 +314,9 @@ module Google
325
314
  # sentence.sentiment.score #=> 0.699999988079071
326
315
  # sentence.sentiment.magnitude #=> 0.699999988079071
327
316
  #
328
- def sentiment encoding: nil
317
+ def sentiment
329
318
  ensure_service!
330
- grpc = service.sentiment to_grpc, encoding: encoding
319
+ grpc = service.sentiment to_grpc
331
320
  Annotation::Sentiment.from_grpc grpc
332
321
  end
333
322
 
@@ -89,9 +89,10 @@ module Google
89
89
  # to be annotated, or a Cloud Storage URI of the form
90
90
  # `"gs://bucketname/path/to/document.ext"`; or an instance of
91
91
  # Google::Cloud::Storage::File of the text to be annotated.
92
- # @param [String] format The format of the document (TEXT/HTML).
93
- # Optional.
94
- # @param [String] language The language of the document (if not
92
+ # @param [String, Symbol] format The format of the document. Acceptable
93
+ # values are: `text` or `html`. If no format is provided, the document
94
+ # will default to `text`. Optional.
95
+ # @param [String, Symbol] language The language of the document (if not
95
96
  # specified, the language is automatically detected). Both ISO and
96
97
  # BCP-47 language codes are accepted. Optional.
97
98
  #
@@ -153,7 +154,7 @@ module Google
153
154
  # to be annotated, or a Cloud Storage URI of the form
154
155
  # `"gs://bucketname/path/to/document.ext"`; or an instance of
155
156
  # Google::Cloud::Storage::File of the text to be annotated.
156
- # @param [String] language The language of the document (if not
157
+ # @param [String, Symbol] language The language of the document (if not
157
158
  # specified, the language is automatically detected). Both ISO and
158
159
  # BCP-47 language codes are accepted. Optional.
159
160
  #
@@ -171,7 +172,7 @@ module Google
171
172
  # to be annotated, or a Cloud Storage URI of the form
172
173
  # `"gs://bucketname/path/to/document.ext"`; or an instance of
173
174
  # Google::Cloud::Storage::File of the text to be annotated.
174
- # @param [String] language The language of the document (if not
175
+ # @param [String, Symbol] language The language of the document (if not
175
176
  # specified, the language is automatically detected). Both ISO and
176
177
  # BCP-47 language codes are accepted. Optional.
177
178
  #
@@ -201,13 +202,11 @@ module Google
201
202
  # @param [Boolean] syntax Whether to perform the syntactic analysis.
202
203
  # Optional. The default is `false`. If every feature option is
203
204
  # `false`, **all** features will be performed.
204
- # @param [String] format The format of the document (TEXT/HTML).
205
- # Optional.
206
- # @param [String] language The language of the document (if not
205
+ # @param [String, Symbol] format The format of the document. Acceptable
206
+ # values are: `text` or `html`. Optional.
207
+ # @param [String, Symbol] language The language of the document (if not
207
208
  # specified, the language is automatically detected). Both ISO and
208
209
  # BCP-47 language codes are accepted. Optional.
209
- # @param [String] encoding The encoding type used by the API to
210
- # calculate offsets. Optional.
211
210
  #
212
211
  # @return [Annotation] The results for the content analysis.
213
212
  #
@@ -226,13 +225,12 @@ module Google
226
225
  # annotation.tokens.count #=> 13
227
226
  #
228
227
  def annotate content, sentiment: false, entities: false, syntax: false,
229
- format: nil, language: nil, encoding: nil
228
+ format: nil, language: nil
230
229
  ensure_service!
231
230
  doc = document content, language: language, format: format
232
231
  grpc = service.annotate doc.to_grpc, sentiment: sentiment,
233
232
  entities: entities,
234
- syntax: syntax,
235
- encoding: encoding
233
+ syntax: syntax
236
234
  Annotation.from_grpc grpc
237
235
  end
238
236
  alias_method :mark, :annotate
@@ -247,13 +245,11 @@ module Google
247
245
  # content to annotate. This can be an {Document} instance, or any
248
246
  # other type that converts to an {Document}. See {#document} for
249
247
  # details.
250
- # @param [String] format The format of the document (TEXT/HTML).
251
- # Optional.
252
- # @param [String] language The language of the document (if not
248
+ # @param [String, Symbol] format The format of the document. Acceptable
249
+ # values are: `text` or `html`. Optional.
250
+ # @param [String, Symbol] language The language of the document (if not
253
251
  # specified, the language is automatically detected). Both ISO and
254
252
  # BCP-47 language codes are accepted. Optional.
255
- # @param [String] encoding The encoding type used by the API to
256
- # calculate offsets. Optional.
257
253
  #
258
254
  # @return [Annotation::Syntax] The results for the content syntax
259
255
  # analysis.
@@ -266,8 +262,7 @@ module Google
266
262
  # content = "Star Wars is a great movie. The Death Star is fearsome."
267
263
  # document = language.document content
268
264
  #
269
- # annotation = language.syntax document
270
- # syntax = annotation.syntax
265
+ # syntax = language.syntax document
271
266
  #
272
267
  # sentence = syntax.sentences.last
273
268
  # sentence.text #=> "The Death Star is fearsome."
@@ -283,10 +278,10 @@ module Google
283
278
  # token.label #=> :TITLE
284
279
  # token.lemma #=> "Star"
285
280
  #
286
- def syntax content, format: nil, language: nil, encoding: nil
281
+ def syntax content, format: nil, language: nil
287
282
  ensure_service!
288
283
  doc = document content, language: language, format: format
289
- grpc = service.syntax doc.to_grpc, encoding: encoding
284
+ grpc = service.syntax doc.to_grpc
290
285
  Annotation::Syntax.from_grpc grpc
291
286
  end
292
287
 
@@ -298,13 +293,11 @@ module Google
298
293
  # @param [String, Document] content The content to annotate. This
299
294
  # can be an {Document} instance, or any other type that converts to an
300
295
  # {Document}. See {#document} for details.
301
- # @param [String] format The format of the document (TEXT/HTML).
302
- # Optional.
303
- # @param [String] language The language of the document (if not
296
+ # @param [String, Symbol] format The format of the document. Acceptable
297
+ # values are: `text` or `html`. Optional.
298
+ # @param [String, Symbol] language The language of the document (if not
304
299
  # specified, the language is automatically detected). Both ISO and
305
300
  # BCP-47 language codes are accepted. Optional.
306
- # @param [String] encoding The encoding type used by the API to
307
- # calculate offsets. Optional.
308
301
  #
309
302
  # @return [Annotation::Entities] The results for the entities analysis.
310
303
  #
@@ -319,10 +312,10 @@ module Google
319
312
  # entities = language.entities document
320
313
  # entities.count #=> 3
321
314
  #
322
- def entities content, format: :text, language: nil, encoding: nil
315
+ def entities content, format: :text, language: nil
323
316
  ensure_service!
324
317
  doc = document content, language: language, format: format
325
- grpc = service.entities doc.to_grpc, encoding: encoding
318
+ grpc = service.entities doc.to_grpc
326
319
  Annotation::Entities.from_grpc grpc
327
320
  end
328
321
 
@@ -335,13 +328,11 @@ module Google
335
328
  # @param [String, Document] content The content to annotate. This
336
329
  # can be an {Document} instance, or any other type that converts to an
337
330
  # {Document}. See {#document} for details.
338
- # @param [String] format The format of the document (TEXT/HTML).
339
- # Optional.
340
- # @param [String] language The language of the document (if not
331
+ # @param [String, Symbol] format The format of the document. Acceptable
332
+ # values are: `text` or `html`. Optional.
333
+ # @param [String, Symbol] language The language of the document (if not
341
334
  # specified, the language is automatically detected). Both ISO and
342
335
  # BCP-47 language codes are accepted. Optional.
343
- # @param [String] encoding The encoding type used by the API to
344
- # calculate offsets. Optional.
345
336
  #
346
337
  # @return [Annotation::Sentiment] The results for the sentiment
347
338
  # analysis.
@@ -364,10 +355,10 @@ module Google
364
355
  # sentence.sentiment.score #=> 0.699999988079071
365
356
  # sentence.sentiment.magnitude #=> 0.699999988079071
366
357
  #
367
- def sentiment content, format: :text, language: nil, encoding: nil
358
+ def sentiment content, format: :text, language: nil
368
359
  ensure_service!
369
360
  doc = document content, language: language, format: format
370
- grpc = service.sentiment doc.to_grpc, encoding: encoding
361
+ grpc = service.sentiment doc.to_grpc
371
362
  Annotation::Sentiment.from_grpc grpc
372
363
  end
373
364
 
@@ -57,8 +57,8 @@ module Google
57
57
  channel: channel,
58
58
  timeout: timeout,
59
59
  client_config: client_config,
60
- app_name: "gcloud-ruby",
61
- app_version: Google::Cloud::Language::VERSION)
60
+ lib_name: "gccl",
61
+ lib_version: Google::Cloud::Language::VERSION)
62
62
  end
63
63
  attr_accessor :mocked_service
64
64
 
@@ -68,8 +68,7 @@ module Google
68
68
 
69
69
  ##
70
70
  # Returns API::BatchAnnotateImagesResponse
71
- def annotate doc_grpc, syntax: false, entities: false, sentiment: false,
72
- encoding: nil
71
+ def annotate doc_grpc, syntax: false, entities: false, sentiment: false
73
72
  if syntax == false && entities == false && sentiment == false
74
73
  syntax = true
75
74
  entities = true
@@ -78,33 +77,29 @@ module Google
78
77
  features = V1::AnnotateTextRequest::Features.new(
79
78
  extract_syntax: syntax, extract_entities: entities,
80
79
  extract_document_sentiment: sentiment)
81
- encoding = verify_encoding! encoding
82
80
  execute do
83
- service.annotate_text doc_grpc, features, encoding,
81
+ service.annotate_text doc_grpc, features, default_encoding,
84
82
  options: default_options
85
83
  end
86
84
  end
87
85
 
88
- def syntax doc_grpc, encoding: nil
89
- encoding = verify_encoding! encoding
86
+ def syntax doc_grpc
90
87
  execute do
91
- service.analyze_syntax doc_grpc, encoding,
88
+ service.analyze_syntax doc_grpc, default_encoding,
92
89
  options: default_options
93
90
  end
94
91
  end
95
92
 
96
- def entities doc_grpc, encoding: nil
97
- encoding = verify_encoding! encoding
93
+ def entities doc_grpc
98
94
  execute do
99
- service.analyze_entities doc_grpc, encoding,
95
+ service.analyze_entities doc_grpc, default_encoding,
100
96
  options: default_options
101
97
  end
102
98
  end
103
99
 
104
- def sentiment doc_grpc, encoding: nil
105
- encoding = verify_encoding! encoding
100
+ def sentiment doc_grpc
106
101
  execute do
107
- service.analyze_sentiment doc_grpc, encoding_type: encoding,
102
+ service.analyze_sentiment doc_grpc, encoding_type: default_encoding,
108
103
  options: default_options
109
104
  end
110
105
  end
@@ -115,12 +110,6 @@ module Google
115
110
 
116
111
  protected
117
112
 
118
- def verify_encoding! encoding
119
- # TODO: verify encoding against V1::EncodingType
120
- return :UTF8 if encoding.nil?
121
- encoding
122
- end
123
-
124
113
  def default_headers
125
114
  { "google-cloud-resource-prefix" => "projects/#{@project}" }
126
115
  end
@@ -129,6 +118,19 @@ module Google
129
118
  Google::Gax::CallOptions.new kwargs: default_headers
130
119
  end
131
120
 
121
+ def default_encoding
122
+ utf_16_encodings = [Encoding::UTF_16, Encoding::UTF_16BE,
123
+ Encoding::UTF_16LE]
124
+ return :UTF16 if utf_16_encodings.include? Encoding.default_internal
125
+
126
+ utf_32_encodings = [Encoding::UTF_32, Encoding::UTF_32BE,
127
+ Encoding::UTF_32LE]
128
+ return :UTF32 if utf_32_encodings.include? Encoding.default_internal
129
+
130
+ # The default encoding_type for all other system settings
131
+ :UTF8
132
+ end
133
+
132
134
  def execute
133
135
  yield
134
136
  rescue Google::Gax::GaxError => e
@@ -1,10 +1,10 @@
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.
5
5
  # You may obtain a copy of the License at
6
6
  #
7
- # http://www.apache.org/licenses/LICENSE-2.0
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
8
  #
9
9
  # Unless required by applicable law or agreed to in writing, software
10
10
  # distributed under the License is distributed on an "AS IS" BASIS,
@@ -912,4 +912,4 @@ module Google
912
912
  end
913
913
  end
914
914
  end
915
- end
915
+ end
@@ -46,8 +46,6 @@ module Google
46
46
  # The default port of the service.
47
47
  DEFAULT_SERVICE_PORT = 443
48
48
 
49
- CODE_GEN_NAME_VERSION = "gapic/0.1.0".freeze
50
-
51
49
  DEFAULT_TIMEOUT = 30
52
50
 
53
51
  # The scopes needed to make gRPC calls to all of the methods defined in
@@ -71,10 +69,6 @@ module Google
71
69
  # or the specified config is missing data points.
72
70
  # @param timeout [Numeric]
73
71
  # The default timeout, in seconds, for calls made through this client.
74
- # @param app_name [String]
75
- # The codename of the calling service.
76
- # @param app_version [String]
77
- # The version of the calling service.
78
72
  def initialize \
79
73
  service_path: SERVICE_ADDRESS,
80
74
  port: DEFAULT_SERVICE_PORT,
@@ -83,8 +77,10 @@ module Google
83
77
  scopes: ALL_SCOPES,
84
78
  client_config: {},
85
79
  timeout: DEFAULT_TIMEOUT,
86
- app_name: "gax",
87
- app_version: Google::Gax::VERSION
80
+ app_name: nil,
81
+ app_version: nil,
82
+ lib_name: nil,
83
+ lib_version: ""
88
84
  # These require statements are intentionally placed here to initialize
89
85
  # the gRPC module only when it's required.
90
86
  # See https://github.com/googleapis/toolkit/issues/446
@@ -92,9 +88,16 @@ module Google
92
88
  require "google/cloud/language/v1/language_service_services_pb"
93
89
 
94
90
 
95
- google_api_client = "#{app_name}/#{app_version} " \
96
- "#{CODE_GEN_NAME_VERSION} gax/#{Google::Gax::VERSION} " \
97
- "ruby/#{RUBY_VERSION}".freeze
91
+ if app_name || app_version
92
+ warn "`app_name` and `app_version` are no longer being used in the request headers."
93
+ end
94
+
95
+ google_api_client = "gl-ruby/#{RUBY_VERSION}"
96
+ google_api_client << " #{lib_name}/#{lib_version}" if lib_name
97
+ google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
98
+ google_api_client << " grpc/#{GRPC::VERSION}"
99
+ google_api_client.freeze
100
+
98
101
  headers = { :"x-goog-api-client" => google_api_client }
99
102
  client_config_file = Pathname.new(__dir__).join(
100
103
  "language_service_client_config.json"
@@ -2,11 +2,11 @@
2
2
  "interfaces": {
3
3
  "google.cloud.language.v1.LanguageService": {
4
4
  "retry_codes": {
5
- "idempotent": [
6
- "DEADLINE_EXCEEDED",
7
- "UNAVAILABLE"
8
- ],
9
- "non_idempotent": []
5
+ "idempotent": [
6
+ "DEADLINE_EXCEEDED",
7
+ "UNAVAILABLE"
8
+ ],
9
+ "non_idempotent": []
10
10
  },
11
11
  "retry_params": {
12
12
  "default": {
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Language
19
- VERSION = "0.24.0"
19
+ VERSION = "0.25.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-language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.25.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: 2017-02-21 00:00:00.000000000 Z
12
+ date: 2017-03-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core