google_drive 2.1.10 → 2.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google_drive/acl.rb +1 -0
- data/lib/google_drive/collection.rb +27 -7
- data/lib/google_drive/file.rb +2 -2
- data/lib/google_drive/session.rb +28 -5
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab18bbc182b3ffa7d363b03b7969457b311158af
|
4
|
+
data.tar.gz: 3a1803545d767797bd8062b1c8bf7010f628be87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5066596c8f5720484ba23f18690164cbb796d4e4e7748a1b1f16f1fcf6240b47bcff1580101c1d9f69e4f00f05f683bbb74335f3a473d407c65a3b487d6c1702
|
7
|
+
data.tar.gz: ef1b363d2a00c794d2a00a2837a178dc3215886a3b9fbc4ddcde6c6f854fde11b7e38cf6ad78a0c1490e06b53cbc24cb5f975bc4b3f562bb0f3a0c1fd817cbfc
|
data/lib/google_drive/acl.rb
CHANGED
@@ -32,22 +32,42 @@ module GoogleDrive
|
|
32
32
|
)
|
33
33
|
end
|
34
34
|
|
35
|
-
# Creates a sub-folder with given title
|
36
|
-
# object.
|
37
|
-
def create_subcollection(title)
|
35
|
+
# Creates a sub-folder with given title in this folder.
|
36
|
+
# Returns GoogleDrive::Collection object.
|
37
|
+
def create_subcollection(title, file_properties = {})
|
38
|
+
create_file(title, file_properties.merge(mime_type: 'application/vnd.google-apps.folder'))
|
39
|
+
end
|
40
|
+
|
41
|
+
alias create_subfolder create_subcollection
|
42
|
+
|
43
|
+
# Creates a spreadsheet with given title in this folder.
|
44
|
+
# Returns GoogleDrive::Spreadsheet object.
|
45
|
+
def create_spreadsheet(title, file_properties = {})
|
46
|
+
create_file(title, file_properties.merge(mime_type: 'application/vnd.google-apps.spreadsheet'))
|
47
|
+
end
|
48
|
+
|
49
|
+
# Creates a file with given title and properties in this folder.
|
50
|
+
# Returns objects with the following types:
|
51
|
+
# GoogleDrive::Spreadsheet, GoogleDrive::File, GoogleDrive::Collection
|
52
|
+
#
|
53
|
+
# You can pass a MIME Type using the file_properties-function parameter,
|
54
|
+
# for example: create_file('Document Title', mime_type: 'application/vnd.google-apps.document')
|
55
|
+
#
|
56
|
+
# A list of available Drive MIME Types can be found here:
|
57
|
+
# https://developers.google.com/drive/v3/web/mime-types
|
58
|
+
def create_file(title, file_properties = {})
|
38
59
|
file_metadata = {
|
39
60
|
name: title,
|
40
|
-
mime_type: 'application/vnd.google-apps.folder',
|
41
61
|
parents: [id]
|
42
|
-
}
|
62
|
+
}.merge(file_properties)
|
63
|
+
|
43
64
|
file = @session.drive.create_file(
|
44
65
|
file_metadata, fields: '*', supports_team_drives: true
|
45
66
|
)
|
67
|
+
|
46
68
|
@session.wrap_api_file(file)
|
47
69
|
end
|
48
70
|
|
49
|
-
alias create_subfolder create_subcollection
|
50
|
-
|
51
71
|
# Returns true if this is a root folder.
|
52
72
|
def root?
|
53
73
|
!api_file.parents || api_file.parents.empty?
|
data/lib/google_drive/file.rb
CHANGED
@@ -213,9 +213,9 @@ module GoogleDrive
|
|
213
213
|
alias title= rename
|
214
214
|
|
215
215
|
# Creates copy of this file with the given title.
|
216
|
-
def copy(title)
|
216
|
+
def copy(title, file_properties = {})
|
217
217
|
api_file = @session.drive.copy_file(
|
218
|
-
id, { name: title }, fields: '*', supports_team_drives: true
|
218
|
+
id, { name: title }.merge(file_properties), fields: '*', supports_team_drives: true
|
219
219
|
)
|
220
220
|
@session.wrap_api_file(api_file)
|
221
221
|
end
|
data/lib/google_drive/session.rb
CHANGED
@@ -418,18 +418,41 @@ module GoogleDrive
|
|
418
418
|
|
419
419
|
alias folder_by_url collection_by_url
|
420
420
|
|
421
|
-
# Creates
|
421
|
+
# Creates a top-level folder with given title. Returns GoogleDrive::Collection
|
422
|
+
# object.
|
423
|
+
def create_collection(title, file_properties = {})
|
424
|
+
create_file(title, file_properties.merge(mime_type: 'application/vnd.google-apps.folder'))
|
425
|
+
end
|
426
|
+
|
427
|
+
alias create_folder create_collection
|
428
|
+
|
429
|
+
# Creates a spreadsheet with given title. Returns GoogleDrive::Spreadsheet
|
430
|
+
# object.
|
422
431
|
#
|
423
432
|
# e.g.
|
424
433
|
# session.create_spreadsheet("My new sheet")
|
425
|
-
def create_spreadsheet(title = 'Untitled')
|
434
|
+
def create_spreadsheet(title = 'Untitled', file_properties = {})
|
435
|
+
create_file(title, file_properties.merge(mime_type: 'application/vnd.google-apps.spreadsheet'))
|
436
|
+
end
|
437
|
+
|
438
|
+
# Creates a file with given title and properties. Returns objects
|
439
|
+
# with the following types: GoogleDrive::Spreadsheet, GoogleDrive::File,
|
440
|
+
# GoogleDrive::Collection
|
441
|
+
#
|
442
|
+
# You can pass a MIME Type using the file_properties-function parameter,
|
443
|
+
# for example: create_file('Document Title', mime_type: 'application/vnd.google-apps.document')
|
444
|
+
#
|
445
|
+
# A list of available Drive MIME Types can be found here:
|
446
|
+
# https://developers.google.com/drive/v3/web/mime-types
|
447
|
+
def create_file(title, file_properties = {})
|
426
448
|
file_metadata = {
|
427
|
-
name:
|
428
|
-
|
429
|
-
|
449
|
+
name: title,
|
450
|
+
}.merge(file_properties)
|
451
|
+
|
430
452
|
file = drive.create_file(
|
431
453
|
file_metadata, fields: '*', supports_team_drives: true
|
432
454
|
)
|
455
|
+
|
433
456
|
wrap_api_file(file)
|
434
457
|
end
|
435
458
|
|
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: 2.1.
|
4
|
+
version: 2.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hiroshi Ichikawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 0.11.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.22.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 0.11.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 0.
|
52
|
+
version: 0.22.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: googleauth
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|