google-cloud-vision 0.27.0 → 0.28.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: ca991fc79a01f838fd57527de39a7bc577002fac3f81a0f484e97ab428e9b0b2
4
- data.tar.gz: '08773bcbb9cc86fe51f35721f3547b7be9044df86949dd5b85e798b374f0e0b4'
3
+ metadata.gz: 8b81db07611ab1066ea2ee85b3e8ad26114526acd1b908cc81208419c00fb6d4
4
+ data.tar.gz: ba5bc2654acea5e24ea93b77000b9ffe7140e1a3ae23e242c45fa5df2cf6c7dd
5
5
  SHA512:
6
- metadata.gz: 7675274ee8a7a351444dc170e28b5b9a9bb629bf35d0a6afaab407451d05c6395a06d040642a9f909ef6474293e613f275975cf1fa544405fa37f10f6fd56ef0
7
- data.tar.gz: e4e0671f7a59e33374981330abdd6a6a7aeb8c6233bcd0808081ca54f61617343129786be3a373df089e136fb4f99b1baed7b0493ce8a2488200535699866c03
6
+ metadata.gz: 104e8b736e5e34d528ea4ca58c6705d1b8e8de4a0f641593746edb0388e05f3c53e9ada250271a7fdf1f8d6a54579769c98fcd025a6248333d597f227216455c
7
+ data.tar.gz: 5eca611c1e4291e9d6aaf38d5a0d0e34896b9d265ff5e57065752c0bb3797baa8b6213d16f0f9fd2d60c810885ece8768919a9d05a9e8c027415cd0f0f0ad604
@@ -20,6 +20,8 @@
20
20
 
21
21
  gem "google-cloud-core"
22
22
  require "google/cloud"
23
+ require "google/cloud/config"
24
+ require "googleauth"
23
25
 
24
26
  module Google
25
27
  module Cloud
@@ -109,3 +111,34 @@ module Google
109
111
  end
110
112
  end
111
113
  end
114
+
115
+ # Set the default vision configuration
116
+ Google::Cloud.configure.add_config! :vision do |config|
117
+ default_project = Google::Cloud::Config.deferred do
118
+ ENV["VISION_PROJECT"]
119
+ end
120
+ default_creds = Google::Cloud::Config.deferred do
121
+ Google::Cloud::Config.credentials_from_env(
122
+ "VISION_CREDENTIALS", "VISION_CREDENTIALS_JSON",
123
+ "VISION_KEYFILE", "VISION_KEYFILE_JSON"
124
+ )
125
+ end
126
+
127
+ config.add_field! :project_id, default_project, match: String, allow_nil: true
128
+ config.add_alias! :project, :project_id
129
+ config.add_field! :credentials, default_creds,
130
+ match: [String, Hash, Google::Auth::Credentials],
131
+ allow_nil: true
132
+ config.add_alias! :keyfile, :credentials
133
+ config.add_field! :scope, nil, match: [String, Array]
134
+ config.add_field! :timeout, nil, match: Integer
135
+ config.add_field! :client_config, nil, match: Hash
136
+ # Update the documentation on the Vision module methods when these
137
+ # defaults change.
138
+ config.add_field! :default_max_faces, 100
139
+ config.add_field! :default_max_landmarks, 100
140
+ config.add_field! :default_max_logos, 100
141
+ config.add_field! :default_max_labels, 100
142
+ config.add_field! :default_max_crop_hints, 100
143
+ config.add_field! :default_max_web, 100
144
+ end
@@ -15,6 +15,8 @@
15
15
 
16
16
  require "google-cloud-vision"
17
17
  require "google/cloud/vision/project"
18
+ require "google/cloud/config"
19
+ require "google/cloud/env"
18
20
 
19
21
  module Google
20
22
  module Cloud
@@ -30,11 +32,12 @@ module Google
30
32
  # Documentation](https://cloud.google.com/vision/docs/).
31
33
  #
32
34
  # The goal of google-cloud is to provide an API that is comfortable to
