drive_v3 0.2.0 → 0.3.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 +38 -0
- data/LICENSE.txt +1 -1
- data/README.md +60 -22
- data/Rakefile +9 -10
- data/examples/README.md +70 -76
- data/examples/drive_service_batch +7 -1
- data/examples/file_create +127 -8
- data/examples/file_delete +6 -1
- data/examples/file_download_content +6 -1
- data/examples/file_export_spreadsheet +22 -2
- data/examples/file_recover_from_trash +10 -1
- data/examples/file_search +10 -1
- data/examples/file_send_to_trash +6 -1
- data/examples/file_upload_content +6 -1
- data/examples/permission_create +12 -1
- data/examples/permission_delete +7 -1
- data/examples/permission_list +13 -1
- data/examples/permission_update +14 -1
- data/lib/drive_v3/version.rb +1 -1
- data/package.json +11 -0
- data/release-please-config.json +22 -0
- metadata +53 -22
- data/examples/file_create_folder +0 -46
- data/examples/file_create_spreadsheet +0 -70
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cddde4d7f4a8592f6c8d81903562f5a7352dd68e1d8ee326ef1331419415c525
|
4
|
+
data.tar.gz: f12318aa45476e25d4517cd8bef98a99d8a5b352e3a1ec1f7f4673f600663901
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9970fad2fca76c679b5207ed98286f789782f77464015cecaa785c8b3fa020e43d811208f2bf00d11119f3c2dc9e4e8f622248f25c089e97364fb22d38678891
|
7
|
+
data.tar.gz: a42dc25b7b4ebbace2bd8fbcbaa0a480b56b56470a342416b1c523491bc02d53dd728f8b1df1114f93234cdd772ba452c5917077493dbad2d9f7f92c18937df5
|
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,44 @@ 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.3.1](https://github.com/main-branch/drive_v3/compare/v0.3.0...v0.3.1) (2025-04-16)
|
8
|
+
|
9
|
+
|
10
|
+
### Bug Fixes
|
11
|
+
|
12
|
+
* Automate commit-to-publish workflow ([9a07c66](https://github.com/main-branch/drive_v3/commit/9a07c663c0af7b80775d8b43a30357313c2733f1))
|
13
|
+
|
14
|
+
## v0.3.0 (2024-10-11)
|
15
|
+
|
16
|
+
[Full Changelog](https://github.com/main-branch/drive_v3/compare/v0.2.1..v0.3.0)
|
17
|
+
|
18
|
+
Changes since v0.2.1:
|
19
|
+
|
20
|
+
* c9aed1f build: remove semver pr label check
|
21
|
+
* eaac868 build: enforce conventional commit message formatting
|
22
|
+
* 5f44bc1 Use shared Rubocop config (#20)
|
23
|
+
* 52fb8ad Update copyright notice in this project (#19)
|
24
|
+
* c8b8973 Update links in gemspec
|
25
|
+
* be94ccb Add Slack badge for this project in README
|
26
|
+
* b17e527 Use standard badges at the top of the README
|
27
|
+
* d200a3e Update yardopts with new standard options
|
28
|
+
* 322805c Standardize YARD and Markdown Lint configurations
|
29
|
+
* 865eed7 Set JRuby --debug option when running tests in GitHub Actions workflows
|
30
|
+
* d675a2e Integrate simplecov-rspec into the project
|
31
|
+
* be896ab Update continuous integration and experimental ruby builds
|
32
|
+
* 6e5487a Enforce the use of semver tags on PRs
|
33
|
+
* 03e23b3 Auto correct rubocop Gemspec/AddRuntimeDependency offense
|
34
|
+
* 0c9230b Add links to other gems in the Google API helpers series (#8)
|
35
|
+
|
36
|
+
## v0.2.1 (2023-12-05)
|
37
|
+
|
38
|
+
[Full Changelog](https://github.com/main-branch/drive_v3/compare/v0.2.0..v0.2.1)
|
39
|
+
|
40
|
+
Changes since v0.2.0:
|
41
|
+
|
42
|
+
* f1b82bd Update examples to include the supports_all_drives parameter (#6)
|
43
|
+
* b26f1fa Release v0.2.0 (#5)
|
44
|
+
|
7
45
|
## v0.2.0 (2023-12-04)
|
8
46
|
|
9
47
|
[Full Changelog](https://github.com/main-branch/drive_v3/compare/v0.1.0..v0.2.0)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -3,38 +3,50 @@
|
|
3
3
|
[](https://badge.fury.io/rb/drive_v3)
|
4
4
|
[](https://rubydoc.info/gems/drive_v3/)
|
5
5
|
[](https://rubydoc.info/gems/drive_v3/file/CHANGELOG.md)
|
6
|
-
[](https://github.com/main-branch/drive_v3/actions/workflows/continuous_integration.yml)
|
7
|
+
[](https://conventionalcommits.org)
|
9
|
+
[](https://main-branch.slack.com/archives/C07NG2J1C72)
|
9
10
|
|
10
11
|
Unofficial helpers and extensions for the Google Drive V3 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)
|
13
23
|
* [Examples](#examples)
|
14
24
|
* [Important links for programming Google Drive](#important-links-for-programming-google-drive)
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
25
|
+
* [DriveV3 documenation](#drivev3-documenation)
|
26
|
+
* [General API documentation](#general-api-documentation)
|
27
|
+
* [Ruby implementation of the Drive API](#ruby-implementation-of-the-drive-api)
|
28
|
+
* [Other links](#other-links)
|
19
29
|
* [Getting started](#getting-started)
|
20
|
-
|
21
|
-
|
22
|
-
|
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)
|
23
33
|
* [Usage](#usage)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
* [Obtaining an authenticated DriveService](#obtaining-an-authenticated-driveservice)
|
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)
|
36
46
|
* [Development](#development)
|
37
47
|
* [Contributing](#contributing)
|
48
|
+
* [Commit message guidelines](#commit-message-guidelines)
|
49
|
+
* [Pull request guidelines](#pull-request-guidelines)
|
38
50
|
* [License](#license)
|
39
51
|
|
40
52
|
## Installation
|
@@ -430,6 +442,32 @@ commits and the created tag, and push the `.gem` file to
|
|
430
442
|
|
431
443
|
Bug reports and pull requests are welcome on [the main-branch/drive_v3 GitHub project](https://github.com/main-branch/drive_v3).
|
432
444
|
|
445
|
+
### Commit message guidelines
|
446
|
+
|
447
|
+
All commit messages must follow the [Conventional Commits
|
448
|
+
standard](https://www.conventionalcommits.org/en/v1.0.0/). This helps us maintain a
|
449
|
+
clear and structured commit history, automate versioning, and generate changelogs
|
450
|
+
effectively.
|
451
|
+
|
452
|
+
To ensure compliance, this project includes:
|
453
|
+
|
454
|
+
* A git commit-msg hook that validates your commit messages before they are accepted.
|
455
|
+
|
456
|
+
To activate the hook, you must have node installed and run `npm install`.
|
457
|
+
|
458
|
+
* A GitHub Actions workflow that will enforce the Conventional Commit standard as
|
459
|
+
part of the continuous integration pipeline.
|
460
|
+
|
461
|
+
Any commit message that does not conform to the Conventional Commits standard will
|
462
|
+
cause the workflow to fail and not allow the PR to be merged.
|
463
|
+
|
464
|
+
### Pull request guidelines
|
465
|
+
|
466
|
+
All pull requests must be merged using rebase merges. This ensures that commit
|
467
|
+
messages from the feature branch are preserved in the release branch, keeping the
|
468
|
+
history clean and meaningful.
|
469
|
+
|
470
|
+
|
433
471
|
## License
|
434
472
|
|
435
473
|
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
|
data/examples/README.md
CHANGED
@@ -4,53 +4,52 @@ Annotated examples written in Ruby.
|
|
4
4
|
|
5
5
|
Checked (✅︎) topics are completed. Topics without a check still need to be added.
|
6
6
|
|
7
|
-
* [
|
8
|
-
* [
|
9
|
-
|
10
|
-
|
11
|
-
* [
|
12
|
-
* [
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
* [
|
23
|
-
* [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
* [
|
28
|
-
* [
|
29
|
-
|
30
|
-
* [
|
31
|
-
* [
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
* [
|
41
|
-
* [
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
* [
|
46
|
-
* [Manage labels](#manage-labels)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
* [Search by label or field](#search-by-label-or-field)
|
7
|
+
* [Google Drive Examples](#google-drive-examples)
|
8
|
+
* [Getting started](#getting-started)
|
9
|
+
* [✅︎ Creating a Google API service account](#︎-creating-a-google-api-service-account)
|
10
|
+
* [✅︎ Creating a DriveService instance](#︎-creating-a-driveservice-instance)
|
11
|
+
* [✅︎ Batching DriveService requests](#︎-batching-driveservice-requests)
|
12
|
+
* [Files and folders](#files-and-folders)
|
13
|
+
* [✅︎ Search for files](#︎-search-for-files)
|
14
|
+
* [✅︎ Get file](#︎-get-file)
|
15
|
+
* [✅︎ Create a file](#︎-create-a-file)
|
16
|
+
* [✅︎ Upload file data](#︎-upload-file-data)
|
17
|
+
* [✅︎ Download file data](#︎-download-file-data)
|
18
|
+
* [✅︎ Export file](#︎-export-file)
|
19
|
+
* [✅︎ Send file to trash](#︎-send-file-to-trash)
|
20
|
+
* [✅︎ Recover file from trash](#︎-recover-file-from-trash)
|
21
|
+
* [✅︎ Delete a file](#︎-delete-a-file)
|
22
|
+
* [Share files, folders, and drives](#share-files-folders-and-drives)
|
23
|
+
* [✅︎ Create permission](#︎-create-permission)
|
24
|
+
* [✅︎ List permissions](#︎-list-permissions)
|
25
|
+
* [✅︎ Update permission](#︎-update-permission)
|
26
|
+
* [✅︎ Delete permission](#︎-delete-permission)
|
27
|
+
* [Shortcuts](#shortcuts)
|
28
|
+
* [Create a shortcut to a file](#create-a-shortcut-to-a-file)
|
29
|
+
* [Search for shortcuts](#search-for-shortcuts)
|
30
|
+
* [Other](#other)
|
31
|
+
* [File revisions](#file-revisions)
|
32
|
+
* [Store application-specific data](#store-application-specific-data)
|
33
|
+
* [Manage file metadata](#manage-file-metadata)
|
34
|
+
* [Manage comments and replies](#manage-comments-and-replies)
|
35
|
+
* [Add custom file properties](#add-custom-file-properties)
|
36
|
+
* [Create a shortcut to a Drive file](#create-a-shortcut-to-a-drive-file)
|
37
|
+
* [Create a shortcut to app content](#create-a-shortcut-to-app-content)
|
38
|
+
* [Protect file content from modification](#protect-file-content-from-modification)
|
39
|
+
* [Access link-shared files using resource keys](#access-link-shared-files-using-resource-keys)
|
40
|
+
* [Handle changes](#handle-changes)
|
41
|
+
* [Identify which change log to track](#identify-which-change-log-to-track)
|
42
|
+
* [Track changes for users and shared drives](#track-changes-for-users-and-shared-drives)
|
43
|
+
* [Retrieve changes](#retrieve-changes)
|
44
|
+
* [Receive notifications for resource changes](#receive-notifications-for-resource-changes)
|
45
|
+
* [Manage labels](#manage-labels)
|
46
|
+
* [Manage labels](#manage-labels-1)
|
47
|
+
* [Set label field](#set-label-field)
|
48
|
+
* [Unset label field](#unset-label-field)
|
49
|
+
* [Remove label](#remove-label)
|
50
|
+
* [List labels from file](#list-labels-from-file)
|
51
|
+
* [Return specific labels from a file](#return-specific-labels-from-a-file)
|
52
|
+
* [Search by label or field](#search-by-label-or-field)
|
54
53
|
|
55
54
|
## Getting started
|
56
55
|
|
@@ -109,42 +108,37 @@ shows how to get a
|
|
109
108
|
[File](https://github.com/googleapis/google-api-ruby-client/blob/main/generated/google-apis-drive_v3/lib/google/apis/drive_v3/classes.rb)
|
110
109
|
from the drive and controlling which fields are returned.
|
111
110
|
|
112
|
-
### ✅︎ Create
|
111
|
+
### ✅︎ Create a file
|
113
112
|
|
114
|
-
|
115
|
-
|
116
|
-
|
113
|
+
Using the `drive_service.create_file` with no parameters creates an empty data file
|
114
|
+
with the following attributes:
|
115
|
+
* `kind` is set to "drive.file",
|
116
|
+
* `id` is set to a unique id
|
117
|
+
* `name` is set to "Untitled"
|
118
|
+
* `mime_type` of application/octet-stream.
|
117
119
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
[examples/file_create](https://github.com/main-branch/drive_v3/blob/main/examples/file_create)
|
123
|
-
shows how to create an empty data file and write data to it.
|
124
|
-
|
125
|
-
### ✅︎ Create a folder
|
120
|
+
The `mime_type` parameter defines the type of file to create or to create a folder.
|
121
|
+
See [Google Workspace & Google Drive supported MIME types](https://developers.google.com/drive/api/guides/mime-types)
|
122
|
+
for a list of supported MIME types.
|
126
123
|
|
127
|
-
|
128
|
-
|
124
|
+
Google Apps files (document, spreadsheet, or presentation) may be created by specifying
|
125
|
+
their specific `mime-type`:
|
126
|
+
* **Google Docs**: application/vnd.google-apps.document
|
127
|
+
* **Google Sheets**: application/vnd.google-apps.spreadsheet
|
128
|
+
* **Google Slides**: application/vnd.google-apps.presentation
|
129
|
+
* See [Google Workspace & Google Drive supported MIME types](https://developers.google.com/drive/api/guides/mime-types)
|
130
|
+
for a complete list.
|
129
131
|
|
130
132
|
See [Create and populate folders](https://developers.google.com/drive/api/guides/folder#create-folder)
|
131
|
-
for more
|
132
|
-
|
133
|
-
### ✅︎ Create a spreadsheet, document, or presentation
|
133
|
+
for more about creating a folder. A folder is a file with a `mime_type` of
|
134
|
+
"application/vnd.google-apps.folder".
|
134
135
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
See [Create a spreadsheet](https://developers.google.com/sheets/api/guides/create#work_with_folders)
|
139
|
-
for more information.
|
140
|
-
|
141
|
-
Use the following mime-types for Google apps:
|
142
|
-
* Spreadsheet: **application/vnd.google-apps.spreadsheet**
|
143
|
-
* Document: **application/vnd.google-apps.document**
|
144
|
-
* Presentation: **application/vnd.google-apps.presentation**
|
136
|
+
Use the `:parents` parameter to give the id of the folder that should contain the
|
137
|
+
file. Omitting this parameter or passing an empty array will place the new file
|
138
|
+
in the user's `My Drive` root folder.
|
145
139
|
|
146
|
-
|
147
|
-
|
140
|
+
[examples/file_create](https://github.com/main-branch/drive_v3/blob/main/examples/file_create)
|
141
|
+
shows how to create a file specifying name, mime-type, parent, and initial data.
|
148
142
|
|
149
143
|
### ✅︎ Upload file data
|
150
144
|
|
@@ -51,6 +51,12 @@ permission = Google::Apis::DriveV3::Permission.new(
|
|
51
51
|
role: 'writer'
|
52
52
|
)
|
53
53
|
|
54
|
+
# Indicate that this application supports files in shared drives. An error will
|
55
|
+
# result if this is false (or omitted) AND you are trying to update the permissions
|
56
|
+
# on a file in a shared drive.
|
57
|
+
#
|
58
|
+
supports_all_drives = true
|
59
|
+
|
54
60
|
begin
|
55
61
|
results = [].tap do |request_results|
|
56
62
|
drive_service.batch do |service|
|
@@ -59,7 +65,7 @@ begin
|
|
59
65
|
#
|
60
66
|
# Collect the result (or error if there is one) in the block passed to
|
61
67
|
# `create_permission`
|
62
|
-
service.create_permission(spreadsheet_id, permission) do |res, err|
|
68
|
+
service.create_permission(spreadsheet_id, permission, supports_all_drives:) do |res, err|
|
63
69
|
request_results << (res || err.message)
|
64
70
|
end
|
65
71
|
end
|
data/examples/file_create
CHANGED
@@ -1,35 +1,143 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
# Create a file or folder in a Google Drive
|
5
|
+
|
6
|
+
require 'optparse'
|
7
|
+
|
8
|
+
# Parse the command line
|
9
|
+
#
|
10
|
+
# @example Create a file in a Google Drive
|
11
|
+
# file-create \
|
12
|
+
# [NAME] \
|
13
|
+
# [--parent ID] \
|
14
|
+
# [--mime-type MIME_TYPE] \
|
15
|
+
# [--content FILE_NAME [--content-type MIME_TYPE]]
|
16
|
+
#
|
17
|
+
# @example Create a new empty file with default title and mimetype in the user's My Drive
|
18
|
+
# file-create
|
19
|
+
#
|
20
|
+
# @example Create a file name 'My Data File' in the user's My Drive
|
21
|
+
# file-create 'My Data File'
|
22
|
+
#
|
23
|
+
# @example Create a file in a specific folder
|
24
|
+
# file-create 'My Data File' --parent '1V6RS_7_YgJmLDH-BDw3dpD8Np60Oi9ET'
|
25
|
+
#
|
26
|
+
# @example Create a specific kind of file (data file)
|
27
|
+
# file-create 'My Data File' --mime-type 'text/plain'
|
28
|
+
#
|
29
|
+
# @example Create a specific kind of file (spreadsheet)
|
30
|
+
# file-create 'My Data File' --mime-type 'application/vnd.google-apps.spreadsheet'
|
31
|
+
#
|
32
|
+
# @example Create a specific kind of file (document)
|
33
|
+
# file-create 'My Data File' --mime-type 'application/vnd.google-apps.document'
|
34
|
+
#
|
35
|
+
# @example Create a folder
|
36
|
+
# file-create 'My New Folder' --mime-type 'application/vnd.google-apps.folder'
|
37
|
+
#
|
38
|
+
# @example Create a file and load it with data from a file
|
39
|
+
# file-create 'My Data File' --content 'data.csv' --content-type 'text/csv'
|
40
|
+
#
|
41
|
+
# @example For a anyone
|
42
|
+
# permission-create FILE_ID \
|
43
|
+
# --type anyone \
|
44
|
+
# --role ROLE \
|
45
|
+
# [--expiration TIME] \
|
46
|
+
# [{--allow-file-discovery | --no-allow-file-discovery}]
|
47
|
+
#
|
48
|
+
class ParseCommandLine
|
49
|
+
def initialize(argv)
|
50
|
+
@argv = argv.dup
|
51
|
+
default_options
|
52
|
+
parser.parse!(@argv)
|
53
|
+
@name = @argv.shift
|
54
|
+
validate(@argv)
|
55
|
+
end
|
56
|
+
|
57
|
+
attr_reader :name, :parent_id, :mime_type, :content, :content_type
|
58
|
+
|
59
|
+
def banner = <<~BANNER
|
60
|
+
Usage:
|
61
|
+
|
62
|
+
#{$PROGRAM_NAME} [NAME] [options]
|
63
|
+
|
64
|
+
Creates a file in a Google Drive and displays the JSON properties
|
65
|
+
of that file.
|
66
|
+
|
67
|
+
WARNING: Omitting NAME will create a file named 'Untitled'.
|
68
|
+
|
69
|
+
Options:
|
70
|
+
BANNER
|
71
|
+
|
72
|
+
def parser
|
73
|
+
@parser ||= OptionParser.new(banner) do |opts|
|
74
|
+
option_definitions.each { |option_definition| opts.on(*option_definition) }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def help
|
79
|
+
puts parser
|
80
|
+
exit
|
81
|
+
end
|
82
|
+
|
83
|
+
def option_definitions
|
84
|
+
[
|
85
|
+
help_definition,
|
86
|
+
parent_definition, mime_type_definition,
|
87
|
+
content_definition, content_type_definition
|
88
|
+
].freeze
|
89
|
+
end
|
90
|
+
|
91
|
+
def help_definition = ['-h', '--help', '', ->(_value) { help }]
|
92
|
+
def parent_definition = ['--parent=ID', ->(value) { @parent_id = value }]
|
93
|
+
def mime_type_definition = ['--mime-type=MIME_TYPE', ->(value) { @mime_type = value }]
|
94
|
+
def content_definition = ['--content=FILE_NAME', ->(value) { @content = value }]
|
95
|
+
def content_type_definition = ['--content_type=MIME_TYPE', ->(value) { @content_type = value }]
|
96
|
+
|
97
|
+
def default_options; end
|
98
|
+
|
99
|
+
def validate(argv)
|
100
|
+
raise "Extra command line arguments: #{argv}" unless argv.empty?
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
4
104
|
# Create a data file
|
5
105
|
#
|
6
106
|
# When creating a data file, upload_source should be an IO object that
|
7
107
|
# responds to `read` and `size` (e.g. StringIO) or a string that names
|
8
108
|
# an existing file to upload.
|
9
109
|
|
110
|
+
options = ParseCommandLine.new(ARGV)
|
111
|
+
|
10
112
|
require 'drive_v3'
|
11
113
|
require 'json'
|
12
114
|
|
13
115
|
drive_service = DriveV3.drive_service
|
14
116
|
|
15
|
-
# If name is not specified as part of a create request, the file name
|
16
|
-
# 'Untitled'.
|
17
|
-
name =
|
117
|
+
# If name is not specified as part of a create request (or it is nil), the file name
|
118
|
+
# is named 'Untitled'.
|
119
|
+
name = options.name
|
18
120
|
|
19
121
|
# If parents not specified as part of a create request or is an empty array, the
|
20
122
|
# file is placed directly in the user's My Drive folder
|
21
123
|
#
|
22
124
|
# parents = ['id1', 'id2']
|
23
|
-
parents = [
|
125
|
+
parents = []
|
126
|
+
parents << options.parent_id if options.parent_id
|
24
127
|
|
25
128
|
# The MIME type of the file. Drive will attempt to automatically detect an
|
26
129
|
# appropriate value from uploaded content if no value is provided. The value
|
27
130
|
# cannot be changed unless a new revision is uploaded.
|
28
131
|
#
|
132
|
+
# See
|
133
|
+
# [Google Workspace & Google Drive supported MIME types](https://developers.google.com/drive/api/guides/mime-types)
|
134
|
+
# for a list of supported MIME types.
|
135
|
+
#
|
29
136
|
# The default MIME type is 'text/plain'
|
30
137
|
#
|
138
|
+
#
|
31
139
|
# mime_type = nil
|
32
|
-
mime_type =
|
140
|
+
mime_type = options.mime_type
|
33
141
|
|
34
142
|
file_metadata = { name:, parents:, mime_type: }
|
35
143
|
|
@@ -47,7 +155,7 @@ fields = '*'
|
|
47
155
|
# data file.
|
48
156
|
#
|
49
157
|
# upload_source = StringIO.new("This is my letter to the World\nThat never wrote to Me")
|
50
|
-
upload_source =
|
158
|
+
upload_source = options.content
|
51
159
|
|
52
160
|
# Content type indicates the MIME type of the upload_source. If not specified,
|
53
161
|
# the content type will be determined by calling MIME::Types.of with the
|
@@ -56,10 +164,21 @@ upload_source = StringIO.new("1,2,3\n4,5,6\n7,8,9")
|
|
56
164
|
# content_type = 'text/plain'
|
57
165
|
# CSV content type
|
58
166
|
# content_type = nil
|
59
|
-
content_type =
|
167
|
+
content_type = options.content_type
|
168
|
+
|
169
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
170
|
+
# this is false (or omitted) AND `create_file` tries to create a file in a shared drive.
|
171
|
+
#
|
172
|
+
supports_all_drives = true
|
60
173
|
|
61
174
|
begin
|
62
|
-
file = drive_service.create_file(
|
175
|
+
file = drive_service.create_file(
|
176
|
+
file_metadata,
|
177
|
+
fields:,
|
178
|
+
upload_source:,
|
179
|
+
content_type:,
|
180
|
+
supports_all_drives:
|
181
|
+
)
|
63
182
|
puts JSON.pretty_generate(file.to_h)
|
64
183
|
rescue StandardError => e
|
65
184
|
puts "An error occurred: #{e.message}"
|
data/examples/file_delete
CHANGED
@@ -14,10 +14,15 @@ drive_service = DriveV3.drive_service
|
|
14
14
|
file_id = ARGV[0] || ENV.fetch('FILE_ID', nil)
|
15
15
|
raise 'Missing file_id' unless file_id
|
16
16
|
|
17
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
18
|
+
# this is false (or omitted) AND `delete_file` tries to create a spreadsheet in a shared drive.
|
19
|
+
#
|
20
|
+
supports_all_drives = true
|
21
|
+
|
17
22
|
begin
|
18
23
|
print 'Delete file...'
|
19
24
|
# Does not return anything
|
20
|
-
drive_service.delete_file(file_id)
|
25
|
+
drive_service.delete_file(file_id, supports_all_drives:)
|
21
26
|
puts 'Success'
|
22
27
|
rescue StandardError => e
|
23
28
|
puts "An error occurred: #{e.message}"
|
@@ -17,10 +17,15 @@ raise 'Missing file_id' unless file_id
|
|
17
17
|
# to.
|
18
18
|
download_dest = StringIO.new
|
19
19
|
|
20
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
21
|
+
# this is false (or omitted) AND `get_file` tries to get a file from s shared drive.
|
22
|
+
#
|
23
|
+
supports_all_drives = true
|
24
|
+
|
20
25
|
# Read content from file
|
21
26
|
#
|
22
27
|
begin
|
23
|
-
drive_service.get_file(file_id, download_dest:)
|
28
|
+
drive_service.get_file(file_id, download_dest:, supports_all_drives:)
|
24
29
|
puts JSON.pretty_generate(download_dest.string)
|
25
30
|
rescue StandardError => e
|
26
31
|
puts "An error occurred: #{e.message}"
|
@@ -14,6 +14,15 @@ require 'json'
|
|
14
14
|
|
15
15
|
drive_service = DriveV3.drive_service
|
16
16
|
|
17
|
+
# Indicate that this application supports files in shared drives. An error will
|
18
|
+
# result if this is false (or omitted) AND you try to do something with a file or
|
19
|
+
# folder in a shared drive.
|
20
|
+
#
|
21
|
+
# Note that the `export_file` method does not require this parameter to export
|
22
|
+
# a file from a shared drive.
|
23
|
+
#
|
24
|
+
supports_all_drives = true
|
25
|
+
|
17
26
|
# First create a spreadsheet, populating with some data.
|
18
27
|
# Then get the file id of the spreadsheet.
|
19
28
|
|
@@ -25,7 +34,13 @@ fields = 'id, name'
|
|
25
34
|
upload_source = StringIO.new("1,2,3\n4,5,6\n7,8,9")
|
26
35
|
content_type = 'text/csv'
|
27
36
|
begin
|
28
|
-
file = drive_service.create_file(
|
37
|
+
file = drive_service.create_file(
|
38
|
+
file_metadata,
|
39
|
+
fields:,
|
40
|
+
upload_source:,
|
41
|
+
content_type:,
|
42
|
+
supports_all_drives:
|
43
|
+
)
|
29
44
|
puts JSON.pretty_generate(file.to_h)
|
30
45
|
rescue StandardError => e
|
31
46
|
puts "An error occurred: #{e.message}"
|
@@ -39,7 +54,12 @@ mime_type = 'application/pdf'
|
|
39
54
|
download_dest = "#{file.name}.pdf"
|
40
55
|
|
41
56
|
begin
|
42
|
-
drive_service.export_file(
|
57
|
+
drive_service.export_file(
|
58
|
+
file_id,
|
59
|
+
mime_type,
|
60
|
+
download_dest:,
|
61
|
+
supports_all_drives:
|
62
|
+
)
|
43
63
|
rescue StandardError => e
|
44
64
|
puts "An error occurred: #{e.message}"
|
45
65
|
exit 1
|
@@ -14,10 +14,19 @@ drive_service = DriveV3.drive_service
|
|
14
14
|
file_id = ARGV[0] || ENV.fetch('FILE_ID', nil)
|
15
15
|
raise 'Missing file_id' unless file_id
|
16
16
|
|
17
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
18
|
+
# this is false (or omitted) AND you are trying to update a file in a shared drive.
|
19
|
+
#
|
20
|
+
supports_all_drives = true
|
21
|
+
|
17
22
|
begin
|
18
23
|
print 'Recovering trashed file...'
|
19
24
|
file_object = { trashed: false }
|
20
|
-
file = drive_service.update_file(
|
25
|
+
file = drive_service.update_file(
|
26
|
+
file_id,
|
27
|
+
file_object,
|
28
|
+
supports_all_drives:
|
29
|
+
)
|
21
30
|
puts "update_file result:\n#{file.to_h.pretty_inspect}"
|
22
31
|
rescue StandardError => e
|
23
32
|
puts "An error occurred: #{e.message}"
|
data/examples/file_search
CHANGED
@@ -71,9 +71,17 @@ fields = '*'
|
|
71
71
|
#
|
72
72
|
include_items_from_all_drives = true
|
73
73
|
|
74
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
75
|
+
# this is false (or omitted) AND `list_files` returns a file from a shared drive.
|
76
|
+
#
|
77
|
+
supports_all_drives = true
|
78
|
+
|
74
79
|
loop do
|
75
80
|
file_list = @drive_service.list_files(
|
76
|
-
q:,
|
81
|
+
q:,
|
82
|
+
fields:,
|
83
|
+
include_items_from_all_drives:,
|
84
|
+
supports_all_drives:,
|
77
85
|
page_token:, page_size:
|
78
86
|
)
|
79
87
|
files += file_list.files.map(&:to_h)
|
@@ -84,3 +92,4 @@ end
|
|
84
92
|
# Print as JSON with links to each file and its parents
|
85
93
|
|
86
94
|
puts JSON.pretty_generate(files)
|
95
|
+
# puts files.count
|
data/examples/file_send_to_trash
CHANGED
@@ -14,10 +14,15 @@ drive_service = DriveV3.drive_service
|
|
14
14
|
file_id = ARGV[0] || ENV.fetch('FILE_ID', nil)
|
15
15
|
raise 'Missing file_id' unless file_id
|
16
16
|
|
17
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
18
|
+
# this is false (or omitted) AND you are trying to update a file in a shared drive.
|
19
|
+
#
|
20
|
+
supports_all_drives = true
|
21
|
+
|
17
22
|
begin
|
18
23
|
print 'Trash file...'
|
19
24
|
file_object = { trashed: true }
|
20
|
-
file = drive_service.update_file(file_id, file_object)
|
25
|
+
file = drive_service.update_file(file_id, file_object, supports_all_drives:)
|
21
26
|
puts "update_file result:\n#{file.to_h.pretty_inspect}"
|
22
27
|
rescue StandardError => e
|
23
28
|
puts "An error occurred: #{e.message}"
|
@@ -15,10 +15,15 @@ raise 'Missing file_id' unless file_id
|
|
15
15
|
#
|
16
16
|
upload_source = StringIO.new('This is the content that replaced the original content')
|
17
17
|
|
18
|
+
# Indicate that this application supports files in shared drives. An error will result if
|
19
|
+
# this is false (or omitted) AND you are trying to update a file in a shared drive.
|
20
|
+
#
|
21
|
+
supports_all_drives = true
|
22
|
+
|
18
23
|
# Replace the content of an existing file
|
19
24
|
#
|
20
25
|
begin
|
21
|
-
file = drive_service.update_file(file_id, upload_source:)
|
26
|
+
file = drive_service.update_file(file_id, upload_source:, supports_all_drives:)
|
22
27
|
puts JSON.pretty_generate(file.to_h)
|
23
28
|
rescue StandardError => e
|
24
29
|
puts "An error occurred: #{e.message}"
|
data/examples/permission_create
CHANGED
@@ -155,8 +155,19 @@ drive_service = DriveV3.drive_service
|
|
155
155
|
options = PermissionCreateCli.new(ARGV)
|
156
156
|
fields = '*'
|
157
157
|
|
158
|
+
# Indicate that this application supports files in shared drives. An error will
|
159
|
+
# result if this is false (or omitted) AND you are trying to update the permissions
|
160
|
+
# on a file in a shared drive.
|
161
|
+
#
|
162
|
+
supports_all_drives = true
|
163
|
+
|
158
164
|
begin
|
159
|
-
result = drive_service.create_permission(
|
165
|
+
result = drive_service.create_permission(
|
166
|
+
options.file_id,
|
167
|
+
options.permission,
|
168
|
+
fields:,
|
169
|
+
supports_all_drives:
|
170
|
+
)
|
160
171
|
# The result.id is 'anyoneWithLink' if type=anyone
|
161
172
|
# The result.id is of the existing permission if it already exists
|
162
173
|
puts JSON.pretty_generate(result.to_h)
|
data/examples/permission_delete
CHANGED
@@ -15,8 +15,14 @@ raise "Extra arguments: #{ARGV}" unless ARGV.empty?
|
|
15
15
|
|
16
16
|
drive_service = DriveV3.drive_service
|
17
17
|
|
18
|
+
# Indicate that this application supports files in shared drives. An error will
|
19
|
+
# result if this is false (or omitted) AND you are trying to delete the permissions
|
20
|
+
# on a file in a shared drive.
|
21
|
+
#
|
22
|
+
supports_all_drives = true
|
23
|
+
|
18
24
|
begin
|
19
|
-
drive_service.delete_permission(file_id, permission_id)
|
25
|
+
drive_service.delete_permission(file_id, permission_id, supports_all_drives:)
|
20
26
|
rescue StandardError => e
|
21
27
|
puts "An error occurred: #{e.message}"
|
22
28
|
end
|
data/examples/permission_list
CHANGED
@@ -39,8 +39,20 @@ page_token = nil
|
|
39
39
|
# fields = 'nextPageToken, files(id, name, parents, web_view_link)'
|
40
40
|
fields = '*'
|
41
41
|
|
42
|
+
# Indicate that this application supports files in shared drives. An error will
|
43
|
+
# result if this is false (or omitted) AND you are trying to list the permissions
|
44
|
+
# on a file in a shared drive.
|
45
|
+
#
|
46
|
+
supports_all_drives = true
|
47
|
+
|
42
48
|
loop do
|
43
|
-
permission_list = drive_service.list_permissions(
|
49
|
+
permission_list = drive_service.list_permissions(
|
50
|
+
file_id,
|
51
|
+
fields:,
|
52
|
+
page_token:,
|
53
|
+
page_size:,
|
54
|
+
supports_all_drives:
|
55
|
+
)
|
44
56
|
permissions += permission_list.permissions.map(&:to_h)
|
45
57
|
# Stop looping if there are no more pages
|
46
58
|
break unless (page_token = permission_list.next_page_token)
|
data/examples/permission_update
CHANGED
@@ -126,8 +126,21 @@ permission = options.permission
|
|
126
126
|
remove_expiration = options.remove_expiration
|
127
127
|
fields = '*'
|
128
128
|
|
129
|
+
# Indicate that this application supports files in shared drives. An error will
|
130
|
+
# result if this is false (or omitted) AND you are trying to update permissions
|
131
|
+
# on a file in a shared drive.
|
132
|
+
#
|
133
|
+
supports_all_drives = true
|
134
|
+
|
129
135
|
begin
|
130
|
-
result = drive_service.update_permission(
|
136
|
+
result = drive_service.update_permission(
|
137
|
+
file_id,
|
138
|
+
permission_id,
|
139
|
+
permission,
|
140
|
+
remove_expiration:,
|
141
|
+
fields:,
|
142
|
+
supports_all_drives:
|
143
|
+
)
|
131
144
|
puts "Permission updated: #{result.to_h.pretty_inspect}"
|
132
145
|
rescue StandardError => e
|
133
146
|
puts "An error occurred: #{e.message}"
|
data/lib/drive_v3/version.rb
CHANGED
data/package.json
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"bootstrap-sha": "5a278a837f3d444a85b9bcfd70bc194708bed0af",
|
3
|
+
"packages": {
|
4
|
+
".": {
|
5
|
+
"release-type": "ruby",
|
6
|
+
"package-name": "drive_v3",
|
7
|
+
"changelog-path": "CHANGELOG.md",
|
8
|
+
"version-file": "lib/drive_v3/version.rb",
|
9
|
+
"bump-minor-pre-major": true,
|
10
|
+
"bump-patch-for-minor-pre-major": true,
|
11
|
+
"draft": false,
|
12
|
+
"prerelease": false,
|
13
|
+
"include-component-in-tag": false
|
14
|
+
}
|
15
|
+
},
|
16
|
+
"plugins": [
|
17
|
+
{
|
18
|
+
"type": "sentence-case"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
|
22
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drive_v3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Couball
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler-audit
|
@@ -30,56 +29,70 @@ dependencies:
|
|
30
29
|
requirements:
|
31
30
|
- - "~>"
|
32
31
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
32
|
+
version: '2.1'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
37
36
|
requirements:
|
38
37
|
- - "~>"
|
39
38
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
39
|
+
version: '2.1'
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: main_branch_shared_rubocop_config
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0.1'
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.1'
|
41
54
|
- !ruby/object:Gem::Dependency
|
42
55
|
name: rake
|
43
56
|
requirement: !ruby/object:Gem::Requirement
|
44
57
|
requirements:
|
45
58
|
- - "~>"
|
46
59
|
- !ruby/object:Gem::Version
|
47
|
-
version: '13.
|
60
|
+
version: '13.2'
|
48
61
|
type: :development
|
49
62
|
prerelease: false
|
50
63
|
version_requirements: !ruby/object:Gem::Requirement
|
51
64
|
requirements:
|
52
65
|
- - "~>"
|
53
66
|
- !ruby/object:Gem::Version
|
54
|
-
version: '13.
|
67
|
+
version: '13.2'
|
55
68
|
- !ruby/object:Gem::Dependency
|
56
69
|
name: rspec
|
57
70
|
requirement: !ruby/object:Gem::Requirement
|
58
71
|
requirements:
|
59
72
|
- - "~>"
|
60
73
|
- !ruby/object:Gem::Version
|
61
|
-
version: '3.
|
74
|
+
version: '3.13'
|
62
75
|
type: :development
|
63
76
|
prerelease: false
|
64
77
|
version_requirements: !ruby/object:Gem::Requirement
|
65
78
|
requirements:
|
66
79
|
- - "~>"
|
67
80
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
81
|
+
version: '3.13'
|
69
82
|
- !ruby/object:Gem::Dependency
|
70
83
|
name: rubocop
|
71
84
|
requirement: !ruby/object:Gem::Requirement
|
72
85
|
requirements:
|
73
86
|
- - "~>"
|
74
87
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
88
|
+
version: '1.66'
|
76
89
|
type: :development
|
77
90
|
prerelease: false
|
78
91
|
version_requirements: !ruby/object:Gem::Requirement
|
79
92
|
requirements:
|
80
93
|
- - "~>"
|
81
94
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
95
|
+
version: '1.66'
|
83
96
|
- !ruby/object:Gem::Dependency
|
84
97
|
name: simplecov
|
85
98
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +121,20 @@ dependencies:
|
|
108
121
|
- - "~>"
|
109
122
|
- !ruby/object:Gem::Version
|
110
123
|
version: '0.8'
|
124
|
+
- !ruby/object:Gem::Dependency
|
125
|
+
name: simplecov-rspec
|
126
|
+
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0.3'
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0.3'
|
111
138
|
- !ruby/object:Gem::Dependency
|
112
139
|
name: redcarpet
|
113
140
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,14 +217,14 @@ dependencies:
|
|
190
217
|
requirements:
|
191
218
|
- - "~>"
|
192
219
|
- !ruby/object:Gem::Version
|
193
|
-
version: '0.
|
220
|
+
version: '0.55'
|
194
221
|
type: :runtime
|
195
222
|
prerelease: false
|
196
223
|
version_requirements: !ruby/object:Gem::Requirement
|
197
224
|
requirements:
|
198
225
|
- - "~>"
|
199
226
|
- !ruby/object:Gem::Version
|
200
|
-
version: '0.
|
227
|
+
version: '0.55'
|
201
228
|
- !ruby/object:Gem::Dependency
|
202
229
|
name: googleauth
|
203
230
|
requirement: !ruby/object:Gem::Requirement
|
@@ -218,14 +245,14 @@ dependencies:
|
|
218
245
|
requirements:
|
219
246
|
- - "~>"
|
220
247
|
- !ruby/object:Gem::Version
|
221
|
-
version: '2.
|
248
|
+
version: '2.3'
|
222
249
|
type: :runtime
|
223
250
|
prerelease: false
|
224
251
|
version_requirements: !ruby/object:Gem::Requirement
|
225
252
|
requirements:
|
226
253
|
- - "~>"
|
227
254
|
- !ruby/object:Gem::Version
|
228
|
-
version: '2.
|
255
|
+
version: '2.3'
|
229
256
|
- !ruby/object:Gem::Dependency
|
230
257
|
name: rltk
|
231
258
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,7 +274,10 @@ executables: []
|
|
247
274
|
extensions: []
|
248
275
|
extra_rdoc_files: []
|
249
276
|
files:
|
277
|
+
- ".commitlintrc.yml"
|
278
|
+
- ".husky/commit-msg"
|
250
279
|
- ".markdownlint.yml"
|
280
|
+
- ".release-please-manifest.json"
|
251
281
|
- ".rspec"
|
252
282
|
- ".rubocop.yml"
|
253
283
|
- ".yardopts"
|
@@ -259,8 +289,6 @@ files:
|
|
259
289
|
- examples/README.md
|
260
290
|
- examples/drive_service_batch
|
261
291
|
- examples/file_create
|
262
|
-
- examples/file_create_folder
|
263
|
-
- examples/file_create_spreadsheet
|
264
292
|
- examples/file_delete
|
265
293
|
- examples/file_download_content
|
266
294
|
- examples/file_export_spreadsheet
|
@@ -276,6 +304,8 @@ files:
|
|
276
304
|
- lib/drive_v3.rb
|
277
305
|
- lib/drive_v3/create_credential.rb
|
278
306
|
- lib/drive_v3/version.rb
|
307
|
+
- package.json
|
308
|
+
- release-please-config.json
|
279
309
|
homepage: https://github.com/main-branch/drive_v3
|
280
310
|
licenses:
|
281
311
|
- MIT
|
@@ -284,8 +314,8 @@ metadata:
|
|
284
314
|
rubygems_mfa_required: 'true'
|
285
315
|
homepage_uri: https://github.com/main-branch/drive_v3
|
286
316
|
source_code_uri: https://github.com/main-branch/drive_v3
|
287
|
-
|
288
|
-
|
317
|
+
documentation_uri: https://rubydoc.info/gems/drive_v3/0.3.1
|
318
|
+
changelog_uri: https://rubydoc.info/gems/drive_v3/0.3.1/file/CHANGELOG.md
|
289
319
|
rdoc_options: []
|
290
320
|
require_paths:
|
291
321
|
- lib
|
@@ -299,9 +329,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
329
|
- - ">="
|
300
330
|
- !ruby/object:Gem::Version
|
301
331
|
version: '0'
|
302
|
-
requirements:
|
303
|
-
|
304
|
-
|
332
|
+
requirements:
|
333
|
+
- 'Platform: Mac, Linux, or Windows'
|
334
|
+
- 'Ruby: MRI 3.1 or later, TruffleRuby 24 or later, or JRuby 9.4 or later'
|
335
|
+
rubygems_version: 3.6.7
|
305
336
|
specification_version: 4
|
306
337
|
summary: Unofficial helpers and extensions for the Google Drive V3 API
|
307
338
|
test_files: []
|
data/examples/file_create_folder
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Create a folder
|
5
|
-
#
|
6
|
-
# When creating a Google Drive folder, you create a file with a MIME type of
|
7
|
-
# 'application/vnd.google-apps.folder' and a name. You can also specify the
|
8
|
-
# folder's parent folder(s) and other metadata.
|
9
|
-
|
10
|
-
require 'drive_v3'
|
11
|
-
require 'json'
|
12
|
-
|
13
|
-
drive_service = DriveV3.drive_service
|
14
|
-
|
15
|
-
# If name is not specified as part of a create request, the file name is named
|
16
|
-
# 'Untitled'.
|
17
|
-
name = 'My New Folder'
|
18
|
-
|
19
|
-
# If parents not specified as part of a create request or is an empty array, the
|
20
|
-
# folder is placed directly in the user's My Drive folder
|
21
|
-
#
|
22
|
-
# parents = ['id1', 'id2']
|
23
|
-
parents = []
|
24
|
-
|
25
|
-
# The MIME type of the file. Drive will attempt to automatically detect an
|
26
|
-
# appropriate value from uploaded content if no value is provided. The value
|
27
|
-
# cannot be changed unless a new revision is uploaded.
|
28
|
-
#
|
29
|
-
# A folder MIME type is 'application/vnd.google-apps.folder'
|
30
|
-
#
|
31
|
-
mime_type = 'application/vnd.google-apps.folder'
|
32
|
-
|
33
|
-
# If fields is not specified, the following default fields are returned:
|
34
|
-
# id, name, kind, and mime_type. '*' can by used to return all fields.
|
35
|
-
# See https://developers.google.com/drive/api/v3/reference/files#resource
|
36
|
-
#
|
37
|
-
fields = '*'
|
38
|
-
|
39
|
-
file_metadata = { name:, parents:, mime_type: }
|
40
|
-
|
41
|
-
begin
|
42
|
-
file = drive_service.create_file(file_metadata, fields:)
|
43
|
-
puts JSON.pretty_generate(file.to_h)
|
44
|
-
rescue StandardError => e
|
45
|
-
puts "An error occurred: #{e.message}"
|
46
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
# Create a Google Sheets spreadsheet in Google Drive
|
5
|
-
#
|
6
|
-
# When creating a spreadsheet, you create a file with a MIME type of
|
7
|
-
# 'application/vnd.google-apps.spreadsheet' and a name. You can also specify the
|
8
|
-
# spreadsheet's parent folder and other metadata.
|
9
|
-
#
|
10
|
-
# The file_create method allows loading an Excel spreadheet or a sheet of data
|
11
|
-
# from CSV or TSV data. Specify the data to load using `upload_source` and
|
12
|
-
# `content_type` parameters. If `upload_source` is not specified, the file will
|
13
|
-
# be created as an empty spreadsheet.
|
14
|
-
|
15
|
-
require 'drive_v3'
|
16
|
-
require 'json'
|
17
|
-
|
18
|
-
drive_service = DriveV3.drive_service
|
19
|
-
|
20
|
-
# If name is not specified as part of a create request, the file name is named
|
21
|
-
# 'Untitled'.
|
22
|
-
name = 'My spreadsheet file'
|
23
|
-
|
24
|
-
# If parents not specified as part of a create request or is an empty array, the
|
25
|
-
# file is placed directly in the user's My Drive folder
|
26
|
-
#
|
27
|
-
# parents = ['id1', 'id2']
|
28
|
-
parents = []
|
29
|
-
|
30
|
-
# The MIME type of the file. Drive will attempt to automatically detect an
|
31
|
-
# appropriate value from uploaded content if no value is provided. The value
|
32
|
-
# cannot be changed unless a new revision is uploaded.
|
33
|
-
#
|
34
|
-
# The default MIME type is 'text/plain'
|
35
|
-
#
|
36
|
-
# mime_type = nil
|
37
|
-
mime_type = 'application/vnd.google-apps.spreadsheet'
|
38
|
-
|
39
|
-
file_metadata = { name:, parents:, mime_type: }
|
40
|
-
|
41
|
-
# If fields is not specified, the following default fields are returned:
|
42
|
-
# id, name, kind, and mime_type. '*' can by used to return all fields.
|
43
|
-
# See https://developers.google.com/drive/api/v3/reference/files#resource
|
44
|
-
#
|
45
|
-
fields = '*'
|
46
|
-
|
47
|
-
# When creating the data file, upload_source should be an IO object that
|
48
|
-
# responds to `read` and `size` (e.g. StringIO) or a string that names
|
49
|
-
# an existing file to upload.
|
50
|
-
#
|
51
|
-
# If upload_source is not specified, the file will be created as an empty
|
52
|
-
# data file.
|
53
|
-
#
|
54
|
-
upload_source = StringIO.new("1,2,3\n4,5,6\n7,8,9")
|
55
|
-
|
56
|
-
# Content type indicates the MIME type of `upload_source`. If not specified,
|
57
|
-
# the content type will be determined by calling MIME::Types.of with the
|
58
|
-
# upload_source's filename.
|
59
|
-
#
|
60
|
-
# content_type = 'text/plain'
|
61
|
-
# CSV content type
|
62
|
-
# content_type = nil
|
63
|
-
content_type = 'text/csv'
|
64
|
-
|
65
|
-
begin
|
66
|
-
file = drive_service.create_file(file_metadata, fields:, upload_source:, content_type:)
|
67
|
-
puts JSON.pretty_generate(file.to_h)
|
68
|
-
rescue StandardError => e
|
69
|
-
puts "An error occurred: #{e.message}"
|
70
|
-
end
|