google-cloud-vision 0.30.2 → 0.30.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: 82f7659d17511a5614ad7fef9c50659494515606830bd8b7872e243c4f253bec
4
- data.tar.gz: ef0fcfe19887df1051ba3fb06ed1e74ecdee3cb94cc947cb7f4057a2cfdc6154
3
+ metadata.gz: 65ed9e03062929ed095034844ccd30b35c52acb834c666d4d390dfa1203121ce
4
+ data.tar.gz: 359629a259f33a73782283921e519a9e118a36fcd94ee749557a14e613d27ad2
5
5
  SHA512:
6
- metadata.gz: '0192759e5ef273badc8220ce1cb2195351b09f624417dd3bf1947db46257075c844603448b50bc4bd6b0652d0cf1e6b8ea0d125b952a497b94f2103af4a630f4'
7
- data.tar.gz: 7ce13c76100395e42e3681a5adbe299f279cfe08287f553827ef94427ed75e62ab246b6923ed1ae8b25f188759b7f7394d9006c1b87346eaf718f54d8d6b64bd
6
+ metadata.gz: 627fa7cfcbd557bb81c625a67a8edf06740801de308b090073ba821741ed3abae08a43272e830baf4b0aa0d3e1657736480c19277524f3b6d96533be5dc642a7
7
+ data.tar.gz: 9fe03553d0b3892d70c09e77509fc97be8180e6eb38eeb1d4bcb3eaa27807e03a6d089148afc859c11ac75814f48545dd623d9047c26e25ed720cd1d1b60718f
data/AUTHENTICATION.md ADDED
@@ -0,0 +1,179 @@
1
+ # Authentication
2
+
3
+ In general, the google-cloud-vision library uses [Service
4
+ Account](https://cloud.google.com/iam/docs/creating-managing-service-accounts)
5
+ credentials to connect to Google Cloud services. When running on Compute Engine
6
+ the credentials will be discovered automatically. When running on other
7
+ environments, the Service Account credentials can be specified by providing the
8
+ path to the [JSON
9
+ keyfile](https://cloud.google.com/iam/docs/managing-service-account-keys) for
10
+ the account (or the JSON itself) in environment variables. Additionally, Cloud
11
+ SDK credentials can also be discovered automatically, but this is only
12
+ recommended during development.
13
+
14
+ ## Project and Credential Lookup
15
+
16
+ The google-cloud-vision library aims to make authentication as simple as
17
+ possible, and provides several mechanisms to configure your system without
18
+ providing **Project ID** and **Service Account Credentials** directly in code.
19
+
20
+ **Project ID** is discovered in the following order:
21
+
22
+ 1. Specify project ID in method arguments
23
+ 2. Specify project ID in configuration
24
+ 3. Discover project ID in environment variables
25
+ 4. Discover GCE project ID
26
+
27
+ **Credentials** are discovered in the following order:
28
+
29
+ 1. Specify credentials in method arguments
30
+ 2. Specify credentials in configuration
31
+ 3. Discover credentials path in environment variables
32
+ 4. Discover credentials JSON in environment variables
33
+ 5. Discover credentials file in the Cloud SDK's path
34
+ 6. Discover GCE credentials
35
+
36
+ ### Google Cloud Platform environments
37
+
38
+ While running on Google Cloud Platform environments such as Google Compute
39
+ Engine, Google App Engine and Google Kubernetes Engine, no extra work is needed.
40
+ The **Project ID** and **Credentials** and are discovered automatically. Code
41
+ should be written as if already authenticated. Just be sure when you [set up the
42
+ GCE instance][gce-how-to], you add the correct scopes for the APIs you want to
43
+ access. For example:
44
+
45
+ * **All APIs**
46
+ * `https://www.googleapis.com/auth/cloud-platform`
47
+ * `https://www.googleapis.com/auth/cloud-platform.read-only`
48
+ * **BigQuery**
49
+ * `https://www.googleapis.com/auth/bigquery`
50
+ * `https://www.googleapis.com/auth/bigquery.insertdata`
51
+ * **Compute Engine**
52
+ * `https://www.googleapis.com/auth/compute`
53
+ * **Datastore**
54
+ * `https://www.googleapis.com/auth/datastore`
55
+ * `https://www.googleapis.com/auth/userinfo.email`
56
+ * **DNS**
57
+ * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
58
+ * **Pub/Sub**
59
+ * `https://www.googleapis.com/auth/pubsub`
60
+ * **Storage**
61
+ * `https://www.googleapis.com/auth/devstorage.full_control`
62
+ * `https://www.googleapis.com/auth/devstorage.read_only`
63
+ * `https://www.googleapis.com/auth/devstorage.read_write`
64
+
65
+ ### Environment Variables
66
+
67
+ The **Project ID** and **Credentials JSON** can be placed in environment
68
+ variables instead of declaring them directly in code. Each service has its own
69
+ environment variable, allowing for different service accounts to be used for
70
+ different services. (See the READMEs for the individual service gems for
71
+ details.) The path to the **Credentials JSON** file can be stored in the
72
+ environment variable, or the **Credentials JSON** itself can be stored for
73
+ environments such as Docker containers where writing files is difficult or not
74
+ encouraged.
75
+
76
+ The environment variables that Vision checks for project ID are:
77
+
78
+ 1. `VISION_PROJECT`
79
+ 2. `GOOGLE_CLOUD_PROJECT`
80
+
81
+ The environment variables that Vision checks for credentials are configured on
82
+ {Google::Cloud::Vision::V1::Credentials}:
83
+
84
+ 1. `VISION_CREDENTIALS` - Path to JSON file, or JSON contents
85
+ 2. `VISION_KEYFILE` - Path to JSON file, or JSON contents
86
+ 3. `GOOGLE_CLOUD_CREDENTIALS` - Path to JSON file, or JSON contents
87
+ 4. `GOOGLE_CLOUD_KEYFILE` - Path to JSON file, or JSON contents
88
+ 5. `GOOGLE_APPLICATION_CREDENTIALS` - Path to JSON file
89
+
90
+ ```ruby
91
+ require "google/cloud/vision"
92
+
93
+ ENV["VISION_PROJECT"] = "my-project-id"
94
+ ENV["VISION_CREDENTIALS"] = "path/to/keyfile.json"
95
+
96
+ vision = Google::Cloud::Vision.new
97
+ ```
98
+
99
+ ### Configuration
100
+
101
+ The **Project ID** and **Credentials JSON** can be configured instead of placing them in environment variables or providing them as arguments.
102
+
103
+ ```ruby
104
+ require "google/cloud/vision"
105
+
106
+ Google::Cloud::Vision.configure do |config|
107
+ config.project_id = "my-project-id"
108
+ config.credentials = "path/to/keyfile.json"
109
+ end
110
+
111
+ vision = Google::Cloud::Vision.new
112
+ ```
113
+
114
+ ### Cloud SDK
115
+
116
+ This option allows for an easy way to authenticate during development. If
117
+ credentials are not provided in code or in environment variables, then Cloud SDK
118
+ credentials are discovered.
119
+
120
+ To configure your system for this, simply:
121
+
122
+ 1. [Download and install the Cloud SDK](https://cloud.google.com/sdk)
123
+ 2. Authenticate using OAuth 2.0 `$ gcloud auth login`
124
+ 3. Write code as if already authenticated.
125
+
126
+ **NOTE:** This is _not_ recommended for running in production. The Cloud SDK
127
+ *should* only be used during development.
128
+
129
+ [gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
130
+ [dev-console]: https://console.cloud.google.com/project
131
+
132
+ [enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
133
+
134
+ [create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
135
+ [create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
136
+ [reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
137
+
138
+ ## Creating a Service Account
139
+
140
+ Google Cloud requires a **Project ID** and **Service Account Credentials** to
141
+ connect to the APIs. You will use the **Project ID** and **JSON key file** to
142
+ connect to most services with google-cloud-vision.
143
+
144
+ If you are not running this client on Google Compute Engine, you need a Google
145
+ Developers service account.
146
+
147
+ 1. Visit the [Google Developers Console][dev-console].
148
+ 1. Create a new project or click on an existing project.
149
+ 1. Activate the slide-out navigation tray and select **API Manager**. From
150
+ here, you will enable the APIs that your application requires.
151
+
152
+ ![Enable the APIs that your application requires][enable-apis]
153
+
154
+ *Note: You may need to enable billing in order to use these services.*
155
+
156
+ 1. Select **Credentials** from the side navigation.
157
+
158
+ You should see a screen like one of the following.
159
+
160
+ ![Create a new service account][create-new-service-account]
161
+
162
+ ![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
163
+
164
+ Find the "Add credentials" drop down and select "Service account" to be
165
+ guided through downloading a new JSON key file.
166
+
167
+ If you want to re-use an existing service account, you can easily generate a
168
+ new key file. Just select the account you wish to re-use, and click "Generate
169
+ new JSON key":
170
+
171
+ ![Re-use an existing service account][reuse-service-account]
172
+
173
+ The key file you download will be used by this library to authenticate API
174
+ requests and should be stored in a secure location.
175
+
176
+ ## Troubleshooting
177
+
178
+ If you're having trouble authenticating you can ask for help by following the
179
+ {file:TROUBLESHOOTING.md Troubleshooting Guide}.
data/CHANGELOG.md ADDED
@@ -0,0 +1,99 @@
1
+ # Release History
2
+
3
+ ### 0.30.3 / 2018-09-12
4
+
5
+ * Add missing documentation files to package.
6
+
7
+ ### 0.30.2 / 2018-09-10
8
+
9
+ * Update documentation.
10
+
11
+ ### 0.30.1 / 2018-08-21
12
+
13
+ * Update documentation.
14
+
15
+ ### 0.30.0 / 2018-07-20
16
+
17
+ * Add async_batch_annotate_files method to Google::Cloud::Vision::Project
18
+
19
+ ### 0.29.1 / 2018-07-05
20
+
21
+ * Update google-gax dependency to version 1.3.
22
+
23
+ ### 0.29.0 / 2018-06-22
24
+
25
+ * Add V1 API.
26
+
27
+ ### 0.28.0 / 2018-02-27
28
+
29
+ * Add Shared Configuration.
30
+
31
+ ### 0.27.0 / 2017-12-19
32
+
33
+ * Update google-gax dependency to 1.0.
34
+
35
+ ### 0.26.0 / 2017-11-14
36
+
37
+ * Add `Google::Cloud::Vision::Credentials` class.
38
+ * Rename constructor arguments to `project_id` and `credentials`.
39
+ (The previous arguments `project` and `keyfile` are still supported.)
40
+ * Document `Google::Auth::Credentials` as `credentials` value.
41
+ * Update generated low level GAPIC code.
42
+ * Updated `google-gax` (`grpc`, `google-protobuf`), `googleauth` dependencies.
43
+
44
+ ### 0.25.0 / 2017-07-11
45
+
46
+ * Add `Image#annotate`.
47
+ * Update GAPIC configuration to exclude `UNAVAILABLE` errors from automatic retry.
48
+ * Update gem spec homepage links.
49
+
50
+ ### 0.24.0 / 2017-03-31
51
+
52
+ * Updated documentation
53
+ * Automatic retry on `UNAVAILABLE` errors
54
+
55
+ ### 0.23.0 / 2017-03-03
56
+
57
+ Major release, adding V1.1 support.
58
+
59
+ * Support image URLs from the internet, not just Cloud Storage.
60
+ * Add document text detection feature, like text but for longer documents.
61
+ * Add crop hints feature.
62
+ * Add web annotation feature
63
+ * Update GRPC header value sent to the Vision API.
64
+
65
+ ### 0.22.1 / 2017-03-01
66
+
67
+ * No public API changes.
68
+ * Update GRPC header value sent to the Vision API.
69
+
70
+ ### 0.22.0 / 2017-02-21
71
+
72
+ * Fix GRPC retry bug
73
+ * The client_config data structure has replaced retry_codes/retry_codes_def with retry_codes
74
+ * Update GRPC/Protobuf/GAX dependencies
75
+ * Updates to code examples in documentation
76
+
77
+ ### 0.21.1 / 2016-10-27
78
+
79
+ * Fix outdated requires (Ricowere)
80
+
81
+ ### 0.21.0 / 2016-10-20
82
+
83
+ * New service constructor Google::Cloud::Vision.new
84
+ * New constructor argument client_config
85
+
86
+ ### 0.20.2 / 2016-09-06
87
+
88
+ * Fix for using GCS URLs. (erikaxel)
89
+
90
+ ### 0.20.1 / 2016-09-02
91
+
92
+ * Fix for timeout on uploads.
93
+
94
+ ### 0.20.0 / 2016-08-26
95
+
96
+ This gem contains the Google Cloud Vision service implementation for the `google-cloud` gem. The `google-cloud` gem replaces the old `gcloud` gem. Legacy code can continue to use the `gcloud` gem.
97
+
98
+ * Namespace is now `Google::Cloud`
99
+ * The `google-cloud` gem is now an umbrella package for individual gems
@@ -0,0 +1,40 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct.
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or reject
24
+ comments, commits, code, wiki edits, issues, and other contributions that are
25
+ not aligned to this Code of Conduct. By adopting this Code of Conduct, project
26
+ maintainers commit themselves to fairly and consistently applying these
27
+ principles to every aspect of managing this project. Project maintainers who do
28
+ not follow or enforce the Code of Conduct may be permanently removed from the
29
+ project team.
30
+
31
+ This code of conduct applies both within project spaces and in public spaces
32
+ when an individual is representing the project or its community.
33
+
34
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
35
+ reported by opening an issue or contacting one or more of the project
36
+ maintainers.
37
+
38
+ This Code of Conduct is adapted from the [Contributor
39
+ Covenant](http://contributor-covenant.org), version 1.2.0, available at
40
+ [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,188 @@
1
+ # Contributing to Google Cloud Vision
2
+
3
+ 1. **Sign one of the contributor license agreements below.**
4
+ 2. Fork the repo, develop and test your code changes.
5
+ 3. Send a pull request.
6
+
7
+ ## Contributor License Agreements
8
+
9
+ Before we can accept your pull requests you'll need to sign a Contributor
10
+ License Agreement (CLA):
11
+
12
+ - **If you are an individual writing original source code** and **you own the
13
+ intellectual property**, then you'll need to sign an [individual
14
+ CLA](https://developers.google.com/open-source/cla/individual).
15
+ - **If you work for a company that wants to allow you to contribute your work**,
16
+ then you'll need to sign a [corporate
17
+ CLA](https://developers.google.com/open-source/cla/corporate).
18
+
19
+ You can sign these electronically (just scroll to the bottom). After that, we'll
20
+ be able to accept your pull requests.
21
+
22
+ ## Setup
23
+
24
+ In order to use the google-cloud-vision console and run the project's tests,
25
+ there is a small amount of setup:
26
+
27
+ 1. Install Ruby. google-cloud-vision requires Ruby 2.3+. You may choose to
28
+ manage your Ruby and gem installations with [RVM](https://rvm.io/),
29
+ [rbenv](https://github.com/rbenv/rbenv), or
30
+ [chruby](https://github.com/postmodern/chruby).
31
+
32
+ 2. Install [Bundler](http://bundler.io/).
33
+
34
+ ```sh
35
+ $ gem install bundler
36
+ ```
37
+
38
+ 3. Install the top-level project dependencies.
39
+
40
+ ```sh
41
+ $ bundle install
42
+ ```
43
+
44
+ 4. Install the Vision dependencies.
45
+
46
+ ```sh
47
+ $ cd google-cloud-vision/
48
+ $ bundle exec rake bundleupdate
49
+ ```
50
+
51
+ ## Console
52
+
53
+ In order to run code interactively, you can automatically load
54
+ google-cloud-vision and its dependencies in IRB. This requires that your
55
+ developer environment has already been configured by following the steps
56
+ described in the {file:AUTHENTICATION.md Authentication Guide}. An IRB console
57
+ can be created with:
58
+
59
+ ```sh
60
+ $ cd google-cloud-vision/
61
+ $ bundle exec rake console
62
+ ```
63
+
64
+ ## Vision Tests
65
+
66
+ Tests are very important part of google-cloud-vision. All contributions
67
+ should include tests that ensure the contributed code behaves as expected.
68
+
69
+ To run the unit tests, documentation tests, and code style checks together for a
70
+ package:
71
+
72
+ ``` sh
73
+ $ cd google-cloud-vision/
74
+ $ bundle exec rake ci
75
+ ```
76
+
77
+ To run the command above, plus all acceptance tests, use `rake ci:acceptance` or
78
+ its handy alias, `rake ci:a`.
79
+
80
+ ### Vision Unit Tests
81
+
82
+
83
+ The project uses the [minitest](https://github.com/seattlerb/minitest) library,
84
+ including [specs](https://github.com/seattlerb/minitest#specs),
85
+ [mocks](https://github.com/seattlerb/minitest#mocks) and
86
+ [minitest-autotest](https://github.com/seattlerb/minitest-autotest).
87
+
88
+ To run the Vision unit tests:
89
+
90
+ ``` sh
91
+ $ cd google-cloud-vision/
92
+ $ bundle exec rake test
93
+ ```
94
+
95
+ ### Vision Documentation Tests
96
+
97
+ The project tests the code examples in the gem's
98
+ [YARD](https://github.com/lsegal/yard)-based documentation.
99
+
100
+ The example testing functions in a way that is very similar to unit testing, and
101
+ in fact the library providing it,
102
+ [yard-doctest](https://github.com/p0deje/yard-doctest), is based on the
103
+ project's unit test library, [minitest](https://github.com/seattlerb/minitest).
104
+
105
+ To run the Vision documentation tests:
106
+
107
+ ``` sh
108
+ $ cd google-cloud-vision/
109
+ $ bundle exec rake doctest
110
+ ```
111
+
112
+ If you add, remove or modify documentation examples when working on a pull
113
+ request, you may need to update the setup for the tests. The stubs and mocks
114
+ required to run the tests are located in `support/doctest_helper.rb`. Please
115
+ note that much of the setup is matched by the title of the
116
+ [`@example`](http://www.rubydoc.info/gems/yard/file/docs/Tags.md#example) tag.
117
+ If you alter an example's title, you may encounter breaking tests.
118
+
119
+ ### Vision Acceptance Tests
120
+
121
+ The Vision acceptance tests interact with the live service API. Follow the
122
+ instructions in the {file:AUTHENTICATION.md Authentication guide} for enabling
123
+ the Vision API. Occasionally, some API features may not yet be generally
124
+ available, making it difficult for some contributors to successfully run the
125
+ entire acceptance test suite. However, please ensure that you do successfully
126
+ run acceptance tests for any code areas covered by your pull request.
127
+
128
+ To run the acceptance tests, first create and configure a project in the Google
129
+ Developers Console, as described in the {file:AUTHENTICATION.md Authentication
130
+ guide}. Be sure to download the JSON KEY file. Make note of the PROJECT_ID and
131
+ the KEYFILE location on your system.
132
+
133
+ Before you can run the Vision acceptance tests, you must first create indexes
134
+ used in the tests.
135
+
136
+ #### Running the Vision acceptance tests
137
+
138
+ To run the Vision acceptance tests:
139
+
140
+ ``` sh
141
+ $ cd google-cloud-vision/
142
+ $ bundle exec rake acceptance[\\{my-project-id},\\{/path/to/keyfile.json}]
143
+ ```
144
+
145
+ Or, if you prefer you can store the values in the `GCLOUD_TEST_PROJECT` and
146
+ `GCLOUD_TEST_KEYFILE` environment variables:
147
+
148
+ ``` sh
149
+ $ cd google-cloud-vision/
150
+ $ export GCLOUD_TEST_PROJECT=\\{my-project-id}
151
+ $ export GCLOUD_TEST_KEYFILE=\\{/path/to/keyfile.json}
152
+ $ bundle exec rake acceptance
153
+ ```
154
+
155
+ If you want to use a different project and credentials for acceptance tests, you
156
+ can use the more specific `VISION_TEST_PROJECT` and `VISION_TEST_KEYFILE`
157
+ environment variables:
158
+
159
+ ``` sh
160
+ $ cd google-cloud-vision/
161
+ $ export VISION_TEST_PROJECT=\\{my-project-id}
162
+ $ export VISION_TEST_KEYFILE=\\{/path/to/keyfile.json}
163
+ $ bundle exec rake acceptance
164
+ ```
165
+
166
+ ## Coding Style
167
+
168
+ Please follow the established coding style in the library. The style is is
169
+ largely based on [The Ruby Style
170
+ Guide](https://github.com/bbatsov/ruby-style-guide) with a few exceptions based
171
+ on seattle-style:
172
+
173
+ * Avoid parenthesis when possible, including in method definitions.
174
+ * Always use double quotes strings. ([Option
175
+ B](https://github.com/bbatsov/ruby-style-guide#strings))
176
+
177
+ You can check your code against these rules by running Rubocop like so:
178
+
179
+ ```sh
180
+ $ cd google-cloud-vision/
181
+ $ bundle exec rake rubocop
182
+ ```
183
+
184
+ ## Code of Conduct
185
+
186
+ Please note that this project is released with a Contributor Code of Conduct. By
187
+ participating in this project you agree to abide by its terms. See
188
+ {file:CODE_OF_CONDUCT.md Code of Conduct} for more information.
data/LOGGING.md ADDED
@@ -0,0 +1,32 @@
1
+ # Enabling gRPC Logging
2
+
3
+ To enable logging for this library, set the logger for the underlying
4
+ [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger
5
+ that you set may be a Ruby stdlib
6
+ [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as
7
+ shown below, or a
8
+ [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger)
9
+ that will write logs to [Stackdriver
10
+ Logging](https://cloud.google.com/logging/). See
11
+ [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
12
+ and the gRPC
13
+ [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb)
14
+ for additional information.
15
+
16
+ Configuring a Ruby stdlib logger:
17
+
18
+ ```ruby
19
+ require "logger"
20
+
21
+ module MyLogger
22
+ LOGGER = Logger.new $stderr, level: Logger::WARN
23
+ def logger
24
+ LOGGER
25
+ end
26
+ end
27
+
28
+ # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
29
+ module GRPC
30
+ extend MyLogger
31
+ end
32
+ ```
data/OVERVIEW.md ADDED
@@ -0,0 +1,202 @@
1
+ # Google Cloud Vision
2
+
3
+ Google Cloud Vision allows developers to easily integrate vision
4
+ detection features within applications, including image labeling, face
5
+ and landmark detection, optical character recognition (OCR), and tagging
6
+ of explicit content.
7
+
8
+ For more information about Cloud Vision, read the [Google Cloud Vision API
9
+ Documentation](https://cloud.google.com/vision/docs/).
10
+
11
+ The goal of google-cloud is to provide an API that is comfortable to
12
+ Rubyists. Your authentication credentials are detected automatically in
13
+ Google Cloud Platform environments such as Google Compute Engine, Google
14
+ App Engine and Google Kubernetes Engine. In other environments you can
15
+ configure authentication easily, either directly in your code or via
16
+ environment variables. Read more about the options for connecting in the
17
+ {file:AUTHENTICATION.md Authentication Guide}.
18
+
19
+ ## Creating images
20
+
21
+ The Cloud Vision API supports UTF-8, UTF-16, and UTF-32 text encodings.
22
+ (Ruby uses UTF-8 natively, which is the default sent to the API, so unless
23
+ you're working with text processed in different platform, you should not
24
+ need to set the encoding type.)
25
+ a ). Be aware that Cloud Vision sets upper
26
+ limits on file size as well as on the total combined size of all images in
27
+ a request. Reducing your file size can significantly improve throughput;
28
+ however, be careful not to reduce image quality in the process. See [Best
29
+ Practices - Image
30
+ Sizing](https://cloud.google.com/vision/docs/best-practices#image_sizing)
31
+ for current file size limits.
32
+
33
+ Use {Google::Cloud::Vision::Project#image} to create images for the Cloud Vision
34
+ service. You can provide a file path:
35
+
36
+ ```ruby
37
+ require "google/cloud/vision"
38
+
39
+ vision = Google::Cloud::Vision.new
40
+
41
+ image = vision.image "path/to/landmark.jpg"
42
+ ```
43
+
44
+ Or any publicly-accessible image HTTP/HTTPS URL:
45
+
46
+ ```ruby
47
+ require "google/cloud/vision"
48
+
49
+ vision = Google::Cloud::Vision.new
50
+
51
+ image = vision.image "https://www.example.com/images/landmark.jpg"
52
+ ```
53
+
54
+ Or, you can initialize the image with a Google Cloud Storage URI:
55
+
56
+ ```ruby
57
+ require "google/cloud/vision"
58
+
59
+ vision = Google::Cloud::Vision.new
60
+
61
+ image = vision.image "gs://bucket-name/path_to_image_object"
62
+ ```
63
+
64
+ Creating an Image instance does not perform an API request.
65
+
66
+ ## Annotating images
67
+
68
+ The instance methods on {Google::Cloud::Vision::Image} invoke Cloud Vision's
69
+ detection features individually. Each method call makes an API request. (If you
70
+ want to run multiple features in a single request, see the examples for
71
+ {Google::Cloud::Vision::Project#annotate}, below.)
72
+
73
+ ```ruby
74
+ require "google/cloud/vision"
75
+
76
+ vision = Google::Cloud::Vision.new
77
+
78
+ image = vision.image "path/to/face.jpg"
79
+
80
+ face = image.face
81
+
82
+ face.features.to_h.count #=> 9
83
+ face.features.eyes.left.pupil
84
+ #<Landmark (x: 190.41544, y: 84.4557, z: -1.3682901)>
85
+ face.features.chin.center
86
+ #<Landmark (x: 233.21977, y: 189.47475, z: 19.487228)>
87
+ ```
88
+
89
+ To run multiple features on an image in a single request, pass the image (or a
90
+ string file path, publicly-accessible image HTTP/HTTPS URL, or Storage URI) to
91
+ {Google::Cloud::Vision::Project#annotate}:
92
+
93
+ ```ruby
94
+ require "google/cloud/vision"
95
+
96
+ vision = Google::Cloud::Vision.new
97
+
98
+ image = vision.image "path/to/face.jpg"
99
+
100
+ annotation = vision.annotate image, faces: true, labels: true
101
+ annotation.faces.count #=> 1
102
+ annotation.labels.count #=> 4
103
+ ```
104
+
105
+ You can also perform detection tasks on multiple images in a single
106
+ request:
107
+
108
+ ```ruby
109
+ require "google/cloud/vision"
110
+
111
+ vision = Google::Cloud::Vision.new
112
+
113
+ face_image = vision.image "path/to/face.jpg"
114
+ landmark_image = vision.image "path/to/landmark.jpg"
115
+
116
+ annotations = vision.annotate face_image,
117
+ landmark_image,
118
+ faces: true,
119
+ landmarks: true,
120
+ labels: true
121
+
122
+ annotations[0].faces.count #=> 1
123
+ annotations[0].landmarks.count #=> 0
124
+ annotations[0].labels.count #=> 4
125
+ annotations[1].faces.count #=> 1
126
+ annotations[1].landmarks.count #=> 1
127
+ annotations[1].labels.count #=> 6
128
+ ```
129
+
130
+ It is even possible to configure different features for multiple images in
131
+ a single call using a block. The following example results in a single
132
+ request to the Cloud Vision API:
133
+
134
+ ```ruby
135
+ require "google/cloud/vision"
136
+
137
+ vision = Google::Cloud::Vision.new
138
+
139
+ face_image = vision.image "path/to/face.jpg"
140
+ landmark_image = vision.image "path/to/landmark.jpg"
141
+ text_image = vision.image "path/to/text.png"
142
+
143
+ annotations = vision.annotate do |annotate|
144
+ annotate.annotate face_image, faces: true, labels: true
145
+ annotate.annotate landmark_image, landmarks: true
146
+ annotate.annotate text_image, text: true
147
+ end
148
+
149
+ annotations[0].faces.count #=> 1
150
+ annotations[0].labels.count #=> 4
151
+ annotations[1].landmarks.count #=> 1
152
+ annotations[2].text.pages.count #=> 1
153
+ ```
154
+
155
+ The maximum number of results returned when performing face, landmark,
156
+ logo, and label detection are defined by
157
+ {Google::Cloud::Vision.default_max_faces},
158
+ {Google::Cloud::Vision.default_max_landmarks},
159
+ {Google::Cloud::Vision.default_max_logos}, and
160
+ {Google::Cloud::Vision.default_max_labels}, respectively. To change the
161
+ global defaults, you can update the configuration:
162
+
163
+ ```ruby
164
+ require "google/cloud/vision"
165
+
166
+ vision = Google::Cloud::Vision.new
167
+
168
+ Google::Cloud::Vision.default_max_faces = 1
169
+
170
+ annotation = vision.annotate "path/to/face.jpg", faces: true
171
+ annotation.faces.count #=> 1
172
+ ```
173
+
174
+ Or, to override a default for a single method call, simply pass an
175
+ integer instead of a flag:
176
+
177
+ ```ruby
178
+ require "google/cloud/vision"
179
+
180
+ vision = Google::Cloud::Vision.new
181
+
182
+ image = vision.image "path/to/face.jpg"
183
+
184
+ # Return just one face.
185
+ annotation = vision.annotate image, faces: 1
186
+ # Return up to 5 faces.
187
+ annotation = vision.annotate image, faces: 5
188
+ ```
189
+
190
+ ## Configuring timeout
191
+
192
+ You can configure the request `timeout` value in seconds.
193
+
194
+ ```ruby
195
+ require "google/cloud/vision"
196
+
197
+ vision = Google::Cloud::Vision.new timeout: 120
198
+ ```
199
+ ## Additional information
200
+
201
+ Google Cloud Vision can be configured to use gRPC's logging. To learn more, see
202
+ the {file:LOGGING.md Logging guide}.
@@ -0,0 +1,37 @@
1
+ # Troubleshooting
2
+
3
+ ## Where can I get more help?
4
+
5
+ ### Ask the Community
6
+
7
+ If you have a question about how to use a Google Cloud client library in your
8
+ project or are stuck in the Developer's console and don't know where to turn,
9
+ it's possible your questions have already been addressed by the community.
10
+
11
+ First, check out the appropriate tags on StackOverflow:
12
+ - [`google-cloud-platform+ruby+vision`][so-ruby]
13
+
14
+ Next, try searching through the issues on GitHub:
15
+
16
+ - [`api:vision` issues][gh-search-ruby]
17
+
18
+ Still nothing?
19
+
20
+ ### Ask the Developers
21
+
22
+ If you're experiencing a bug with the code, or have an idea for how it can be
23
+ improved, *please* create a new issue on GitHub so we can talk about it.
24
+
25
+ - [New issue][gh-ruby]
26
+
27
+ Or, you can ask questions on the [Google Cloud Platform Slack][slack-ruby]. You
28
+ can use the "ruby" channel for general Ruby questions, or use the
29
+ "google-cloud-ruby" channel if you have questions about this gem in particular.
30
+
31
+ [so-ruby]: http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby+vision
32
+
33
+ [gh-search-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues?q=label%3A%22api%3A+vision%22
34
+
35
+ [gh-ruby]: https://github.com/googlecloudplatform/google-cloud-ruby/issues/new
36
+
37
+ [slack-ruby]: https://gcp-slack.appspot.com/
@@ -16,7 +16,7 @@
16
16
  module Google
17
17
  module Cloud
18
18
  module Vision
19
- VERSION = "0.30.2".freeze
19
+ VERSION = "0.30.3".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.30.2
4
+ version: 0.30.3
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: 2018-09-10 00:00:00.000000000 Z
12
+ date: 2018-09-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: google-cloud-core
@@ -188,8 +188,14 @@ extensions: []
188
188
  extra_rdoc_files: []
189
189
  files:
190
190
  - ".yardopts"
191
+ - AUTHENTICATION.md
192
+ - CHANGELOG.md
193
+ - CODE_OF_CONDUCT.md
194
+ - CONTRIBUTING.md
191
195
  - LICENSE
192
- - README.md
196
+ - LOGGING.md
197
+ - OVERVIEW.md
198
+ - TROUBLESHOOTING.md
193
199
  - lib/google-cloud-vision.rb
194
200
  - lib/google/cloud/vision.rb
195
201
  - lib/google/cloud/vision/annotate.rb
data/README.md DELETED
@@ -1,98 +0,0 @@
1
- # google-cloud-vision
2
-
3
- [Google Cloud Vision](https://cloud.google.com/vision/) ([docs](https://cloud.google.com/vision/docs)) allows developers to easily integrate vision detection features within applications, including image labeling, face and landmark detection, optical character recognition (OCR), and tagging of explicit content.
4
-
5
- - [google-cloud-vision API documentation](http://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-vision/latest)
6
- - [google-cloud-vision on RubyGems](https://rubygems.org/gems/google-cloud-vision)
7
- - [Google Cloud Vision documentation](https://cloud.google.com/vision/docs)
8
-
9
- ## Quick Start
10
-
11
- ```sh
12
- $ gem install google-cloud-vision
13
- ```
14
-
15
- ## Authentication
16
-
17
- This library uses Service Account credentials to connect to Google Cloud services. When running on Compute Engine the credentials will be discovered automatically. When running on other environments the Service Account credentials can be specified by providing the path to the JSON file, or the JSON itself, in environment variables.
18
-
19
- Instructions and configuration options are covered in the [Authentication Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-vision/latest/file.AUTHENTICATION).
20
-
21
- ## Example
22
-
23
- ```ruby
24
- require "google/cloud/vision"
25
-
26
- vision = Google::Cloud::Vision.new
27
-
28
- image = vision.image "path/to/landmark.jpg"
29
-
30
- landmark = image.landmark
31
- landmark.description #=> "Mount Rushmore"
32
- ```
33
-
34
- ## Enabling Logging
35
-
36
- To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library. The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below, or a [`Google::Cloud::Logging::Logger`](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-logging/latest/Google/Cloud/Logging/Logger) that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb) and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
37
-
38
- Configuring a Ruby stdlib logger:
39
-
40
- ```ruby
41
- require "logger"
42
-
43
- module MyLogger
44
- LOGGER = Logger.new $stderr, level: Logger::WARN
45
- def logger
46
- LOGGER
47
- end
48
- end
49
-
50
- # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
51
- module GRPC
52
- extend MyLogger
53
- end
54
- ```
55
-
56
- ## Supported Ruby Versions
57
-
58
- This library is supported on Ruby 2.3+.
59
-
60
- Google provides official support for Ruby versions that are actively supported
61
- by Ruby Core—that is, Ruby versions that are either in normal maintenance or in
62
- security maintenance, and not end of life. Currently, this means Ruby 2.3 and
63
- later. Older versions of Ruby _may_ still work, but are unsupported and not
64
- recommended. See https://www.ruby-lang.org/en/downloads/branches/ for details
65
- about the Ruby support schedule.
66
-
67
- ## Versioning
68
-
69
- This library follows [Semantic Versioning](http://semver.org/).
70
-
71
- It is currently in major version zero (0.y.z), which means that anything may
72
- change at any time and the public API should not be considered stable.
73
-
74
- ## Contributing
75
-
76
- Contributions to this library are always welcome and highly encouraged.
77
-
78
- See the [Contributing
79
- Guide](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-vision/latest/file.CONTRIBUTING)
80
- for more information on how to get started.
81
-
82
- Please note that this project is released with a Contributor Code of Conduct. By
83
- participating in this project you agree to abide by its terms. See [Code of
84
- Conduct](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-vision/latest/file.CODE_OF_CONDUCT)
85
- for more information.
86
-
87
- ## License
88
-
89
- This library is licensed under Apache 2.0. Full license text is available in
90
- [LICENSE](https://googlecloudplatform.github.io/google-cloud-ruby/docs/google-cloud-vision/latest/file.LICENSE).
91
-
92
- ## Support
93
-
94
- Please [report bugs at the project on
95
- Github](https://github.com/GoogleCloudPlatform/google-cloud-ruby/issues). Don't
96
- hesitate to [ask
97
- questions](http://stackoverflow.com/questions/tagged/google-cloud-platform+ruby)
98
- about the client or APIs on [StackOverflow](http://stackoverflow.com).