33
- # Rubyists. Authentication is handled by {Google::Cloud#vision}. You can
34
- # provide the project and credential information to connect to the Cloud
35
- # Vision service, or if you are running on Google Compute Engine this
36
- # configuration is taken care of for you. You can read more about the
37
- # options for connecting in the [Authentication
35
+ # Rubyists. Your authentication credentials are detected automatically in
36
+ # Google Cloud Platform environments such as Google Compute Engine, Google
37
+ # App Engine and Google Kubernetes Engine. In other environments you can
38
+ # configure authentication easily, either directly in your code or via
39
+ # environment variables. Read more about the options for connecting in the
40
+ # [Authentication
38
41
  # Guide](https://googlecloudplatform.github.io/google-cloud-ruby/#/docs/guides/authentication).
39
42
  #
40
43
  # ## Creating images
@@ -226,6 +229,9 @@ module Google
226
229
  #
227
230
  # The default value is `100`.
228
231
  #
232
+ # This is also available on the configuration as
233
+ # `Google::Cloud::Vision.configure.default_max_faces`
234
+ #
229
235
  # @example Using the default setting on {Project#annotate}:
230
236
  # require "google/cloud/vision"
231
237
  #
@@ -273,7 +279,16 @@ module Google
273
279
  # # This is the same as calling
274
280
  # # faces = vision.image("path/to/faces.jpg").faces 5
275
281
  #
276
- attr_accessor :default_max_faces
282
+ def default_max_faces= value
283
+ configure.default_max_faces = value
284
+ end
285
+
286
+ ##
287
+ # The default max results to return for face detection requests.
288
+ #
289
+ def default_max_faces
290
+ configure.default_max_faces
291
+ end
277
292
 
278
293
  ##
279
294
  # The default max results to return for landmark detection requests.
@@ -281,6 +296,9 @@ module Google
281
296
  #
282
297
  # The default value is 100.
283
298
  #
299
+ # This is also available on the configuration as
300
+ # `Google::Cloud::Vision.configure.default_max_landmarks`
301
+ #
284
302
  # @example Using the default setting on {Project#annotate}:
285
303
  # require "google/cloud/vision"
286
304
  #
@@ -330,7 +348,16 @@ module Google
330
348
  # # This is the same as calling
331
349
  # # landmarks = vision.image("path/to/landmarks.jpg").landmarks 5
332
350
  #
333
- attr_accessor :default_max_landmarks
351
+ def default_max_landmarks= value
352
+ configure.default_max_landmarks = value
353
+ end
354
+
355
+ ##
356
+ # The default max results to return for landmark detection requests.
357
+ #
358
+ def default_max_landmarks
359
+ configure.default_max_landmarks
360
+ end
334
361
 
335
362
  ##
336
363
  # The default max results to return for logo detection requests. This is
@@ -338,6 +365,9 @@ module Google
338
365
  #
339
366
  # The default value is 100.
340
367
  #
368
+ # This is also available on the configuration as
369
+ # `Google::Cloud::Vision.configure.default_max_logos`
370
+ #
341
371
  # @example Using the default setting on {Project#annotate}:
342
372
  # require "google/cloud/vision"
343
373
  #
@@ -385,7 +415,16 @@ module Google
385
415
  # # This is the same as calling
386
416
  # # logos = vision.image("path/to/logos.jpg").logos 5
387
417
  #
388
- attr_accessor :default_max_logos
418
+ def default_max_logos= value
419
+ configure.default_max_logos = value
420
+ end
421
+
422
+ ##
423
+ # The default max results to return for logo detection requests.
424
+ #
425
+ def default_max_logos
426
+ configure.default_max_logos
427
+ end
389
428
 
390
429
  ##
391
430
  # The default max results to return for label detection requests. This
@@ -393,6 +432,9 @@ module Google
393
432
  #
394
433
  # The default value is 100.
395
434
  #
435
+ # This is also available on the configuration as
436
+ # `Google::Cloud::Vision.configure.default_max_labels`
437
+ #
396
438
  # @example Using the default setting on {Project#annotate}:
397
439
  # require "google/cloud/vision"
398
440
  #
@@ -440,7 +482,16 @@ module Google
440
482
  # # This is the same as calling
441
483
  # # labels = vision.image("path/to/labels.jpg").labels 5
442
484
  #
443
- attr_accessor :default_max_labels
485
+ def default_max_labels= value
486
+ configure.default_max_labels = value
487
+ end
488
+
489
+ ##
490
+ # The default max results to return for label detection requests.
491
+ #
492
+ def default_max_labels
493
+ configure.default_max_labels
494
+ end
444
495
 
