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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8730b843169d2404228e744281e52a37624c61f33cb061b99e38178faab2cc9
4
- data.tar.gz: 4f156d01ec986dd39eb0c471f9838b1670d16c33240843dbec7b873489e10c68
3
+ metadata.gz: b51bff3e6d1c400ce384b9f7c52d51616848d0f88c82898919381292c12c2af3
4
+ data.tar.gz: a6a1fed0f9eb4e7c7766eecc122524212fc961b4d472a30472a9e841f4f2e1f1
5
5
  SHA512:
6
- metadata.gz: 3b6558bcfc332037e0bf21a1b9605e94a629bdd89bc7621a6afe455bb4451395b1178e4ba92c23ba61e76adef6fd6a9ec4a9f8abc326f4068fcc505c97172ecc
7
- data.tar.gz: 5fdce2afd7f3063452bbe79cc7ce35311d87d415c44027c566dbd27099e2ac748777b497a3a4f1e46a3e044e21463c4299fb58bf83df30f048d43a6f29c2529c
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 trailig punctuation in a header
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
@@ -0,0 +1,3 @@
1
+ {
2
+ ".": "0.10.1"
3
+ }
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
- NewCops: enable
3
- # Output extra information for each offense to make it easier to diagnose:
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
@@ -3,4 +3,6 @@
3
3
  --markup-provider=redcarpet
4
4
  --markup markdown
5
5
  - CHANGELOG.md
6
- - LICENSE.txt
6
+ - CONTRIBUTING.md
7
+ - RELEASING.md
8
+ - LICENSE.txt
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
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 James Couball
3
+ Copyright (c) 2024 James Couball
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -3,36 +3,50 @@
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/CI%20Build/badge.svg?branch=main)](https://github.com/main-branch/sheets_v4/actions?query=workflow%3ACI%20Build)
7
- [![Maintainability](https://api.codeclimate.com/v1/badges/aeebc016487c5cad881e/maintainability)](https://codeclimate.com/github/main-branch/sheets_v4/maintainability)
8
- [![Test Coverage](https://api.codeclimate.com/v1/badges/aeebc016487c5cad881e/test_coverage)](https://codeclimate.com/github/main-branch/sheets_v4/test_coverage)
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
+ [![Conventional
8
+ Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white)](https://conventionalcommits.org)
9
+ [![Slack](https://img.shields.io/badge/slack-main--branch/sheets__v4-yellow.svg?logo=slack)](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
- * [General API documentation](#general-api-documentation)
15
- * [Ruby implementation of the Sheets API](#ruby-implementation-of-the-sheets-api)
16
- * [Other Links](#other-links)
17
- * [Getting Started](#getting-started)
18
- * [Creating a Google Cloud project](#creating-a-google-cloud-project)
19
- * [Enable the APIs you want to use](#enable-the-apis-you-want-to-use)
20
- * [Create a Google API credentials](#create-a-google-api-credentials)
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
- * [Obtaining an authenticated SheetsService](#obtaining-an-authenticated-sheetsservice)
23
- * [Building a request](#building-a-request)
24
- * [Method 1: constructing requests using `Google::Apis::SheetsV4::*` objects](#method-1-constructing-requests-using-googleapissheetsv4-objects)
25
- * [Method 2: constructing requests using hashes](#method-2-constructing-requests-using-hashes)
26
- * [Which method should be used?](#which-method-should-be-used)
27
- * [Validating requests](#validating-requests)
28
- * [Google Extensions](#google-extensions)
29
- * [SheetsService Extensions](#sheetsservice-extensions)
30
- * [Spreadsheet Extensions](#spreadsheet-extensions)
31
- * [Sheet Extensions](#sheet-extensions)
32
- * [Working with dates and times](#working-with-dates-and-times)
33
- * [Colors](#colors)
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 Links
100
+ ### Other links
67
101
 
68
102
  * [Apps Script for Sheets](https://developers.google.com/apps-script/guides/sheets)
69
103
 
70
- ## Getting Started
104
+ ## Getting started
71
105
 
72
- In order to use this gem, you will need to obtain a Google API sheets service
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
- ### Creating a Google Cloud project
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
- ### Create a Google API credentials
118
+ ### Download a Google API credential file
84
119
 
85
- Create a service account and download credentials using [these directions](https://developers.google.com/workspace/guides/create-credentials#service-account).
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. The recommended
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 elsewhere, pass the credential_source to `SheetsV4.sheets_service`
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, this library provides a way to validate that requests are valid and
257
- identifies precisely where the request objects do not conform to the API description.
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
- The [`SheetsV4.validate_api_object`](https://rubydoc.info/gems/sheets_v4/SheetsV4#validate_api_object-class_method)
263
- method can be used to validate request objects prior to using them in the Google
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
- This method takes a `schema_name` and an `object` to validate. Schema names can be
267
- listed using [`SheetsV4.api_object_schema_names`](https://rubydoc.info/gems/sheets_v4/SheetsV4#api_object_schema_names-class_method).
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
- This method will either return `true` if `object` conforms to the schema OR it
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 line can be inserted after the `requests = ...` line to validate the
311
+ following lines can be inserted after the `requests = ...` line to validate the
275
312
  request:
276
313
 
277
314
  ```Ruby
278
- SheetsV4.validate_api_object(schema: 'batch_update_spreadsheet_request', object: requests)
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
- ### Colors
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 do |t|
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
- CLEAN << 'rubocop-report.json'
60
+ # YARD
62
61
 
63
62
  unless RUBY_PLATFORM == 'java'
64
63
  # yard:build