sheets_v4 0.9.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.commitlintrc.yml +16 -0
- data/.husky/commit-msg +1 -0
- data/.markdownlint.yml +1 -1
- data/.release-please-manifest.json +3 -0
- data/.rubocop.yml +5 -35
- data/.yardopts +3 -1
- data/CHANGELOG.md +35 -0
- data/LICENSE.txt +1 -1
- data/README.md +116 -44
- data/Rakefile +9 -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 +2 -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
- data/release-please-config.json +22 -0
- metadata +67 -25
- 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: b51bff3e6d1c400ce384b9f7c52d51616848d0f88c82898919381292c12c2af3
|
4
|
+
data.tar.gz: a6a1fed0f9eb4e7c7766eecc122524212fc961b4d472a30472a9e841f4f2e1f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 765b6e15a54ae5532fdd2587fcd932b82ac600d1f89eb4c01fcd2ba6b851b557ae20874b4afab3e41490cb03614b1a452944ccde560bf6569f30cd2a912ba378
|
7
|
+
data.tar.gz: 3937faab4bc0ec7ca688df33cab1358bece7b29bfd1cddb6ca2ecc320c47a6038f2ea071a70c69bf9c6250460b7e5f9c81d745ab0eb2f4f5f17eff3410e956b3
|
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,41 @@ 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
|
+
## [0.10.1](https://github.com/main-branch/sheets_v4/compare/v0.10.0...v0.10.1) (2025-04-16)
|
8
|
+
|
9
|
+
|
10
|
+
### Bug Fixes
|
11
|
+
|
12
|
+
* Automate commit-to-publish workflow ([22e4653](https://github.com/main-branch/sheets_v4/commit/22e4653cc0699225951c1b85bae101677f3dfc04))
|
13
|
+
* Correctly mark constants as private ([3a7a35e](https://github.com/main-branch/sheets_v4/commit/3a7a35e94fec40759c995c24a7a93085407ee415))
|
14
|
+
|
15
|
+
## v0.10.0 (2024-10-11)
|
16
|
+
|
17
|
+
[Full Changelog](https://github.com/main-branch/sheets_v4/compare/v0.9.0..v0.10.0)
|
18
|
+
|
19
|
+
Changes since v0.9.0:
|
20
|
+
|
21
|
+
* 96d390e build: remove semver pr label check
|
22
|
+
* 54149ee build: enforce conventional commit message formatting
|
23
|
+
* 29ef270 Use shared Rubocop config
|
24
|
+
* 39a926d Update copyright notice in this project
|
25
|
+
* f4be18a Update links in gemspec
|
26
|
+
* 9c6eae1 Add Slack badge for this project in README
|
27
|
+
* eae2952 Update yardopts with new standard options
|
28
|
+
* 24d501c Use standard badges at the top of the README
|
29
|
+
* 0fb15d3 Standardize YARD and Markdown Lint configurations
|
30
|
+
* 07db14a Set JRuby --debug option when running tests in GitHub Actions workflows
|
31
|
+
* fe810d9 Integrate simplecov-rspec into the project
|
32
|
+
* 256ac35 Update continuous integration and experimental ruby builds
|
33
|
+
* 3f58109 Enforce the use of semver tags on PRs
|
34
|
+
* 9be5038 Auto correct Rubocop Gemspec/AddRuntimeDependency offenses
|
35
|
+
* c800d10 Add links to other gems in the Google API helpers series (#35)
|
36
|
+
* 207c4d6 Reformat examples/README.md (#34)
|
37
|
+
* 18b4d9b Move api_object_validation to the discovery_v1 gem (#33)
|
38
|
+
* cc48f8c Review and update documentation (#32)
|
39
|
+
* 2f2c8e2 Remove code for no longer used validate_api_object (#31)
|
40
|
+
* e566cfe Reformat examples (#30)
|
41
|
+
|
7
42
|
## v0.9.0 (2023-10-16)
|
8
43
|
|
9
44
|
[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,36 +3,50 @@
|
|
3
3
|
[](https://badge.fury.io/rb/sheets_v4)
|
4
4
|
[](https://rubydoc.info/gems/sheets_v4/)
|
5
5
|
[](https://rubydoc.info/gems/sheets_v4/file/CHANGELOG.md)
|
6
|
-
[](https://github.com/main-branch/sheets_v4/actions/workflows/continuous_integration.yml)
|
7
|
+
[](https://conventionalcommits.org)
|
9
|
+
[](https://main-branch.slack.com/archives/C07N5ULJQU9)
|
9
10
|
|
10
|
-
Unofficial helpers for the Google Sheets V4 API
|
11
|
+
Unofficial helpers and extensions for the Google Sheets V4 API
|
11
12
|
|
13
|
+
Gems in the Google API helper, extensions, and examples series:
|
14
|
+
|
15
|
+
* [discovery_v1](https://github.com/main-branch/discovery_v1)
|
16
|
+
* [drive_v3](https://github.com/main-branch/drive_v3)
|
17
|
+
* [sheets_v4](https://github.com/main-branch/sheets_v4)
|
18
|
+
|
19
|
+
## Contents
|
20
|
+
|
21
|
+
* [Contents](#contents)
|
12
22
|
* [Installation](#installation)
|
23
|
+
* [Examples](#examples)
|
13
24
|
* [Important links for programming Google Sheets](#important-links-for-programming-google-sheets)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
* [
|
18
|
-
|
19
|
-
|
20
|
-
|
25
|
+
* [SheetsV4 documenation](#sheetsv4-documenation)
|
26
|
+
* [General API documentation](#general-api-documentation)
|
27
|
+
* [Ruby implementation of the Sheets API](#ruby-implementation-of-the-sheets-api)
|
28
|
+
* [Other links](#other-links)
|
29
|
+
* [Getting started](#getting-started)
|
30
|
+
* [Create a Google Cloud project](#create-a-google-cloud-project)
|
31
|
+
* [Enable the APIs you want to use](#enable-the-apis-you-want-to-use)
|
32
|
+
* [Download a Google API credential file](#download-a-google-api-credential-file)
|
21
33
|
* [Usage](#usage)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
+
* [Obtaining an authenticated SheetsService](#obtaining-an-authenticated-sheetsservice)
|
35
|
+
* [Building a request](#building-a-request)
|
36
|
+
* [Method 1: constructing requests using `Google::Apis::SheetsV4::*` objects](#method-1-constructing-requests-using-googleapissheetsv4-objects)
|
37
|
+
* [Method 2: constructing requests using hashes](#method-2-constructing-requests-using-hashes)
|
38
|
+
* [Which method should be used?](#which-method-should-be-used)
|
39
|
+
* [Validating requests](#validating-requests)
|
40
|
+
* [Google Extensions](#google-extensions)
|
41
|
+
* [SheetsService Extensions](#sheetsservice-extensions)
|
42
|
+
* [Spreadsheet Extensions](#spreadsheet-extensions)
|
43
|
+
* [Sheet Extensions](#sheet-extensions)
|
44
|
+
* [Working with dates and times](#working-with-dates-and-times)
|
45
|
+
* [Working with colors](#working-with-colors)
|
34
46
|
* [Development](#development)
|
35
47
|
* [Contributing](#contributing)
|
48
|
+
* [Commit message guidelines](#commit-message-guidelines)
|
49
|
+
* [Pull request guidelines](#pull-request-guidelines)
|
36
50
|
* [License](#license)
|
37
51
|
|
38
52
|
## Installation
|
@@ -49,8 +63,28 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
49
63
|
gem install sheets_v4
|
50
64
|
```
|
51
65
|
|
66
|
+
## Examples
|
67
|
+
|
68
|
+
Many examples can be found in the `examples` directory of this project. The examples
|
69
|
+
have [a README of their own](https://github.com/main-branch/sheets_v4/tree/reformat_examples/examples)
|
70
|
+
which describes each example.
|
71
|
+
|
72
|
+
Prior to running an example, clone this project and run `bundle install` in the
|
73
|
+
project's root working directory.
|
74
|
+
|
75
|
+
Run an example using `bundle exec`. For example, to run the `set_background_color1`
|
76
|
+
example:
|
77
|
+
|
78
|
+
```shell
|
79
|
+
bundle exec examples/set_background_color1
|
80
|
+
```
|
81
|
+
|
52
82
|
## Important links for programming Google Sheets
|
53
83
|
|
84
|
+
### SheetsV4 documenation
|
85
|
+
|
86
|
+
This Gem's YARD documentation is hosted on [rubydoc.info]https://rubydoc.info/gems/sheets_v4/.
|
87
|
+
|
54
88
|
### General API documentation
|
55
89
|
|
56
90
|
* [Google Sheets API Overview](https://developers.google.com/sheets/api)
|
@@ -63,29 +97,31 @@ gem install sheets_v4
|
|
63
97
|
* [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
98
|
* [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
99
|
|
66
|
-
### Other
|
100
|
+
### Other links
|
67
101
|
|
68
102
|
* [Apps Script for Sheets](https://developers.google.com/apps-script/guides/sheets)
|
69
103
|
|
70
|
-
## Getting
|
104
|
+
## Getting started
|
71
105
|
|
72
|
-
In order to use this gem, you will need to obtain a Google API
|
106
|
+
In order to use this gem, you will need to obtain a Google API service account
|
73
107
|
credential following the instructions below.
|
74
108
|
|
75
|
-
###
|
109
|
+
### Create a Google Cloud project
|
76
110
|
|
77
111
|
Create a Google Cloud project using [these directions](https://developers.google.com/workspace/guides/create-project).
|
78
112
|
|
79
113
|
### Enable the APIs you want to use
|
80
114
|
|
81
115
|
Enable the Sheets API for this project using [these directions](https://developers.google.com/workspace/guides/enable-apis).
|
116
|
+
Optionally, enable the Drive API since you may need it to create a spreadsheet.
|
82
117
|
|
83
|
-
###
|
118
|
+
### Download a Google API credential file
|
84
119
|
|
85
|
-
Create a service account and download
|
120
|
+
Create a service account and download a credential file using [these directions](https://developers.google.com/workspace/guides/create-credentials#service-account).
|
86
121
|
|
87
|
-
You can store the download credential files anywhere on your system.
|
88
|
-
location is `~/.google-api-credential.json
|
122
|
+
You can store the download credential files anywhere on your system.
|
123
|
+
The recommended location is `~/.google-api-credential.json` since this is default
|
124
|
+
credential file that `SheetsV4.sheets_service` uses.
|
89
125
|
|
90
126
|
## Usage
|
91
127
|
|
@@ -115,8 +151,8 @@ an authenticated SheetsService object can be obtained with one method call:
|
|
115
151
|
sheets_service = SheetsV4.sheets_service
|
116
152
|
```
|
117
153
|
|
118
|
-
If the credential is stored
|
119
|
-
manually. `credential_source` can be a String:
|
154
|
+
If the credential is stored somewhere else, pass the `credential_source` to
|
155
|
+
`SheetsV4.sheets_service` manually. `credential_source` can be a String:
|
120
156
|
|
121
157
|
```Ruby
|
122
158
|
sheets_service = SheetsV4.sheets_service(credential_source: File.read('credential.json'))
|
@@ -253,29 +289,40 @@ Google Sheets API will do one of following depending on the nature of the proble
|
|
253
289
|
common result)
|
254
290
|
3. Not return an error with some of the batch requests not having the expected outcome
|
255
291
|
|
256
|
-
Luckily,
|
257
|
-
|
292
|
+
Luckily, you can validate that requests are valid and identifies precisely where
|
293
|
+
the request objects do not conform to the API description using the DiscoveryV1 API.
|
258
294
|
That is the subject of the next section [Validating requests](#validating-requests).
|
259
295
|
|
260
296
|
### Validating requests
|
261
297
|
|
262
|
-
|
263
|
-
|
264
|
-
Sheets API.
|
298
|
+
Use the [DiscoveryV1 API](https://github.com/main-branch/discovery_v1)
|
299
|
+
can be used to validate request object prior to using them in the Google Sheets API.
|
265
300
|
|
266
|
-
|
267
|
-
|
301
|
+
In this API, [`DiscoveryV1.validate_object`](https://rubydoc.info/gems/discovery_v1/DiscoveryV1#validate_object-class_method)
|
302
|
+
validates a request object for a given schema. This method takes a `schema_name`
|
303
|
+
and an `object` to validate. Valid schemas names for an API can be listed using
|
304
|
+
[`SheetsV4.api_object_schema_names`](https://rubydoc.info/gems/sheets_v4/SheetsV4#api_object_schema_names-class_method).
|
268
305
|
|
269
|
-
|
306
|
+
`validate_object` will either return `true` if `object` conforms to the schema OR it
|
270
307
|
will raise a RuntimeError noting where the object structure did not conform to
|
271
308
|
the schema.
|
272
309
|
|
273
310
|
In the previous examples (see [Building a request](#building-a-request)), the
|
274
|
-
following
|
311
|
+
following lines can be inserted after the `requests = ...` line to validate the
|
275
312
|
request:
|
276
313
|
|
277
314
|
```Ruby
|
278
|
-
|
315
|
+
require 'discovery_v1'
|
316
|
+
discovery_service = DiscoveryV1.discovery_service
|
317
|
+
rest_description = discovery_service.get_rest_api('sheets', 'v4')
|
318
|
+
schema_name = 'batch_update_spreadsheet_request'
|
319
|
+
object = requests
|
320
|
+
begin
|
321
|
+
DiscoveryV1.validate_object(rest_description:, schema_name:, object:)
|
322
|
+
puts 'BatchUpdateSpreadsheetRequest object is valid'
|
323
|
+
rescue RuntimeError => e
|
324
|
+
puts e.message
|
325
|
+
end
|
279
326
|
```
|
280
327
|
|
281
328
|
### Google Extensions
|
@@ -378,7 +425,7 @@ datetime = SheetsV4.gs_to_datetime(cell_value) #=> Mon, 17 May 2021 04:36:00 -07
|
|
378
425
|
datetime.utc #=> 2021-05-17 11:36:00 UTC
|
379
426
|
```
|
380
427
|
|
381
|
-
###
|
428
|
+
### Working with colors
|
382
429
|
|
383
430
|
Color objects (with appropriate :red, :green, :blue values) can be retrieved by name
|
384
431
|
using `SheetsV4.color(:black)` or `SheetsV4::Color.black` (these are equivalent).
|
@@ -407,6 +454,31 @@ commits and the created tag, and push the `.gem` file to
|
|
407
454
|
|
408
455
|
Bug reports and pull requests are welcome on [the main-branch/sheets_v4 GitHub project](https://github.com/main-branch/sheets_v4).
|
409
456
|
|
457
|
+
### Commit message guidelines
|
458
|
+
|
459
|
+
All commit messages must follow the [Conventional Commits
|
460
|
+
standard](https://www.conventionalcommits.org/en/v1.0.0/). This helps us maintain a
|
461
|
+
clear and structured commit history, automate versioning, and generate changelogs
|
462
|
+
effectively.
|
463
|
+
|
464
|
+
To ensure compliance, this project includes:
|
465
|
+
|
466
|
+
* A git commit-msg hook that validates your commit messages before they are accepted.
|
467
|
+
|
468
|
+
To activate the hook, you must have node installed and run `npm install`.
|
469
|
+
|
470
|
+
* A GitHub Actions workflow that will enforce the Conventional Commit standard as
|
471
|
+
part of the continuous integration pipeline.
|
472
|
+
|
473
|
+
Any commit message that does not conform to the Conventional Commits standard will
|
474
|
+
cause the workflow to fail and not allow the PR to be merged.
|
475
|
+
|
476
|
+
### Pull request guidelines
|
477
|
+
|
478
|
+
All pull requests must be merged using rebase merges. This ensures that commit
|
479
|
+
messages from the feature branch are preserved in the release branch, keeping the
|
480
|
+
history clean and meaningful.
|
481
|
+
|
410
482
|
## License
|
411
483
|
|
412
484
|
The gem is available as open source under the terms of the
|
data/Rakefile
CHANGED
@@ -25,6 +25,13 @@ rescue Bundler::BundlerError => e
|
|
25
25
|
exit e.status_code
|
26
26
|
end
|
27
27
|
|
28
|
+
# Make it so that calling `rake release` just calls `rake release:rubygems_push` to
|
29
|
+
# avoid creating and pushing a new tag.
|
30
|
+
|
31
|
+
Rake::Task['release'].clear
|
32
|
+
desc 'Customized release task to avoid creating a new tag'
|
33
|
+
task release: 'release:rubygem_push'
|
34
|
+
|
28
35
|
CLEAN << 'pkg'
|
29
36
|
CLEAN << 'Gemfile.lock'
|
30
37
|
|
@@ -48,17 +55,9 @@ CLEAN << 'rspec-report.xml'
|
|
48
55
|
|
49
56
|
require 'rubocop/rake_task'
|
50
57
|
|
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
|
58
|
+
RuboCop::RakeTask.new
|
60
59
|
|
61
|
-
|
60
|
+
# YARD
|
62
61
|
|
63
62
|
unless RUBY_PLATFORM == 'java'
|
64
63
|
# yard:build
|