445
496
  ##
446
497
  # The default max results to return for crop hints detection requests.
@@ -448,6 +499,9 @@ module Google
448
499
  #
449
500
  # The default value is 100.
450
501
  #
502
+ # This is also available on the configuration as
503
+ # `Google::Cloud::Vision.configure.default_max_crop_hints`
504
+ #
451
505
  # @example Using the default setting on {Project#annotate}:
452
506
  # require "google/cloud/vision"
453
507
  #
@@ -497,7 +551,16 @@ module Google
497
551
  # # This is the same as calling
498
552
  # # crop_hints = vision.image("path/to/landmarks.jpg").crop_hints 5
499
553
  #
500
- attr_accessor :default_max_crop_hints
554
+ def default_max_crop_hints= value
555
+ configure.default_max_crop_hints = value
556
+ end
557
+
558
+ ##
559
+ # The default max results to return for crop hints detection requests.
560
+ #
561
+ def default_max_crop_hints
562
+ configure.default_max_crop_hints
563
+ end
501
564
 
502
565
  ##
503
566
  # The default max results to return for web detection requests.
@@ -505,6 +568,9 @@ module Google
505
568
  #
506
569
  # The default value is 100.
507
570
  #
571
+ # This is also available on the configuration as
572
+ # `Google::Cloud::Vision.configure.default_max_web`
573
+ #
508
574
  # @example Using the default setting on {Project#annotate}:
509
575
  # require "google/cloud/vision"
510
576
  #
@@ -554,17 +620,17 @@ module Google
554
620
  # # This is the same as calling
555
621
  # # web = vision.image("path/to/landmarks.jpg").web 5
556
622
  #
557
- attr_accessor :default_max_web
558
- end
623
+ def default_max_web= value
624
+ configure.default_max_web = value
625
+ end
559
626
 
560
- # Set the default values.
561
- # Update the comments documentation when these change.
562
- self.default_max_faces = 100
563
- self.default_max_landmarks = 100
564
- self.default_max_logos = 100
565
- self.default_max_labels = 100
566
- self.default_max_crop_hints = 100
567
- self.default_max_web = 100
627
+ ##
628
+ # The default max results to return for web detection requests.
629
+ #
630
+ def default_max_web
631
+ configure.default_max_web
632
+ end
633
+ end
568
634
 
569
635
  ##
570
636
  # Creates a new object for connecting to the Vision service.
@@ -605,11 +671,14 @@ module Google
605
671
  #
606
672
  def self.new project_id: nil, credentials: nil, scope: nil, timeout: nil,
607
673
  client_config: nil, project: nil, keyfile: nil
608
- project_id ||= (project || Vision::Project.default_project_id)
674
+ project_id ||= (project || default_project_id)
609
675
  project_id = project_id.to_s # Always cast to a string
610
- fail ArgumentError, "project_id is missing" if project_id.empty?
676
+ raise ArgumentError, "project_id is missing" if project_id.empty?
611
677
 
612
- credentials ||= (keyfile || Vision::Credentials.default(scope: scope))
678
+ scope ||= configure.scope
679
+ timeout ||= configure.timeout
680
+ client_config ||= configure.client_config
681
+ credentials ||= (keyfile || default_credentials(scope: scope))
613
682
  unless credentials.is_a? Google::Auth::Credentials
614
683
  credentials = Vision::Credentials.new credentials, scope: scope
615
684
  end
