gcloud 0.11.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/AUTHENTICATION.md +3 -3
- data/CHANGELOG.md +92 -0
- data/OVERVIEW.md +3 -3
- data/lib/gcloud.rb +75 -25
- data/lib/gcloud/backoff.rb +5 -1
- data/lib/gcloud/bigquery.rb +25 -43
- data/lib/gcloud/bigquery/copy_job.rb +13 -13
- data/lib/gcloud/bigquery/data.rb +20 -16
- data/lib/gcloud/bigquery/dataset.rb +202 -177
- data/lib/gcloud/bigquery/dataset/access.rb +118 -104
- data/lib/gcloud/bigquery/dataset/list.rb +14 -18
- data/lib/gcloud/bigquery/extract_job.rb +12 -12
- data/lib/gcloud/bigquery/insert_response.rb +12 -14
- data/lib/gcloud/bigquery/job.rb +45 -57
- data/lib/gcloud/bigquery/job/list.rb +18 -24
- data/lib/gcloud/bigquery/load_job.rb +35 -27
- data/lib/gcloud/bigquery/project.rb +53 -73
- data/lib/gcloud/bigquery/query_data.rb +28 -35
- data/lib/gcloud/bigquery/query_job.rb +18 -18
- data/lib/gcloud/bigquery/schema.rb +359 -0
- data/lib/gcloud/bigquery/service.rb +506 -0
- data/lib/gcloud/bigquery/table.rb +185 -266
- data/lib/gcloud/bigquery/table/list.rb +15 -19
- data/lib/gcloud/bigquery/view.rb +126 -81
- data/lib/gcloud/datastore.rb +39 -27
- data/lib/gcloud/datastore/commit.rb +2 -2
- data/lib/gcloud/datastore/dataset.rb +8 -19
- data/lib/gcloud/datastore/dataset/lookup_results.rb +2 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +0 -2
- data/lib/gcloud/datastore/entity.rb +7 -1
- data/lib/gcloud/datastore/errors.rb +5 -27
- data/lib/gcloud/datastore/grpc_utils.rb +4 -3
- data/lib/gcloud/datastore/key.rb +6 -0
- data/lib/gcloud/datastore/service.rb +18 -12
- data/lib/gcloud/datastore/transaction.rb +0 -10
- data/lib/gcloud/dns.rb +29 -19
- data/lib/gcloud/dns/change.rb +10 -15
- data/lib/gcloud/dns/change/list.rb +4 -4
- data/lib/gcloud/dns/importer.rb +1 -1
- data/lib/gcloud/dns/project.rb +32 -49
- data/lib/gcloud/dns/record.rb +8 -2
- data/lib/gcloud/dns/record/list.rb +4 -4
- data/lib/gcloud/dns/service.rb +167 -0
- data/lib/gcloud/dns/zone.rb +33 -52
- data/lib/gcloud/dns/zone/list.rb +12 -16
- data/lib/gcloud/errors.rb +31 -19
- data/lib/gcloud/logging.rb +50 -39
- data/lib/gcloud/logging/entry.rb +197 -24
- data/lib/gcloud/logging/entry/list.rb +0 -2
- data/lib/gcloud/logging/logger.rb +1 -1
- data/lib/gcloud/logging/metric.rb +3 -9
- data/lib/gcloud/logging/metric/list.rb +0 -2
- data/lib/gcloud/logging/project.rb +58 -54
- data/lib/gcloud/logging/resource_descriptor.rb +2 -2
- data/lib/gcloud/logging/resource_descriptor/list.rb +0 -2
- data/lib/gcloud/logging/service.rb +32 -23
- data/lib/gcloud/logging/sink.rb +8 -14
- data/lib/gcloud/logging/sink/list.rb +0 -2
- data/lib/gcloud/pubsub.rb +21 -16
- data/lib/gcloud/pubsub/policy.rb +204 -0
- data/lib/gcloud/pubsub/project.rb +26 -38
- data/lib/gcloud/pubsub/service.rb +39 -31
- data/lib/gcloud/pubsub/subscription.rb +56 -59
- data/lib/gcloud/pubsub/subscription/list.rb +4 -4
- data/lib/gcloud/pubsub/topic.rb +69 -66
- data/lib/gcloud/pubsub/topic/list.rb +0 -2
- data/lib/gcloud/pubsub/topic/{batch.rb → publisher.rb} +15 -2
- data/lib/gcloud/resource_manager.rb +27 -26
- data/lib/gcloud/resource_manager/manager.rb +19 -39
- data/lib/gcloud/resource_manager/policy.rb +211 -0
- data/lib/gcloud/resource_manager/project.rb +97 -121
- data/lib/gcloud/resource_manager/project/list.rb +7 -7
- data/lib/gcloud/resource_manager/project/updater.rb +4 -9
- data/lib/gcloud/resource_manager/service.rb +127 -0
- data/lib/gcloud/storage.rb +24 -42
- data/lib/gcloud/storage/bucket.rb +104 -192
- data/lib/gcloud/storage/bucket/acl.rb +47 -143
- data/lib/gcloud/storage/bucket/cors.rb +55 -11
- data/lib/gcloud/storage/bucket/list.rb +14 -14
- data/lib/gcloud/storage/errors.rb +3 -43
- data/lib/gcloud/storage/file.rb +114 -111
- data/lib/gcloud/storage/file/acl.rb +27 -113
- data/lib/gcloud/storage/file/list.rb +21 -21
- data/lib/gcloud/storage/project.rb +49 -59
- data/lib/gcloud/storage/service.rb +347 -0
- data/lib/gcloud/translate.rb +24 -14
- data/lib/gcloud/translate/api.rb +12 -21
- data/lib/gcloud/translate/detection.rb +5 -5
- data/lib/gcloud/translate/language.rb +1 -1
- data/lib/gcloud/translate/service.rb +80 -0
- data/lib/gcloud/translate/translation.rb +6 -6
- data/lib/gcloud/version.rb +1 -1
- data/lib/gcloud/vision.rb +24 -15
- data/lib/gcloud/vision/annotate.rb +24 -21
- data/lib/gcloud/vision/annotation.rb +9 -9
- data/lib/gcloud/vision/annotation/entity.rb +11 -11
- data/lib/gcloud/vision/annotation/face.rb +25 -25
- data/lib/gcloud/vision/annotation/properties.rb +8 -8
- data/lib/gcloud/vision/annotation/safe_search.rb +4 -4
- data/lib/gcloud/vision/annotation/text.rb +7 -7
- data/lib/gcloud/vision/annotation/vertex.rb +1 -1
- data/lib/gcloud/vision/image.rb +11 -11
- data/lib/gcloud/vision/location.rb +5 -2
- data/lib/gcloud/vision/project.rb +14 -16
- data/lib/gcloud/vision/service.rb +66 -0
- data/lib/google/api_client.rb +0 -0
- metadata +27 -24
- data/lib/gcloud/bigquery/connection.rb +0 -624
- data/lib/gcloud/bigquery/errors.rb +0 -68
- data/lib/gcloud/bigquery/table/schema.rb +0 -234
- data/lib/gcloud/dns/connection.rb +0 -173
- data/lib/gcloud/dns/errors.rb +0 -68
- data/lib/gcloud/resource_manager/connection.rb +0 -134
- data/lib/gcloud/resource_manager/errors.rb +0 -68
- data/lib/gcloud/storage/connection.rb +0 -444
- data/lib/gcloud/translate/connection.rb +0 -85
- data/lib/gcloud/translate/errors.rb +0 -68
- data/lib/gcloud/upload.rb +0 -95
- data/lib/gcloud/vision/connection.rb +0 -63
- data/lib/gcloud/vision/errors.rb +0 -69
@@ -89,7 +89,7 @@ module Gcloud
|
|
89
89
|
# @return [String] The opaque entity ID.
|
90
90
|
#
|
91
91
|
def mid
|
92
|
-
@gapi
|
92
|
+
@gapi.mid
|
93
93
|
end
|
94
94
|
|
95
95
|
##
|
@@ -101,7 +101,7 @@ module Gcloud
|
|
101
101
|
# language code.
|
102
102
|
#
|
103
103
|
def locale
|
104
|
-
@gapi
|
104
|
+
@gapi.locale
|
105
105
|
end
|
106
106
|
|
107
107
|
##
|
@@ -110,7 +110,7 @@ module Gcloud
|
|
110
110
|
# @return [String] A description of the entity.
|
111
111
|
#
|
112
112
|
def description
|
113
|
-
@gapi
|
113
|
+
@gapi.description
|
114
114
|
end
|
115
115
|
|
116
116
|
##
|
@@ -119,7 +119,7 @@ module Gcloud
|
|
119
119
|
# @return [Float] A value in the range [0, 1].
|
120
120
|
#
|
121
121
|
def score
|
122
|
-
@gapi
|
122
|
+
@gapi.score
|
123
123
|
end
|
124
124
|
|
125
125
|
##
|
@@ -130,7 +130,7 @@ module Gcloud
|
|
130
130
|
# @return [Float] A value in the range [0, 1].
|
131
131
|
#
|
132
132
|
def confidence
|
133
|
-
@gapi
|
133
|
+
@gapi.confidence
|
134
134
|
end
|
135
135
|
|
136
136
|
##
|
@@ -143,7 +143,7 @@ module Gcloud
|
|
143
143
|
# @return [Float] A value in the range [0, 1].
|
144
144
|
#
|
145
145
|
def topicality
|
146
|
-
@gapi
|
146
|
+
@gapi.topicality
|
147
147
|
end
|
148
148
|
|
149
149
|
##
|
@@ -153,8 +153,8 @@ module Gcloud
|
|
153
153
|
# @return [Array<Vertex>] An array of vertices.
|
154
154
|
#
|
155
155
|
def bounds
|
156
|
-
return [] unless @gapi
|
157
|
-
@bounds ||= Array(@gapi
|
156
|
+
return [] unless @gapi.bounding_poly
|
157
|
+
@bounds ||= Array(@gapi.bounding_poly.vertices).map do |v|
|
158
158
|
Vertex.from_gapi v
|
159
159
|
end
|
160
160
|
end
|
@@ -170,8 +170,8 @@ module Gcloud
|
|
170
170
|
# and longitude.
|
171
171
|
#
|
172
172
|
def locations
|
173
|
-
@locations ||= Array(@gapi
|
174
|
-
Location.from_gapi l
|
173
|
+
@locations ||= Array(@gapi.locations).map do |l|
|
174
|
+
Location.from_gapi l.lat_lng
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
@@ -184,7 +184,7 @@ module Gcloud
|
|
184
184
|
#
|
185
185
|
def properties
|
186
186
|
@properties ||=
|
187
|
-
Hash[Array(@gapi
|
187
|
+
Hash[Array(@gapi.properties).map { |p| [p.name, p.value] }]
|
188
188
|
end
|
189
189
|
|
190
190
|
##
|
@@ -91,7 +91,7 @@ module Gcloud
|
|
91
91
|
# @return [Float] A value in the range [0, 1].
|
92
92
|
#
|
93
93
|
def confidence
|
94
|
-
@gapi
|
94
|
+
@gapi.detection_confidence
|
95
95
|
end
|
96
96
|
|
97
97
|
##
|
@@ -169,7 +169,7 @@ module Gcloud
|
|
169
169
|
# @return [Float] A value in the range [-180,180].
|
170
170
|
#
|
171
171
|
def roll
|
172
|
-
@gapi
|
172
|
+
@gapi.roll_angle
|
173
173
|
end
|
174
174
|
|
175
175
|
##
|
@@ -180,7 +180,7 @@ module Gcloud
|
|
180
180
|
# @return [Float] A value in the range [-180,180].
|
181
181
|
#
|
182
182
|
def yaw
|
183
|
-
@gapi
|
183
|
+
@gapi.pan_angle
|
184
184
|
end
|
185
185
|
alias_method :pan, :yaw
|
186
186
|
|
@@ -191,7 +191,7 @@ module Gcloud
|
|
191
191
|
# @return [Float] A value in the range [-180,180].
|
192
192
|
#
|
193
193
|
def pitch
|
194
|
-
@gapi
|
194
|
+
@gapi.tilt_angle
|
195
195
|
end
|
196
196
|
alias_method :tilt, :pitch
|
197
197
|
|
@@ -289,8 +289,8 @@ module Gcloud
|
|
289
289
|
# generated in the BoundingPoly (the polygon will be unbounded) if
|
290
290
|
# only a partial face appears in the image to be annotated.
|
291
291
|
def head
|
292
|
-
return [] unless @gapi
|
293
|
-
@head ||= Array(@gapi
|
292
|
+
return [] unless @gapi.bounding_poly
|
293
|
+
@head ||= Array(@gapi.bounding_poly.vertices).map do |v|
|
294
294
|
Vertex.from_gapi v
|
295
295
|
end
|
296
296
|
end
|
@@ -302,8 +302,8 @@ module Gcloud
|
|
302
302
|
# visible in an image. It is not based on the landmarks, only on the
|
303
303
|
# initial face detection.
|
304
304
|
def face
|
305
|
-
return [] unless @gapi
|
306
|
-
@face ||= Array(@gapi
|
305
|
+
return [] unless @gapi.fd_bounding_poly
|
306
|
+
@face ||= Array(@gapi.fd_bounding_poly.vertices).map do |v|
|
307
307
|
Vertex.from_gapi v
|
308
308
|
end
|
309
309
|
end
|
@@ -407,7 +407,7 @@ module Gcloud
|
|
407
407
|
# @return [Float] A value in the range [0,1].
|
408
408
|
#
|
409
409
|
def confidence
|
410
|
-
@gapi
|
410
|
+
@gapi.landmarking_confidence
|
411
411
|
end
|
412
412
|
|
413
413
|
##
|
@@ -435,8 +435,8 @@ module Gcloud
|
|
435
435
|
# #=> #<Landmark (x: 303.81198, y: 88.5782, z: 77.719193)>
|
436
436
|
#
|
437
437
|
def [] landmark_type
|
438
|
-
landmark = Array(@gapi
|
439
|
-
l
|
438
|
+
landmark = Array(@gapi.landmarks).detect do |l|
|
439
|
+
l.type == landmark_type
|
440
440
|
end
|
441
441
|
return nil if landmark.nil?
|
442
442
|
Landmark.from_gapi landmark
|
@@ -635,7 +635,7 @@ module Gcloud
|
|
635
635
|
# face.features.forehead.type #=> "FOREHEAD_GLABELLA"
|
636
636
|
#
|
637
637
|
def type
|
638
|
-
@gapi
|
638
|
+
@gapi.type
|
639
639
|
end
|
640
640
|
|
641
641
|
##
|
@@ -644,8 +644,8 @@ module Gcloud
|
|
644
644
|
# @return [Float]
|
645
645
|
#
|
646
646
|
def x
|
647
|
-
return nil unless @gapi
|
648
|
-
@gapi
|
647
|
+
return nil unless @gapi.position
|
648
|
+
@gapi.position.x
|
649
649
|
end
|
650
650
|
|
651
651
|
##
|
@@ -654,8 +654,8 @@ module Gcloud
|
|
654
654
|
# @return [Float]
|
655
655
|
#
|
656
656
|
def y
|
657
|
-
return nil unless @gapi
|
658
|
-
@gapi
|
657
|
+
return nil unless @gapi.position
|
658
|
+
@gapi.position.y
|
659
659
|
end
|
660
660
|
|
661
661
|
##
|
@@ -664,8 +664,8 @@ module Gcloud
|
|
664
664
|
# @return [Float]
|
665
665
|
#
|
666
666
|
def z
|
667
|
-
return nil unless @gapi
|
668
|
-
@gapi
|
667
|
+
return nil unless @gapi.position
|
668
|
+
@gapi.position.z
|
669
669
|
end
|
670
670
|
|
671
671
|
##
|
@@ -1586,7 +1586,7 @@ module Gcloud
|
|
1586
1586
|
# Joy likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1587
1587
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1588
1588
|
def joy
|
1589
|
-
@gapi
|
1589
|
+
@gapi.joy_likelihood
|
1590
1590
|
end
|
1591
1591
|
|
1592
1592
|
##
|
@@ -1603,7 +1603,7 @@ module Gcloud
|
|
1603
1603
|
# Sorrow likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1604
1604
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1605
1605
|
def sorrow
|
1606
|
-
@gapi
|
1606
|
+
@gapi.sorrow_likelihood
|
1607
1607
|
end
|
1608
1608
|
|
1609
1609
|
##
|
@@ -1620,7 +1620,7 @@ module Gcloud
|
|
1620
1620
|
# Joy likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1621
1621
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1622
1622
|
def anger
|
1623
|
-
@gapi
|
1623
|
+
@gapi.anger_likelihood
|
1624
1624
|
end
|
1625
1625
|
|
1626
1626
|
##
|
@@ -1637,7 +1637,7 @@ module Gcloud
|
|
1637
1637
|
# Surprise likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1638
1638
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1639
1639
|
def surprise
|
1640
|
-
@gapi
|
1640
|
+
@gapi.surprise_likelihood
|
1641
1641
|
end
|
1642
1642
|
|
1643
1643
|
##
|
@@ -1655,7 +1655,7 @@ module Gcloud
|
|
1655
1655
|
# `VERY_UNLIKELY`, `UNLIKELY`, `POSSIBLE`, `LIKELY`, and
|
1656
1656
|
# `VERY_LIKELY`.
|
1657
1657
|
def under_exposed
|
1658
|
-
@gapi
|
1658
|
+
@gapi.under_exposed_likelihood
|
1659
1659
|
end
|
1660
1660
|
|
1661
1661
|
##
|
@@ -1672,7 +1672,7 @@ module Gcloud
|
|
1672
1672
|
# Blurred likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1673
1673
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1674
1674
|
def blurred
|
1675
|
-
@gapi
|
1675
|
+
@gapi.blurred_likelihood
|
1676
1676
|
end
|
1677
1677
|
|
1678
1678
|
##
|
@@ -1689,7 +1689,7 @@ module Gcloud
|
|
1689
1689
|
# Headwear likelihood rating. Possible values are `VERY_UNLIKELY`,
|
1690
1690
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
1691
1691
|
def headwear
|
1692
|
-
@gapi
|
1692
|
+
@gapi.headwear_likelihood
|
1693
1693
|
end
|
1694
1694
|
|
1695
1695
|
##
|
@@ -51,8 +51,8 @@ module Gcloud
|
|
51
51
|
# @return [Array<Color>] An array of the image's dominant colors.
|
52
52
|
#
|
53
53
|
def colors
|
54
|
-
return [] unless @gapi
|
55
|
-
@colors ||= Array(@gapi
|
54
|
+
return [] unless @gapi.dominant_colors
|
55
|
+
@colors ||= Array(@gapi.dominant_colors.colors).map do |c|
|
56
56
|
Color.from_gapi c
|
57
57
|
end
|
58
58
|
end
|
@@ -150,7 +150,7 @@ module Gcloud
|
|
150
150
|
# @return [Float] A value in the interval [0, 255].
|
151
151
|
#
|
152
152
|
def red
|
153
|
-
@gapi
|
153
|
+
@gapi.color.red
|
154
154
|
end
|
155
155
|
|
156
156
|
##
|
@@ -159,7 +159,7 @@ module Gcloud
|
|
159
159
|
# @return [Float] A value in the interval [0, 255].
|
160
160
|
#
|
161
161
|
def green
|
162
|
-
@gapi
|
162
|
+
@gapi.color.green
|
163
163
|
end
|
164
164
|
|
165
165
|
##
|
@@ -168,7 +168,7 @@ module Gcloud
|
|
168
168
|
# @return [Float] A value in the interval [0, 255].
|
169
169
|
#
|
170
170
|
def blue
|
171
|
-
@gapi
|
171
|
+
@gapi.color.blue
|
172
172
|
end
|
173
173
|
|
174
174
|
##
|
@@ -179,7 +179,7 @@ module Gcloud
|
|
179
179
|
# @return [Float] A value in the range [0, 1].
|
180
180
|
#
|
181
181
|
def alpha
|
182
|
-
@gapi
|
182
|
+
@gapi.color.alpha || 1.0
|
183
183
|
end
|
184
184
|
|
185
185
|
def rgb
|
@@ -194,7 +194,7 @@ module Gcloud
|
|
194
194
|
# @return [Float] A value in the range [0, 1].
|
195
195
|
#
|
196
196
|
def score
|
197
|
-
@gapi
|
197
|
+
@gapi.score
|
198
198
|
end
|
199
199
|
|
200
200
|
##
|
@@ -203,7 +203,7 @@ module Gcloud
|
|
203
203
|
# @return [Float] A value in the range [0, 1].
|
204
204
|
#
|
205
205
|
def pixel_fraction
|
206
|
-
@gapi
|
206
|
+
@gapi.pixel_fraction
|
207
207
|
end
|
208
208
|
|
209
209
|
##
|
@@ -54,7 +54,7 @@ module Gcloud
|
|
54
54
|
# Adult likelihood rating. Possible values are `VERY_UNLIKELY`,
|
55
55
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
56
56
|
def adult
|
57
|
-
@gapi
|
57
|
+
@gapi.adult
|
58
58
|
end
|
59
59
|
|
60
60
|
##
|
@@ -71,7 +71,7 @@ module Gcloud
|
|
71
71
|
# Spoof likelihood rating. Possible values are `VERY_UNLIKELY`,
|
72
72
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
73
73
|
def spoof
|
74
|
-
@gapi
|
74
|
+
@gapi.spoof
|
75
75
|
end
|
76
76
|
|
77
77
|
##
|
@@ -88,7 +88,7 @@ module Gcloud
|
|
88
88
|
# Medical likelihood rating. Possible values are `VERY_UNLIKELY`,
|
89
89
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
90
90
|
def medical
|
91
|
-
@gapi
|
91
|
+
@gapi.medical
|
92
92
|
end
|
93
93
|
|
94
94
|
##
|
@@ -105,7 +105,7 @@ module Gcloud
|
|
105
105
|
# Violence likelihood rating. Possible values are `VERY_UNLIKELY`,
|
106
106
|
# `UNLIKELY`, `POSSIBLE`, `LIKELY`, and `VERY_LIKELY`.
|
107
107
|
def violence
|
108
|
-
@gapi
|
108
|
+
@gapi.violence
|
109
109
|
end
|
110
110
|
|
111
111
|
##
|
@@ -55,7 +55,7 @@ module Gcloud
|
|
55
55
|
# @return [String] The entire text including newline characters.
|
56
56
|
#
|
57
57
|
def text
|
58
|
-
@gapi
|
58
|
+
@gapi.description
|
59
59
|
end
|
60
60
|
|
61
61
|
##
|
@@ -66,7 +66,7 @@ module Gcloud
|
|
66
66
|
# language code.
|
67
67
|
#
|
68
68
|
def locale
|
69
|
-
@gapi
|
69
|
+
@gapi.locale
|
70
70
|
end
|
71
71
|
|
72
72
|
##
|
@@ -75,8 +75,8 @@ module Gcloud
|
|
75
75
|
# @return [Array<Vertex>]
|
76
76
|
#
|
77
77
|
def bounds
|
78
|
-
return [] unless @gapi
|
79
|
-
@bounds ||= Array(@gapi
|
78
|
+
return [] unless @gapi.bounding_poly
|
79
|
+
@bounds ||= Array(@gapi.bounding_poly.vertices).map do |v|
|
80
80
|
Vertex.from_gapi v
|
81
81
|
end
|
82
82
|
end
|
@@ -176,7 +176,7 @@ module Gcloud
|
|
176
176
|
# @return [String]
|
177
177
|
#
|
178
178
|
def text
|
179
|
-
@gapi
|
179
|
+
@gapi.description
|
180
180
|
end
|
181
181
|
|
182
182
|
##
|
@@ -185,8 +185,8 @@ module Gcloud
|
|
185
185
|
# @return [Array<Vertex>]
|
186
186
|
#
|
187
187
|
def bounds
|
188
|
-
return [] unless @gapi
|
189
|
-
@bounds ||= Array(@gapi
|
188
|
+
return [] unless @gapi.bounding_poly
|
189
|
+
@bounds ||= Array(@gapi.bounding_poly.vertices).map do |v|
|
190
190
|
Vertex.from_gapi v
|
191
191
|
end
|
192
192
|
end
|
data/lib/gcloud/vision/image.rb
CHANGED
@@ -14,6 +14,7 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
require "gcloud/vision/location"
|
17
|
+
require "google/apis/vision_v1"
|
17
18
|
require "stringio"
|
18
19
|
require "base64"
|
19
20
|
|
@@ -70,8 +71,6 @@ module Gcloud
|
|
70
71
|
##
|
71
72
|
# @private Whether the Image has content.
|
72
73
|
#
|
73
|
-
# @see {#url?}
|
74
|
-
#
|
75
74
|
def io?
|
76
75
|
!@io.nil?
|
77
76
|
end
|
@@ -79,8 +78,6 @@ module Gcloud
|
|
79
78
|
##
|
80
79
|
# @private Whether the Image is a URL.
|
81
80
|
#
|
82
|
-
# @see {#io?}
|
83
|
-
#
|
84
81
|
def url?
|
85
82
|
!@url.nil?
|
86
83
|
end
|
@@ -358,9 +355,9 @@ module Gcloud
|
|
358
355
|
def to_gapi
|
359
356
|
if io?
|
360
357
|
@io.rewind
|
361
|
-
|
358
|
+
Google::Apis::VisionV1::Image.new content: @io.read
|
362
359
|
elsif url?
|
363
|
-
|
360
|
+
Google::Apis::VisionV1::Image.new source: { gcsImageUri: @url }
|
364
361
|
else
|
365
362
|
fail ArgumentError, "Unable to use Image with Vision service."
|
366
363
|
end
|
@@ -477,9 +474,9 @@ module Gcloud
|
|
477
474
|
# @private
|
478
475
|
def to_gapi
|
479
476
|
return nil if empty?
|
480
|
-
gapi =
|
481
|
-
gapi
|
482
|
-
gapi
|
477
|
+
gapi = Google::Apis::VisionV1::ImageContext.new
|
478
|
+
gapi.lat_long_rect = area.to_gapi unless area.empty?
|
479
|
+
gapi.language_hints = languages unless languages.empty?
|
483
480
|
gapi
|
484
481
|
end
|
485
482
|
|
@@ -576,12 +573,15 @@ module Gcloud
|
|
576
573
|
# @return [Hash]
|
577
574
|
#
|
578
575
|
def to_hash
|
579
|
-
{
|
576
|
+
{ min_lat_lng: min.to_hash, max_lat_lng: max.to_hash }
|
580
577
|
end
|
581
578
|
|
582
579
|
def to_gapi
|
583
580
|
return nil if empty?
|
584
|
-
|
581
|
+
Google::Apis::VisionV1::LatLongRect.new(
|
582
|
+
min_lat_lng: min.to_gapi,
|
583
|
+
max_lat_lng: max.to_gapi
|
584
|
+
)
|
585
585
|
end
|
586
586
|
end
|
587
587
|
end
|