google_drive 3.0.2 → 3.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/google_drive/acl.rb +4 -4
- data/lib/google_drive/collection.rb +3 -3
- data/lib/google_drive/file.rb +9 -9
- data/lib/google_drive/session.rb +11 -13
- data/lib/google_drive/worksheet.rb +38 -8
- metadata +28 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8579ea758131c51c083928052abf518b1f327b9b9666e798c17007801f0c1476
|
4
|
+
data.tar.gz: c04c47fe2d0337bb2e471227ad66e90b857b33784f01f8d60d7406f63fcad92b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d52bac1e4e05bd2dee4503a67a4c9da7eaeee700dfa9bca2f668bc88c04df065b5a7c209a4808d98a63610cb27318df3bef859e6e016ba4fbe1029782440aa58
|
7
|
+
data.tar.gz: 24facac6a6116210ea76b82f139fcd5c93e5624fbdb889f2fb89de65c98a6eb11ae31fb0c892cb221a5b689e2fc5271bb6636ad1215559e2689a8ef9b5edbf85
|
data/lib/google_drive/acl.rb
CHANGED
@@ -22,7 +22,7 @@ module GoogleDrive
|
|
22
22
|
@session = session
|
23
23
|
@file = file
|
24
24
|
api_permissions = @session.drive_service.list_permissions(
|
25
|
-
@file.id, fields: '*',
|
25
|
+
@file.id, fields: '*', supports_all_drives: true
|
26
26
|
)
|
27
27
|
@entries =
|
28
28
|
api_permissions.permissions.map { |perm| AclEntry.new(perm, self) }
|
@@ -73,7 +73,7 @@ module GoogleDrive
|
|
73
73
|
api_permission = @session.drive_service.create_permission(
|
74
74
|
@file.id,
|
75
75
|
entry.params,
|
76
|
-
{ fields: '*',
|
76
|
+
**{ fields: '*', supports_all_drives: true }.merge(options)
|
77
77
|
)
|
78
78
|
new_entry = AclEntry.new(api_permission, self)
|
79
79
|
@entries.push(new_entry)
|
@@ -86,7 +86,7 @@ module GoogleDrive
|
|
86
86
|
# spreadsheet.acl.delete(spreadsheet.acl[1])
|
87
87
|
def delete(entry)
|
88
88
|
@session.drive_service.delete_permission(
|
89
|
-
@file.id, entry.id,
|
89
|
+
@file.id, entry.id, supports_all_drives: true
|
90
90
|
)
|
91
91
|
@entries.delete(entry)
|
92
92
|
end
|
@@ -98,7 +98,7 @@ module GoogleDrive
|
|
98
98
|
entry.id,
|
99
99
|
{ role: entry.role },
|
100
100
|
fields: '*',
|
101
|
-
|
101
|
+
supports_all_drives: true
|
102
102
|
)
|
103
103
|
entry.api_permission = api_permission
|
104
104
|
entry
|
@@ -20,7 +20,7 @@ module GoogleDrive
|
|
20
20
|
# Adds the given GoogleDrive::File to the folder.
|
21
21
|
def add(file)
|
22
22
|
@session.drive_service.update_file(
|
23
|
-
file.id, add_parents: id, fields: '',
|
23
|
+
file.id, add_parents: id, fields: '', supports_all_drives: true
|
24
24
|
)
|
25
25
|
nil
|
26
26
|
end
|
@@ -28,7 +28,7 @@ module GoogleDrive
|
|
28
28
|
# Removes the given GoogleDrive::File from the folder.
|
29
29
|
def remove(file)
|
30
30
|
@session.drive_service.update_file(
|
31
|
-
file.id, remove_parents: id, fields: '',
|
31
|
+
file.id, remove_parents: id, fields: '', supports_all_drives: true
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
@@ -62,7 +62,7 @@ module GoogleDrive
|
|
62
62
|
}.merge(file_properties)
|
63
63
|
|
64
64
|
file = @session.drive_service.create_file(
|
65
|
-
file_metadata, fields: '*',
|
65
|
+
file_metadata, fields: '*', supports_all_drives: true
|
66
66
|
)
|
67
67
|
|
68
68
|
@session.wrap_api_file(file)
|
data/lib/google_drive/file.rb
CHANGED
@@ -39,7 +39,7 @@ module GoogleDrive
|
|
39
39
|
# Reloads file metadata such as title and acl.
|
40
40
|
def reload_metadata
|
41
41
|
@api_file = @session.drive_service.get_file(
|
42
|
-
id, fields: '*',
|
42
|
+
id, fields: '*', supports_all_drives: true
|
43
43
|
)
|
44
44
|
@acl = Acl.new(@session, self) if @acl
|
45
45
|
end
|
@@ -96,7 +96,7 @@ module GoogleDrive
|
|
96
96
|
def download_to_file(path, params = {})
|
97
97
|
@session.drive_service.get_file(
|
98
98
|
id,
|
99
|
-
{ download_dest: path,
|
99
|
+
{ download_dest: path, supports_all_drives: true }.merge(params)
|
100
100
|
)
|
101
101
|
end
|
102
102
|
|
@@ -115,7 +115,7 @@ module GoogleDrive
|
|
115
115
|
def download_to_io(io, params = {})
|
116
116
|
@session.drive_service.get_file(
|
117
117
|
id,
|
118
|
-
{ download_dest: io,
|
118
|
+
**{ download_dest: io, supports_all_drives: true }.merge(params)
|
119
119
|
)
|
120
120
|
end
|
121
121
|
|
@@ -184,8 +184,8 @@ module GoogleDrive
|
|
184
184
|
|
185
185
|
# Reads content from +io+ and updates the file with the content.
|
186
186
|
def update_from_io(io, params = {})
|
187
|
-
params = { upload_source: io,
|
188
|
-
@session.drive_service.update_file(id, nil, params)
|
187
|
+
params = { upload_source: io, supports_all_drives: true }.merge(params)
|
188
|
+
@session.drive_service.update_file(id, nil, **params)
|
189
189
|
nil
|
190
190
|
end
|
191
191
|
|
@@ -193,10 +193,10 @@ module GoogleDrive
|
|
193
193
|
# If +permanent+ is +true+, deletes the file permanently.
|
194
194
|
def delete(permanent = false)
|
195
195
|
if permanent
|
196
|
-
@session.drive_service.delete_file(id,
|
196
|
+
@session.drive_service.delete_file(id, supports_all_drives: true)
|
197
197
|
else
|
198
198
|
@session.drive_service.update_file(
|
199
|
-
id, { trashed: true },
|
199
|
+
id, { trashed: true }, supports_all_drives: true
|
200
200
|
)
|
201
201
|
end
|
202
202
|
nil
|
@@ -205,7 +205,7 @@ module GoogleDrive
|
|
205
205
|
# Renames title of the file.
|
206
206
|
def rename(title)
|
207
207
|
@session.drive_service.update_file(
|
208
|
-
id, { name: title },
|
208
|
+
id, { name: title }, supports_all_drives: true
|
209
209
|
)
|
210
210
|
nil
|
211
211
|
end
|
@@ -215,7 +215,7 @@ module GoogleDrive
|
|
215
215
|
# Creates copy of this file with the given title.
|
216
216
|
def copy(title, file_properties = {})
|
217
217
|
api_file = @session.drive_service.copy_file(
|
218
|
-
id, { name: title }.merge(file_properties), fields: '*',
|
218
|
+
id, { name: title }.merge(file_properties), fields: '*', supports_all_drives: true
|
219
219
|
)
|
220
220
|
@session.wrap_api_file(api_file)
|
221
221
|
end
|
data/lib/google_drive/session.rb
CHANGED
@@ -141,15 +141,13 @@ module GoogleDrive
|
|
141
141
|
config.client_id = options[:client_id]
|
142
142
|
config.client_secret = options[:client_secret]
|
143
143
|
end
|
144
|
-
if !config.client_id
|
145
|
-
config.client_id =
|
146
|
-
'452925651630-egr1f18o96acjjvphpbbd1qlsevkho1d.' \
|
147
|
-
'apps.googleusercontent.com'
|
148
|
-
config.client_secret = '1U3-Krii5x1oLPrwD5zgn-ry'
|
149
|
-
elsif !config.client_id || !config.client_secret
|
144
|
+
if !config.client_id || !config.client_secret
|
150
145
|
raise(
|
151
146
|
ArgumentError,
|
152
|
-
'client_id
|
147
|
+
'client_id or client_secret is missing in the config. Follow ' \
|
148
|
+
'https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md ' \
|
149
|
+
'to provide a valid config. google_drive library no longer provides ' \
|
150
|
+
'the default credential due to a limitation of Google API.'
|
153
151
|
)
|
154
152
|
end
|
155
153
|
|
@@ -255,7 +253,7 @@ module GoogleDrive
|
|
255
253
|
params = convert_params(params)
|
256
254
|
execute_paged!(
|
257
255
|
method: drive_service.method(:list_files),
|
258
|
-
parameters: { fields: '*',
|
256
|
+
parameters: { fields: '*', supports_all_drives: true, include_items_from_all_drives: true }.merge(params),
|
259
257
|
items_method_name: :files,
|
260
258
|
converter: proc { |af| wrap_api_file(af) },
|
261
259
|
&block
|
@@ -287,7 +285,7 @@ module GoogleDrive
|
|
287
285
|
# Returns an instance of GoogleDrive::File or its subclass
|
288
286
|
# (GoogleDrive::Spreadsheet, GoogleDrive::Collection).
|
289
287
|
def file_by_id(id)
|
290
|
-
api_file = drive_service.get_file(id, fields: '*',
|
288
|
+
api_file = drive_service.get_file(id, fields: '*', supports_all_drives: true)
|
291
289
|
wrap_api_file(api_file)
|
292
290
|
end
|
293
291
|
|
@@ -510,7 +508,7 @@ module GoogleDrive
|
|
510
508
|
}.merge(file_properties)
|
511
509
|
|
512
510
|
file = drive_service.create_file(
|
513
|
-
file_metadata, fields: '*',
|
511
|
+
file_metadata, fields: '*', supports_all_drives: true
|
514
512
|
)
|
515
513
|
|
516
514
|
wrap_api_file(file)
|
@@ -600,7 +598,7 @@ module GoogleDrive
|
|
600
598
|
end
|
601
599
|
|
602
600
|
elsif opts[:parameters] && opts[:parameters].key?(:page_token)
|
603
|
-
response = opts[:method].call(opts[:parameters])
|
601
|
+
response = opts[:method].call(**opts[:parameters])
|
604
602
|
items = response.__send__(opts[:items_method_name]).map do |item|
|
605
603
|
opts[:converter] ? opts[:converter].call(item) : item
|
606
604
|
end
|
@@ -656,7 +654,7 @@ module GoogleDrive
|
|
656
654
|
upload_source: source,
|
657
655
|
content_type: 'application/octet-stream',
|
658
656
|
fields: '*',
|
659
|
-
|
657
|
+
supports_all_drives: true
|
660
658
|
}
|
661
659
|
for k, v in params
|
662
660
|
unless %i[convert convert_mime_type parents].include?(k)
|
@@ -674,7 +672,7 @@ module GoogleDrive
|
|
674
672
|
end
|
675
673
|
file_metadata[:parents] = params[:parents] if params[:parents]
|
676
674
|
|
677
|
-
file = drive_service.create_file(file_metadata, api_params)
|
675
|
+
file = drive_service.create_file(file_metadata, **api_params)
|
678
676
|
wrap_api_file(file)
|
679
677
|
end
|
680
678
|
|
@@ -50,7 +50,7 @@ module GoogleDrive
|
|
50
50
|
# @api private
|
51
51
|
# A regexp which matches an invalid character in XML 1.0:
|
52
52
|
# https://en.wikipedia.org/wiki/Valid_characters_in_XML#XML_1.0
|
53
|
-
|
53
|
+
XML_INVALID_CHAR_REGEXP =
|
54
54
|
/[^\u0009\u000a\u000d\u0020-\ud7ff\ue000-\ufffd\u{10000}-\u{10ffff}]/
|
55
55
|
|
56
56
|
# @api private
|
@@ -73,13 +73,16 @@ module GoogleDrive
|
|
73
73
|
def worksheet_feed_entry
|
74
74
|
@worksheet_feed_entry ||= @session.request(:get, worksheet_feed_url).root
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Google::Apis::SheetsV4::SheetProperties object for this worksheet.
|
78
78
|
attr_reader :properties
|
79
79
|
|
80
80
|
# Title of the worksheet (shown as tab label in Web interface).
|
81
81
|
attr_reader :title
|
82
82
|
|
83
|
+
# Index of the worksheet (affects tab order in web interface).
|
84
|
+
attr_reader :index
|
85
|
+
|
83
86
|
# GoogleDrive::Spreadsheet which this worksheet belongs to.
|
84
87
|
attr_reader :spreadsheet
|
85
88
|
|
@@ -139,6 +142,24 @@ module GoogleDrive
|
|
139
142
|
format("%s\#gid=%s", spreadsheet.human_url, gid)
|
140
143
|
end
|
141
144
|
|
145
|
+
# Copy worksheet to specified spreadsheet.
|
146
|
+
# This method can take either instance of GoogleDrive::Spreadsheet or its id.
|
147
|
+
def copy_to(spreadsheet_or_id)
|
148
|
+
destination_spreadsheet_id =
|
149
|
+
spreadsheet_or_id.respond_to?(:id) ?
|
150
|
+
spreadsheet_or_id.id : spreadsheet_or_id
|
151
|
+
request = Google::Apis::SheetsV4::CopySheetToAnotherSpreadsheetRequest.new(
|
152
|
+
destination_spreadsheet_id: destination_spreadsheet_id,
|
153
|
+
)
|
154
|
+
@session.sheets_service.copy_spreadsheet(spreadsheet.id, sheet_id, request)
|
155
|
+
nil
|
156
|
+
end
|
157
|
+
|
158
|
+
# Copy worksheet to owner spreadsheet.
|
159
|
+
def duplicate
|
160
|
+
copy_to(spreadsheet)
|
161
|
+
end
|
162
|
+
|
142
163
|
# Returns content of the cell as String. Arguments must be either
|
143
164
|
# (row number, column number) or cell name. Top-left cell is [1, 1].
|
144
165
|
#
|
@@ -280,6 +301,13 @@ module GoogleDrive
|
|
280
301
|
@meta_modified = true
|
281
302
|
end
|
282
303
|
|
304
|
+
# Updates index of the worksheet.
|
305
|
+
# Note that update is not sent to the server until you call save().
|
306
|
+
def index=(index)
|
307
|
+
@index = index
|
308
|
+
@meta_modified = true
|
309
|
+
end
|
310
|
+
|
283
311
|
# @api private
|
284
312
|
def cells
|
285
313
|
reload_cells unless @cells
|
@@ -380,6 +408,7 @@ module GoogleDrive
|
|
380
408
|
properties: {
|
381
409
|
sheet_id: sheet_id,
|
382
410
|
title: title,
|
411
|
+
index: index,
|
383
412
|
grid_properties: {row_count: max_rows, column_count: max_cols},
|
384
413
|
},
|
385
414
|
fields: '*',
|
@@ -392,7 +421,7 @@ module GoogleDrive
|
|
392
421
|
@v4_requests = []
|
393
422
|
sent = true
|
394
423
|
end
|
395
|
-
|
424
|
+
|
396
425
|
@remote_title = @title
|
397
426
|
|
398
427
|
unless @modified.empty?
|
@@ -406,7 +435,7 @@ module GoogleDrive
|
|
406
435
|
min_modified_col = c if c < min_modified_col
|
407
436
|
max_modified_col = c if c > max_modified_col
|
408
437
|
end
|
409
|
-
|
438
|
+
|
410
439
|
# Uses update_spreadsheet_value instead batch_update_spreadsheet with
|
411
440
|
# update_cells. batch_update_spreadsheet has benefit that the request
|
412
441
|
# can be batched with other requests. But it has drawback that the
|
@@ -570,8 +599,8 @@ module GoogleDrive
|
|
570
599
|
# A1 to have red text that is bold and italic:
|
571
600
|
# worksheet.set_text_format(
|
572
601
|
# 1, 1, 1, 1,
|
573
|
-
# bold: true,
|
574
|
-
# italic: true,
|
602
|
+
# bold: true,
|
603
|
+
# italic: true,
|
575
604
|
# foreground_color: GoogleDrive::Worksheet::Colors::RED_BERRY)
|
576
605
|
#
|
577
606
|
# foreground_color is an instance of Google::Apis::SheetsV4::Color.
|
@@ -638,6 +667,7 @@ module GoogleDrive
|
|
638
667
|
def set_properties(properties)
|
639
668
|
@properties = properties
|
640
669
|
@title = @remote_title = properties.title
|
670
|
+
@index = properties.index
|
641
671
|
if properties.grid_properties.nil?
|
642
672
|
@max_rows = @max_cols = 0
|
643
673
|
else
|
@@ -673,7 +703,7 @@ module GoogleDrive
|
|
673
703
|
k = [r + 1, c + 1]
|
674
704
|
@cells[k] = cell_data.formatted_value || ''
|
675
705
|
@input_values[k] = extended_value_to_str(cell_data.user_entered_value)
|
676
|
-
@numeric_values[k] =
|
706
|
+
@numeric_values[k] =
|
677
707
|
cell_data.effective_value && cell_data.effective_value.number_value ?
|
678
708
|
cell_data.effective_value.number_value.to_f : nil
|
679
709
|
end
|
@@ -709,7 +739,7 @@ module GoogleDrive
|
|
709
739
|
end
|
710
740
|
|
711
741
|
def validate_cell_value(value)
|
712
|
-
if value =~
|
742
|
+
if value =~ XML_INVALID_CHAR_REGEXP
|
713
743
|
raise(
|
714
744
|
ArgumentError,
|
715
745
|
format('Contains invalid character %p for XML 1.0: %p', $&, value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_drive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Ichikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -31,25 +31,45 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: google-
|
34
|
+
name: google-apis-drive_v3
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.
|
39
|
+
version: 0.5.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 1.0.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.5.0
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.0.0
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: google-apis-sheets_v4
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 0.4.0
|
50
60
|
- - "<"
|
51
61
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.
|
62
|
+
version: 1.0.0
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.4.0
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.0.0
|
53
73
|
- !ruby/object:Gem::Dependency
|
54
74
|
name: googleauth
|
55
75
|
requirement: !ruby/object:Gem::Requirement
|
@@ -168,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
188
|
- !ruby/object:Gem::Version
|
169
189
|
version: '0'
|
170
190
|
requirements: []
|
171
|
-
|
172
|
-
rubygems_version: 2.6.14
|
191
|
+
rubygems_version: 3.2.3
|
173
192
|
signing_key:
|
174
193
|
specification_version: 4
|
175
194
|
summary: A library to read/write files/spreadsheets in Google Drive/Docs.
|