@@ -617,7 +686,64 @@ module Google
617
686
  Vision::Project.new(
618
687
  Vision::Service.new(
619
688
  project_id, credentials, timeout: timeout,
620
- client_config: client_config))
689
+ client_config: client_config
690
+ )
691
+ )
692
+ end
693
+
694
+ ##
695
+ # Configure the Google Cloud Vision library.
696
+ #
697
+ # The following Vision configuration parameters are supported:
698
+ #
699
+ # * `project_id` - (String) Identifier for a Vision project. (The
700
+ # parameter `project` is considered deprecated, but may also be used.)
701
+ # * `credentials` - (String, Hash, Google::Auth::Credentials) The path to
702
+ # the keyfile as a String, the contents of the keyfile as a Hash, or a
703
+ # Google::Auth::Credentials object. (See {Vision::Credentials}) (The
704
+ # parameter `keyfile` is considered deprecated, but may also be used.)
705
+ # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
706
+ # the set of resources and operations that the connection can access.
707
+ # * `timeout` - (Integer) Default timeout to use in requests.
708
+ # * `client_config` - (Hash) A hash of values to override the default
709
+ # behavior of the API client.
710
+ # * `default_max_faces` - (Integer) The default max results to return for
711
+ # facial detection requests. See {Vision.default_max_faces=}.
712
+ # * `default_max_landmarks` - (Integer) The default max results to return
713
+ # for landmark detection requests. See {Vision.default_max_landmarks=}.
714
+ # * `default_max_logos` - (Integer) The default max results to return for
715
+ # logo detection requests. See {Vision.default_max_logos=}.
716
+ # * `default_max_labels` - (Integer) The default max results to return for
717
+ # label detection requests. See {Vision.default_max_labels=}.
718
+ # * `default_max_crop_hints` - (Integer) The default max results to return
719
+ # for crop hints detection requests. See
720
+ # {Vision.default_max_crop_hints=}.
721
+ # * `default_max_web` - (Integer) The default max results to return for
722
+ # web detection requests. See {Vision.default_max_faces=}.
723
+ #
724
+ # @return [Google::Cloud::Config] The configuration object the
725
+ # Google::Cloud::Vision library uses.
726
+ #
727
+ def self.configure
728
+ yield Google::Cloud.configure.vision if block_given?
729
+
730
+ Google::Cloud.configure.vision
731
+ end
732
+
733
+ ##
734
+ # @private Default project.
735
+ def self.default_project_id
736
+ Google::Cloud.configure.vision.project_id ||
737
+ Google::Cloud.configure.project_id ||
738
+ Google::Cloud.env.project_id
739
+ end
740
+
741
+ ##
742
+ # @private Default credentials.
743
+ def self.default_credentials scope: nil
744
+ Google::Cloud.configure.vision.credentials ||
745
+ Google::Cloud.configure.credentials ||
746
+ Vision::Credentials.default(scope: scope)
621
747
  end
622
748
  end
623
749
  end
@@ -177,10 +177,12 @@ module Google
177
177
  safe_search, properties, crop_hints, web
178
178
  return default_features if default_features?(
179
179
  faces, landmarks, logos, labels, text, document, safe_search,
180
- properties, crop_hints, web)
180
+ properties, crop_hints, web
181
+ )
181
182
 
182
183
  faces, landmarks, logos, labels, crop_hints, web = validate_max_args(
183
- faces, landmarks, logos, labels, crop_hints, web)
184
+ faces, landmarks, logos, labels, crop_hints, web
185
+ )
184
186
 
185
187
  f = value_features faces, landmarks, logos, labels, crop_hints, web
186
188
  f + boolean_features(text, document, safe_search, properties)
@@ -208,7 +210,8 @@ module Google
208
210
 
209
211
  def feature type, max_results
210
212
  Google::Cloud::Vision::V1::Feature.new(
211
- type: type, max_results: max_results)
213
+ type: type, max_results: max_results
214
+ )
212
215
  end
213
216
 
214
217
  def default_features? faces, landmarks, logos, labels, text, document,
@@ -237,18 +240,24 @@ module Google
237
240
  end
238
241
 
239
242
  def validate_max_args faces, landmarks, logos, labels, crop_hints, web
240
- faces = validate_max_value(
241
- faces, Google::Cloud::Vision.default_max_faces)
242
- landmarks = validate_max_value(
243
- landmarks, Google::Cloud::Vision.default_max_landmarks)
244
- logos = validate_max_value(
245
- logos, Google::Cloud::Vision.default_max_logos)
246
- labels = validate_max_value(
247
- labels, Google::Cloud::Vision.default_max_labels)
243
+ faces = validate_max_value(
244
+ faces, Google::Cloud::Vision.default_max_faces
245
+ )
246
+ landmarks = validate_max_value(
247
+ landmarks, Google::Cloud::Vision.default_max_landmarks
248
+ )
249
+ logos = validate_max_value(
250
+ logos, Google::Cloud::Vision.default_max_logos
251
+ )
252
+ labels = validate_max_value(
253
+ labels, Google::Cloud::Vision.default_max_labels
254
+ )
248
255
  crop_hints = validate_max_value(
249
- crop_hints, Google::Cloud::Vision.default_max_crop_hints)
250
- web = validate_max_value(
251
- web, Google::Cloud::Vision.default_max_web)
256
+ crop_hints, Google::Cloud::Vision.default_max_crop_hints
257
+ )
258
+ web = validate_max_value(
259
+ web, Google::Cloud::Vision.default_max_web
260
+ )
252
261
  [faces, landmarks, logos, labels, crop_hints, web]
