sheets_v4 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.commitlintrc.yml +16 -0
- data/.husky/commit-msg +1 -0
- data/.markdownlint.yml +1 -1
- data/.rubocop.yml +5 -35
- data/.yardopts +3 -1
- data/CHANGELOG.md +27 -0
- data/LICENSE.txt +1 -1
- data/README.md +102 -28
- data/Rakefile +2 -10
- data/examples/README.md +230 -47
- data/examples/create_spreadsheet +11 -0
- data/examples/{set_background_color → set_background_color1} +21 -8
- data/examples/set_background_color2 +11 -21
- data/lib/sheets_v4/color.rb +2 -2
- data/lib/sheets_v4/convert_dates_and_times.rb +0 -2
- data/lib/sheets_v4/google_extensions/sheet.rb +0 -1
- data/lib/sheets_v4/google_extensions/sheets_service.rb +0 -1
- data/lib/sheets_v4/google_extensions/spreadsheet.rb +0 -1
- data/lib/sheets_v4/version.rb +1 -1
- data/lib/sheets_v4.rb +0 -36
- data/package.json +11 -0
- metadata +65 -22
- data/lib/sheets_v4/api_object_validation/load_schemas.rb +0 -155
- data/lib/sheets_v4/api_object_validation/resolve_schema_ref.rb +0 -72
- data/lib/sheets_v4/api_object_validation/traverse_object_tree.rb +0 -82
- data/lib/sheets_v4/api_object_validation/validate_api_object.rb +0 -87
- data/lib/sheets_v4/validate_api_objects/validate_api_object.rb +0 -87
- data/lib/sheets_v4/validate_api_objects.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e42d894f2be3f646b39758c38a76d3c035047c2397e5ff37d03d84ab027dd0e
|
4
|
+
data.tar.gz: 461f2acf46f01fd2e26a20bbdda0e40a13700d13348fb879b6ee825f37f12375
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef2a81afffe0e2c8514c9df98dd6444d24e87924b957cb320604ba2705e5aa161f4fb0e87a06c9da5eda666a34f2cf9ea9316023f123116af98dc69eaeb8e553
|
7
|
+
data.tar.gz: ed191d55200c3f04bc5ec66390bc83f0c0538062c75c7e3a74211530718933ed8722a3bf8dbf06af7658f587906da3e6124d6339e18feb20bb33618a9fb25af5
|
data/.commitlintrc.yml
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
---
|
2
|
+
extends: '@commitlint/config-conventional'
|
3
|
+
|
4
|
+
rules:
|
5
|
+
# See: https://commitlint.js.org/reference/rules.html
|
6
|
+
#
|
7
|
+
# Rules are made up by a name and a configuration array. The configuration array contains:
|
8
|
+
#
|
9
|
+
# * Severity [0..2]: 0 disable rule, 1 warning if violated, or 2 error if violated
|
10
|
+
# * Applicability [always|never]: never inverts the rule
|
11
|
+
# * Value: value to use for this rule
|
12
|
+
#
|
13
|
+
# Run `npx commitlint --print-config` to see the current setting for all rules.
|
14
|
+
#
|
15
|
+
body-leading-blank: [2, 'always']
|
16
|
+
footer-leading-blank: [2, 'always']
|
data/.husky/commit-msg
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
npx --no-install commitlint --edit "$1"
|
data/.markdownlint.yml
CHANGED
@@ -9,7 +9,7 @@ MD013: { line_length: 90, tables: false, code_blocks: false }
|
|
9
9
|
# Heading duplication is allowed for non-sibling headings
|
10
10
|
MD024: { siblings_only: true }
|
11
11
|
|
12
|
-
# Do not allow the specified
|
12
|
+
# Do not allow the specified trailing punctuation in a header
|
13
13
|
MD026: { punctuation: '.,;:' }
|
14
14
|
|
15
15
|
# Order list items must have a prefix that increases in numerical order
|
data/.rubocop.yml
CHANGED
@@ -1,37 +1,7 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
main_branch_shared_rubocop_config: config/rubocop.yml
|
3
|
+
|
1
4
|
AllCops:
|
2
|
-
|
3
|
-
#
|
4
|
-
DisplayCopNames: true
|
5
|
-
DisplayStyleGuide: true
|
6
|
-
ExtraDetails: true
|
7
|
-
SuggestExtensions: false
|
8
|
-
# RuboCop enforces rules depending on the oldest version of Ruby which
|
9
|
-
# your project supports:
|
5
|
+
# Pin this project to Ruby 3.1 in case the shared config above is upgraded to 3.2
|
6
|
+
# or later.
|
10
7
|
TargetRubyVersion: 3.1
|
11
|
-
|
12
|
-
Gemspec/DevelopmentDependencies:
|
13
|
-
EnforcedStyle: gemspec
|
14
|
-
|
15
|
-
# The default max line length is 80 characters
|
16
|
-
Layout/LineLength:
|
17
|
-
Max: 120
|
18
|
-
|
19
|
-
# The DSL for RSpec and the gemspec file make it very hard to limit block length:
|
20
|
-
Metrics/BlockLength:
|
21
|
-
Exclude:
|
22
|
-
- "spec/spec_helper.rb"
|
23
|
-
- "spec/**/*_spec.rb"
|
24
|
-
- "*.gemspec"
|
25
|
-
|
26
|
-
Metrics/ModuleLength:
|
27
|
-
CountAsOne: ['hash']
|
28
|
-
|
29
|
-
# When writing minitest tests, it is very hard to limit test class length:
|
30
|
-
Metrics/ClassLength:
|
31
|
-
CountAsOne: ['hash']
|
32
|
-
Exclude:
|
33
|
-
- "test/**/*_test.rb"
|
34
|
-
|
35
|
-
Style/AsciiComments:
|
36
|
-
Enabled: false
|
37
|
-
|
data/.yardopts
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,33 @@ Changes for each release are listed in this file.
|
|
4
4
|
|
5
5
|
This project adheres to [Semantic Versioning](https://semver.org/) for its releases.
|
6
6
|
|
7
|
+
## v0.10.0 (2024-10-11)
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/main-branch/sheets_v4/compare/v0.9.0..v0.10.0)
|
10
|
+
|
11
|
+
Changes since v0.9.0:
|
12
|
+
|
13
|
+
* 96d390e build: remove semver pr label check
|
14
|
+
* 54149ee build: enforce conventional commit message formatting
|
15
|
+
* 29ef270 Use shared Rubocop config
|
16
|
+
* 39a926d Update copyright notice in this project
|
17
|
+
* f4be18a Update links in gemspec
|
18
|
+
* 9c6eae1 Add Slack badge for this project in README
|
19
|
+
* eae2952 Update yardopts with new standard options
|
20
|
+
* 24d501c Use standard badges at the top of the README
|
21
|
+
* 0fb15d3 Standardize YARD and Markdown Lint configurations
|
22
|
+
* 07db14a Set JRuby --debug option when running tests in GitHub Actions workflows
|
23
|
+
* fe810d9 Integrate simplecov-rspec into the project
|
24
|
+
* 256ac35 Update continuous integration and experimental ruby builds
|
25
|
+
* 3f58109 Enforce the use of semver tags on PRs
|
26
|
+
* 9be5038 Auto correct Rubocop Gemspec/AddRuntimeDependency offenses
|
27
|
+
* c800d10 Add links to other gems in the Google API helpers series (#35)
|
28
|
+
* 207c4d6 Reformat examples/README.md (#34)
|
29
|
+
* 18b4d9b Move api_object_validation to the discovery_v1 gem (#33)
|
30
|
+
* cc48f8c Review and update documentation (#32)
|
31
|
+
* 2f2c8e2 Remove code for no longer used validate_api_object (#31)
|
32
|
+
* e566cfe Reformat examples (#30)
|
33
|
+
|
7
34
|
## v0.9.0 (2023-10-16)
|
8
35
|
|
9
36
|
[Full Changelog](https://github.com/main-branch/sheets_v4/compare/v0.8.0..v0.9.0)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -3,21 +3,35 @@
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/sheets_v4.svg)](https://badge.fury.io/rb/sheets_v4)
|
4
4
|
[![Documentation](https://img.shields.io/badge/Documentation-Latest-green)](https://rubydoc.info/gems/sheets_v4/)
|
5
5
|
[![Change Log](https://img.shields.io/badge/CHANGELOG-Latest-green)](https://rubydoc.info/gems/sheets_v4/file/CHANGELOG.md)
|
6
|
-
[![Build Status](https://github.com/main-branch/sheets_v4/workflows/
|
6
|
+
[![Build Status](https://github.com/main-branch/sheets_v4/actions/workflows/continuous_integration.yml/badge.svg)](https://github.com/main-branch/sheets_v4/actions/workflows/continuous_integration.yml)
|
7
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/aeebc016487c5cad881e/maintainability)](https://codeclimate.com/github/main-branch/sheets_v4/maintainability)
|
8
8
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/aeebc016487c5cad881e/test_coverage)](https://codeclimate.com/github/main-branch/sheets_v4/test_coverage)
|
9
|
+
[![Conventional
|
10
|
+
Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
|
11
|
+
[![Slack](https://img.shields.io/badge/slack-main--branch/sheets__v4-yellow.svg?logo=slack)](https://main-branch.slack.com/archives/C07N5ULJQU9)
|
9
12
|
|
10
|
-
Unofficial helpers for the Google Sheets V4 API
|
13
|
+
Unofficial helpers and extensions for the Google Sheets V4 API
|
11
14
|
|
15
|
+
Gems in the Google API helper, extensions, and examples series:
|
16
|
+
|
17
|
+
* [discovery_v1](https://github.com/main-branch/discovery_v1)
|
18
|
+
* [drive_v3](https://github.com/main-branch/drive_v3)
|
19
|
+
* [sheets_v4](https://github.com/main-branch/sheets_v4)
|
20
|
+
|
21
|
+
## Contents
|
22
|
+
|
23
|
+
* [Contents](#contents)
|
12
24
|
* [Installation](#installation)
|
25
|
+
* [Examples](#examples)
|
13
26
|
* [Important links for programming Google Sheets](#important-links-for-programming-google-sheets)
|
27
|
+
* [SheetsV4 documenation](#sheetsv4-documenation)
|
14
28
|
* [General API documentation](#general-api-documentation)
|
15
29
|
* [Ruby implementation of the Sheets API](#ruby-implementation-of-the-sheets-api)
|
16
|
-
* [Other
|
17
|
-
* [Getting
|
18
|
-
* [
|
30
|
+
* [Other links](#other-links)
|
31
|
+
* [Getting started](#getting-started)
|
32
|
+
* [Create a Google Cloud project](#create-a-google-cloud-project)
|
19
33
|
* [Enable the APIs you want to use](#enable-the-apis-you-want-to-use)
|
20
|
-
* [
|
34
|
+
* [Download a Google API credential file](#download-a-google-api-credential-file)
|
21
35
|
* [Usage](#usage)
|
22
36
|
* [Obtaining an authenticated SheetsService](#obtaining-an-authenticated-sheetsservice)
|
23
37
|
* [Building a request](#building-a-request)
|
@@ -30,9 +44,11 @@ Unofficial helpers for the Google Sheets V4 API
|
|
30
44
|
* [Spreadsheet Extensions](#spreadsheet-extensions)
|
31
45
|
* [Sheet Extensions](#sheet-extensions)
|
32
46
|
* [Working with dates and times](#working-with-dates-and-times)
|
33
|
-
* [
|
47
|
+
* [Working with colors](#working-with-colors)
|
34
48
|
* [Development](#development)
|
35
49
|
* [Contributing](#contributing)
|
50
|
+
* [Commit message guidelines](#commit-message-guidelines)
|
51
|
+
* [Pull request guidelines](#pull-request-guidelines)
|
36
52
|
* [License](#license)
|
37
53
|
|
38
54
|
## Installation
|
@@ -49,8 +65,28 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
49
65
|
gem install sheets_v4
|
50
66
|
```
|
51
67
|
|
68
|
+
## Examples
|
69
|
+
|
70
|
+
Many examples can be found in the `examples` directory of this project. The examples
|
71
|
+
have [a README of their own](https://github.com/main-branch/sheets_v4/tree/reformat_examples/examples)
|
72
|
+
which describes each example.
|
73
|
+
|
74
|
+
Prior to running an example, clone this project and run `bundle install` in the
|
75
|
+
project's root working directory.
|
76
|
+
|
77
|
+
Run an example using `bundle exec`. For example, to run the `set_background_color1`
|
78
|
+
example:
|
79
|
+
|
80
|
+
```shell
|
81
|
+
bundle exec examples/set_background_color1
|
82
|
+
```
|
83
|
+
|
52
84
|
## Important links for programming Google Sheets
|
53
85
|
|
86
|
+
### SheetsV4 documenation
|
87
|
+
|
88
|
+
This Gem's YARD documentation is hosted on [rubydoc.info]https://rubydoc.info/gems/sheets_v4/.
|
89
|
+
|
54
90
|
### General API documentation
|
55
91
|
|
56
92
|
* [Google Sheets API Overview](https://developers.google.com/sheets/api)
|
@@ -63,29 +99,31 @@ gem install sheets_v4
|
|
63
99
|
* [SheetsService Class](https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-sheets_v4/lib/google/apis/sheets_v4/service.rb)
|
64
100
|
* [All Other Sheets Classes](https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-sheets_v4/lib/google/apis/sheets_v4/classes.rb)
|
65
101
|
|
66
|
-
### Other
|
102
|
+
### Other links
|
67
103
|
|
68
104
|
* [Apps Script for Sheets](https://developers.google.com/apps-script/guides/sheets)
|
69
105
|
|
70
|
-
## Getting
|
106
|
+
## Getting started
|
71
107
|
|
72
|
-
In order to use this gem, you will need to obtain a Google API
|
108
|
+
In order to use this gem, you will need to obtain a Google API service account
|
73
109
|
credential following the instructions below.
|
74
110
|
|
75
|
-
###
|
111
|
+
### Create a Google Cloud project
|
76
112
|
|
77
113
|
Create a Google Cloud project using [these directions](https://developers.google.com/workspace/guides/create-project).
|
78
114
|
|
79
115
|
### Enable the APIs you want to use
|
80
116
|
|
81
117
|
Enable the Sheets API for this project using [these directions](https://developers.google.com/workspace/guides/enable-apis).
|
118
|
+
Optionally, enable the Drive API since you may need it to create a spreadsheet.
|
82
119
|
|
83
|
-
###
|
120
|
+
### Download a Google API credential file
|
84
121
|
|
85
|
-
Create a service account and download
|
122
|
+
Create a service account and download a credential file using [these directions](https://developers.google.com/workspace/guides/create-credentials#service-account).
|
86
123
|
|
87
|
-
You can store the download credential files anywhere on your system.
|
88
|
-
location is `~/.google-api-credential.json
|
124
|
+
You can store the download credential files anywhere on your system.
|
125
|
+
The recommended location is `~/.google-api-credential.json` since this is default
|
126
|
+
credential file that `SheetsV4.sheets_service` uses.
|
89
127
|
|
90
128
|
## Usage
|
91
129
|
|
@@ -115,8 +153,8 @@ an authenticated SheetsService object can be obtained with one method call:
|
|
115
153
|
sheets_service = SheetsV4.sheets_service
|
116
154
|
```
|
117
155
|
|
118
|
-
If the credential is stored
|
119
|
-
manually. `credential_source` can be a String:
|
156
|
+
If the credential is stored somewhere else, pass the `credential_source` to
|
157
|
+
`SheetsV4.sheets_service` manually. `credential_source` can be a String:
|
120
158
|
|
121
159
|
```Ruby
|
122
160
|
sheets_service = SheetsV4.sheets_service(credential_source: File.read('credential.json'))
|
@@ -253,29 +291,40 @@ Google Sheets API will do one of following depending on the nature of the proble
|
|
253
291
|
common result)
|
254
292
|
3. Not return an error with some of the batch requests not having the expected outcome
|
255
293
|
|
256
|
-
Luckily,
|
257
|
-
|
294
|
+
Luckily, you can validate that requests are valid and identifies precisely where
|
295
|
+
the request objects do not conform to the API description using the DiscoveryV1 API.
|
258
296
|
That is the subject of the next section [Validating requests](#validating-requests).
|
259
297
|
|
260
298
|
### Validating requests
|
261
299
|
|
262
|
-
|
263
|
-
|
264
|
-
Sheets API.
|
300
|
+
Use the [DiscoveryV1 API](https://github.com/main-branch/discovery_v1)
|
301
|
+
can be used to validate request object prior to using them in the Google Sheets API.
|
265
302
|
|
266
|
-
|
267
|
-
|
303
|
+
In this API, [`DiscoveryV1.validate_object`](https://rubydoc.info/gems/discovery_v1/DiscoveryV1#validate_object-class_method)
|
304
|
+
validates a request object for a given schema. This method takes a `schema_name`
|
305
|
+
and an `object` to validate. Valid schemas names for an API can be listed using
|
306
|
+
[`SheetsV4.api_object_schema_names`](https://rubydoc.info/gems/sheets_v4/SheetsV4#api_object_schema_names-class_method).
|
268
307
|
|
269
|
-
|
308
|
+
`validate_object` will either return `true` if `object` conforms to the schema OR it
|
270
309
|
will raise a RuntimeError noting where the object structure did not conform to
|
271
310
|
the schema.
|
272
311
|
|
273
312
|
In the previous examples (see [Building a request](#building-a-request)), the
|
274
|
-
following
|
313
|
+
following lines can be inserted after the `requests = ...` line to validate the
|
275
314
|
request:
|
276
315
|
|
277
316
|
```Ruby
|
278
|
-
|
317
|
+
require 'discovery_v1'
|
318
|
+
discovery_service = DiscoveryV1.discovery_service
|
319
|
+
rest_description = discovery_service.get_rest_api('sheets', 'v4')
|
320
|
+
schema_name = 'batch_update_spreadsheet_request'
|
321
|
+
object = requests
|
322
|
+
begin
|
323
|
+
DiscoveryV1.validate_object(rest_description:, schema_name:, object:)
|
324
|
+
puts 'BatchUpdateSpreadsheetRequest object is valid'
|
325
|
+
rescue RuntimeError => e
|
326
|
+
puts e.message
|
327
|
+
end
|
279
328
|
```
|
280
329
|
|
281
330
|
### Google Extensions
|
@@ -378,7 +427,7 @@ datetime = SheetsV4.gs_to_datetime(cell_value) #=> Mon, 17 May 2021 04:36:00 -07
|
|
378
427
|
datetime.utc #=> 2021-05-17 11:36:00 UTC
|
379
428
|
```
|
380
429
|
|
381
|
-
###
|
430
|
+
### Working with colors
|
382
431
|
|
383
432
|
Color objects (with appropriate :red, :green, :blue values) can be retrieved by name
|
384
433
|
using `SheetsV4.color(:black)` or `SheetsV4::Color.black` (these are equivalent).
|
@@ -407,6 +456,31 @@ commits and the created tag, and push the `.gem` file to
|
|
407
456
|
|
408
457
|
Bug reports and pull requests are welcome on [the main-branch/sheets_v4 GitHub project](https://github.com/main-branch/sheets_v4).
|
409
458
|
|
459
|
+
### Commit message guidelines
|
460
|
+
|
461
|
+
All commit messages must follow the [Conventional Commits
|
462
|
+
standard](https://www.conventionalcommits.org/en/v1.0.0/). This helps us maintain a
|
463
|
+
clear and structured commit history, automate versioning, and generate changelogs
|
464
|
+
effectively.
|
465
|
+
|
466
|
+
To ensure compliance, this project includes:
|
467
|
+
|
468
|
+
* A git commit-msg hook that validates your commit messages before they are accepted.
|
469
|
+
|
470
|
+
To activate the hook, you must have node installed and run `npm install`.
|
471
|
+
|
472
|
+
* A GitHub Actions workflow that will enforce the Conventional Commit standard as
|
473
|
+
part of the continuous integration pipeline.
|
474
|
+
|
475
|
+
Any commit message that does not conform to the Conventional Commits standard will
|
476
|
+
cause the workflow to fail and not allow the PR to be merged.
|
477
|
+
|
478
|
+
### Pull request guidelines
|
479
|
+
|
480
|
+
All pull requests must be merged using rebase merges. This ensures that commit
|
481
|
+
messages from the feature branch are preserved in the release branch, keeping the
|
482
|
+
history clean and meaningful.
|
483
|
+
|
410
484
|
## License
|
411
485
|
|
412
486
|
The gem is available as open source under the terms of the
|
data/Rakefile
CHANGED
@@ -48,17 +48,9 @@ CLEAN << 'rspec-report.xml'
|
|
48
48
|
|
49
49
|
require 'rubocop/rake_task'
|
50
50
|
|
51
|
-
RuboCop::RakeTask.new
|
52
|
-
t.options = %w[
|
53
|
-
--display-cop-names
|
54
|
-
--display-style-guide
|
55
|
-
--extra-details
|
56
|
-
--format progress
|
57
|
-
--format json --out rubocop-report.json
|
58
|
-
]
|
59
|
-
end
|
51
|
+
RuboCop::RakeTask.new
|
60
52
|
|
61
|
-
|
53
|
+
# YARD
|
62
54
|
|
63
55
|
unless RUBY_PLATFORM == 'java'
|
64
56
|
# yard:build
|