253
262
  end
254
263
 
@@ -376,7 +376,8 @@ module Google
376
376
  def properties
377
377
  return nil unless @grpc.image_properties_annotation
378
378
  @properties ||= Properties.from_grpc(
379
- @grpc.image_properties_annotation)
379
+ @grpc.image_properties_annotation
380
+ )
380
381
  end
381
382
 
382
383
  ##
@@ -173,7 +173,7 @@ module Google
173
173
  def yaw
174
174
  @grpc.pan_angle
175
175
  end
176
- alias_method :pan, :yaw
176
+ alias pan yaw
177
177
 
178
178
  ##
179
179
  # Pitch (tilt) angle. Indicates the upwards/downwards angle that the
@@ -184,7 +184,7 @@ module Google
184
184
  def pitch
185
185
  @grpc.tilt_angle
186
186
  end
187
- alias_method :tilt, :pitch
187
+ alias tilt pitch
188
188
 
189
189
  ##
190
190
  # Returns the object's property values as an array.
@@ -1109,8 +1109,8 @@ module Google
1109
1109
  class Lips
1110
1110
  attr_reader :top, :bottom
1111
1111
 
1112
- alias_method :upper, :top
1113
- alias_method :lower, :bottom
1112
+ alias upper top
1113
+ alias lower bottom
1114
1114
 
1115
1115
  ##
1116
1116
  # @private Creates a new Lips instance.
@@ -1325,7 +1325,7 @@ module Google
1325
1325
  # face.likelihood.sorrow #=> :VERY_UNLIKELY
1326
1326
  #
1327
1327
  class Likelihood
1328
- POSITIVE_RATINGS = %i(POSSIBLE LIKELY VERY_LIKELY)
1328
+ POSITIVE_RATINGS = %i[POSSIBLE LIKELY VERY_LIKELY].freeze
1329
1329
 
1330
1330
  ##
1331
1331
  # @private The FaceAnnotation GRPC object.
@@ -38,7 +38,7 @@ module Google
38
38
  # safe_search.spoof #=> :VERY_UNLIKELY
39
39
  #
40
40
  class SafeSearch
41
- POSITIVE_RATINGS = %i(POSSIBLE LIKELY VERY_LIKELY)
41
+ POSITIVE_RATINGS = %i[POSSIBLE LIKELY VERY_LIKELY].freeze
42
42
 
43
43
  ##
44
44
  # @private The SafeSearchAnnotation GRPC object.
@@ -151,16 +151,16 @@ module Google
151
151
  text, *words = Array grpc_text_annotations
152
152
  return nil if text.nil?
153
153
 
154
+ words = words.map { |w| Word.from_grpc w }
155
+
154
156
  # Since text is taken from grpc_text_annotations, do not use text
155
157
  # from grpc_full_text_annotation in this merged model.
156
158
  # Instead, just take the pages.
157
- pages = grpc_full_text_annotation.pages
159
+ pages = grpc_full_text_annotation.pages.map { |p| Page.from_grpc p }
158
160
  new.tap do |t|
159
161
  t.instance_variable_set :@grpc, text
160
- t.instance_variable_set :@words,
161
- words.map { |w| Word.from_grpc w }
162
- t.instance_variable_set :@pages,
163
- pages.map { |p| Page.from_grpc p }
162
+ t.instance_variable_set :@words, words
163
+ t.instance_variable_set :@pages, pages
164
164
  end
165
165
  end
166
166
 
@@ -38,19 +38,19 @@ module Google
38
38
  # vision.project_id #=> "my-project"
39
39
  #
40
40
  class Credentials < Google::Auth::Credentials
41
- SCOPE = ["https://www.googleapis.com/auth/cloud-platform"]
42
- PATH_ENV_VARS = %w(VISION_CREDENTIALS
41
+ SCOPE = ["https://www.googleapis.com/auth/cloud-platform"].freeze
42
+ PATH_ENV_VARS = %w[VISION_CREDENTIALS
43
43
  VISION_KEYFILE
44
44
  GOOGLE_CLOUD_CREDENTIALS
45
45
  GOOGLE_CLOUD_KEYFILE
46
- GCLOUD_KEYFILE)
47
- JSON_ENV_VARS = %w(VISION_CREDENTIALS_JSON
46
+ GCLOUD_KEYFILE].freeze
47
+ JSON_ENV_VARS = %w[VISION_CREDENTIALS_JSON
48
48
  VISION_KEYFILE_JSON
49
49
  GOOGLE_CLOUD_CREDENTIALS_JSON
50
50
  GOOGLE_CLOUD_KEYFILE_JSON
51
- GCLOUD_KEYFILE_JSON)
51
+ GCLOUD_KEYFILE_JSON].freeze
52
52
  DEFAULT_PATHS = \
53
- ["~/.config/gcloud/application_default_credentials.json"]
53
+ ["~/.config/gcloud/application_default_credentials.json"].freeze
54
54
  end
55
55
  end
56
56
  end
@@ -521,8 +521,8 @@ module Google
521
521
  properties: properties, crop_hints: crop_hints,
522
522
  web: web)
523
523
  end
524
- alias_method :mark, :annotate
525
- alias_method :detect, :annotate
524
+ alias mark annotate
525
+ alias detect annotate
526
526
 
527
527
  # @private
528
528
  def to_s
@@ -550,9 +550,11 @@ module Google
550
550
  elsif url?
551
551
  Google::Cloud::Vision::V1::Image.new(
552
552
  source: Google::Cloud::Vision::V1::ImageSource.new(
553
- image_uri: @url))
553
+ image_uri: @url
554
+ )
555
+ )
554
556
  else
555
- fail ArgumentError, "Unable to use Image with Vision service."
557
+ raise ArgumentError, "Unable to use Image with Vision service."
556
558
  end
557
559
  end
558
560
 
@@ -571,18 +573,18 @@ module Google
571
573
  # Create an image from a file on the filesystem
572
574
  if File.file? source
573
575
  unless File.readable? source
574
- fail ArgumentError, "Cannot read #{source}"
576
+ raise ArgumentError, "Cannot read #{source}"
575
577
  end
576
578
  return from_io(File.open(source, "rb"), vision)
577
579
  end
578
- fail ArgumentError, "Unable to convert #{source} to an Image"
580
+ raise ArgumentError, "Unable to convert #{source} to an Image"
579
581
  end
580
582
 
581
583
  ##
582
584
  # @private New Image from an IO object.
583
585
  def self.from_io io, vision
584
586
  if !io.respond_to?(:read) && !io.respond_to?(:rewind)
585
- fail ArgumentError, "Cannot create an Image without an IO object"
587
+ raise ArgumentError, "Cannot create an Image without an IO object"
586
588
  end
587
589
  new.tap do |i|
588
590
  i.instance_variable_set :@io, io
@@ -595,7 +597,7 @@ module Google
595
597
  def self.from_url url, vision
596
598
  url = String url
597
599
  unless url? url
598
- fail ArgumentError, "Cannot create an Image without a URL"
600
+ raise ArgumentError, "Cannot create an Image without a URL"
599
601
  end
600
602
  new.tap do |i|
601
603
  i.instance_variable_set :@url, url
@@ -615,7 +617,7 @@ module Google
615
617
  ##
616
618
  # Raise an error unless an active vision project object is available.
617
619
  def ensure_vision!
618
- fail "Must have active connection" unless @vision
620
+ raise "Must have active connection" unless @vision
619
621
  end
620
622
  end
621
623
 
@@ -740,11 +742,12 @@ module Google
740
742
  # standard](http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf).
741
743
  def min= location
742
744
  if location.respond_to?(:to_h) &&
743
- location.to_h.keys.sort == [:latitude, :longitude]
744
- return @min = Location.new(location.to_h[:latitude],
745
- location.to_h[:longitude])
745
+ location.to_h.keys.sort == %i[latitude longitude]
746
+ @min = Location.new(location.to_h[:latitude],
747
+ location.to_h[:longitude])
748
+ return
746
749
  end
747
- fail ArgumentError, "Must pass a proper location value."
750
+ raise ArgumentError, "Must pass a proper location value."
748
751
  end
749
752
 
750
753
  ##
@@ -756,11 +759,12 @@ module Google
756
759
  # standard](http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf).
757
760
  def max= location
758
761
  if location.respond_to?(:to_h) &&
759
- location.to_h.keys.sort == [:latitude, :longitude]
760
- return @max = Location.new(location.to_h[:latitude],
761
- location.to_h[:longitude])
762
+ location.to_h.keys.sort == %i[latitude longitude]
763
+ @max = Location.new(location.to_h[:latitude],
764
+ location.to_h[:longitude])
765
+ return
762
766
  end
763
- fail ArgumentError, "Must pass a proper location value."
767
+ raise ArgumentError, "Must pass a proper location value."
764
768
  end
765
769
 
766
770
  ##
@@ -14,7 +14,6 @@
14
14
 
15
15
 
16
16
  require "google/cloud/errors"
17
- require "google/cloud/env"
18
17
  require "google/cloud/vision/service"
19
18
  require "google/cloud/vision/credentials"
20
19
  require "google/cloud/vision/annotate"
@@ -72,16 +71,7 @@ module Google
72
71
  def project_id
73
72
  service.project
74
73
  end
75
- alias_method :project, :project_id
76
-
77
- ##
78
- # @private Default project.
79
- def self.default_project_id
80
- ENV["VISION_PROJECT"] ||
81
- ENV["GOOGLE_CLOUD_PROJECT"] ||
82
- ENV["GCLOUD_PROJECT"] ||
83
- Google::Cloud.env.project_id
84
- end
74
+ alias project project_id
85
75
 
86
76
  ##
87
77
  # Returns a new image from the given source.
@@ -278,21 +268,21 @@ module Google
278
268
 
279
269
  grpc = service.annotate a.requests
280
270
  annotations = Array(grpc.responses).map do |g|
281
- fail Error.from_error(g.error) if g.error
271
+ raise Error.from_error(g.error) if g.error
282
272
  Annotation.from_grpc g
283
273
  end
284
274
  return annotations.first if annotations.count == 1
285
275
  annotations
286
276
  end
287
- alias_method :mark, :annotate
288
- alias_method :detect, :annotate
277
+ alias mark annotate
278
+ alias detect annotate
289
279
 
290
280
  protected
291
281
 
292
282
  ##
293
283
  # Raise an error unless an active connection is available.
294
284
  def ensure_service!
295
- fail "Must have active connection" unless service
285
+ raise "Must have active connection" unless service
296
286
  end
297
287
  end
298
288
  end
@@ -44,7 +44,8 @@ module Google
44
44
  timeout: timeout,
45
45
  client_config: client_config,
46
46
  lib_name: "gccl",
47
- lib_version: Google::Cloud::Vision::VERSION)
47
+ lib_version: Google::Cloud::Vision::VERSION
48
+ )
48
49
  end
49
50
  attr_accessor :mocked_service
50
51
 
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Vision
19
- VERSION = "0.27.0"
19
+ VERSION = "0.28.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-vision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.0
4
+ version: 0.28.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-12-19 00:00:00.000000000 Z
12
+ date: 2018-02-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.1'
20
+ version: '1.2'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.1'
27
+ version: '1.2'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: google-gax
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -113,16 +113,16 @@ dependencies:
113
113
  name: rubocop
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "<="
116
+ - - "~>"
117
117
  - !ruby/object:Gem::Version
118
- version: 0.35.1
118
+ version: 0.50.0
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "<="
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: 0.35.1
125
+ version: 0.50.0
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: simplecov
128
128
  requirement: !ruby/object:Gem::Requirement
@@ -232,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
232
232
  version: '0'
233
233
  requirements: []
234
234
  rubyforge_project:
235
- rubygems_version: 2.7.3
235
+ rubygems_version: 2.7.6
236
236
  signing_key:
237
237
  specification_version: 4
238
238
  summary: API Client library for Google Cloud Vision API