google_drive 2.1.11 → 2.1.12
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/lib/google_drive/api_client_fetcher.rb +13 -1
- data/lib/google_drive/session.rb +59 -12
- data/lib/google_drive/spreadsheet.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e8bc240087cb507a378a4ff02886cad3e2b7ed
|
4
|
+
data.tar.gz: 07a8f238c8cc89072248fd6db3b2ca0b7ab18d37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55ff686961a787c15738c8177f6aada5b4df2851019116e120310e2523684fed2d389b9658ad7f7d832ce125bcaf608467e7f7244a76109c0c649491d14ac773
|
7
|
+
data.tar.gz: b89df0376ae01ef915ae88193059a809eccbfa410f2a84a0e30c35415f08789f4021567d8da52a85e8f7cddd53319b084ddbc161deeb6ba19f0a0dd072e3cfec
|
@@ -17,7 +17,7 @@ module GoogleDrive
|
|
17
17
|
attr_reader(:code, :body)
|
18
18
|
end
|
19
19
|
|
20
|
-
def initialize(authorization)
|
20
|
+
def initialize(authorization, client_options, request_options)
|
21
21
|
@drive = Google::Apis::DriveV3::DriveService.new
|
22
22
|
@drive.authorization = authorization
|
23
23
|
|
@@ -28,6 +28,18 @@ module GoogleDrive
|
|
28
28
|
@drive.client_options.open_timeout_sec = t
|
29
29
|
@drive.client_options.read_timeout_sec = t
|
30
30
|
@drive.client_options.send_timeout_sec = t
|
31
|
+
|
32
|
+
if client_options
|
33
|
+
@drive.client_options.members.each do |name|
|
34
|
+
if !client_options[name].nil?
|
35
|
+
@drive.client_options[name] = client_options[name]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
if request_options
|
41
|
+
@drive.request_options = @drive.request_options.merge(request_options)
|
42
|
+
end
|
31
43
|
end
|
32
44
|
|
33
45
|
attr_reader(:drive)
|
data/lib/google_drive/session.rb
CHANGED
@@ -50,13 +50,19 @@ module GoogleDrive
|
|
50
50
|
# See
|
51
51
|
# https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md
|
52
52
|
# for a usage example.
|
53
|
-
|
54
|
-
|
53
|
+
#
|
54
|
+
# See from_config documentation for an explanation of client_options and
|
55
|
+
# request_options.
|
56
|
+
def self.from_credentials(credentials, client_options = nil, request_options = nil)
|
57
|
+
Session.new(credentials, nil, client_options, request_options)
|
55
58
|
end
|
56
59
|
|
57
60
|
# Constructs a GoogleDrive::Session object from OAuth2 access token string.
|
58
|
-
|
59
|
-
|
61
|
+
#
|
62
|
+
# See from_config documentation for an explanation of client_options and
|
63
|
+
# request_options.
|
64
|
+
def self.from_access_token(access_token, client_options = nil, request_options = nil)
|
65
|
+
Session.new(access_token, nil, client_options, request_options)
|
60
66
|
end
|
61
67
|
|
62
68
|
# Constructs a GoogleDrive::Session object from a service account key JSON.
|
@@ -67,23 +73,28 @@ module GoogleDrive
|
|
67
73
|
# See
|
68
74
|
# https://github.com/gimite/google-drive-ruby/blob/master/doc/authorization.md
|
69
75
|
# for a usage example.
|
76
|
+
#
|
77
|
+
# As with from_config, you can configure Google API client behavior with
|
78
|
+
# +client_options+ and +request_options+. Unlike in from_config, these
|
79
|
+
# are passed as positional arguments.
|
70
80
|
def self.from_service_account_key(
|
71
|
-
json_key_path_or_io, scope = DEFAULT_SCOPE
|
81
|
+
json_key_path_or_io, scope = DEFAULT_SCOPE, client_options = nil,
|
82
|
+
request_options = nil
|
72
83
|
)
|
73
84
|
if json_key_path_or_io.is_a?(String)
|
74
85
|
open(json_key_path_or_io) do |f|
|
75
|
-
from_service_account_key(f, scope)
|
86
|
+
from_service_account_key(f, scope, client_options, request_options)
|
76
87
|
end
|
77
88
|
else
|
78
89
|
credentials = Google::Auth::ServiceAccountCredentials.make_creds(
|
79
90
|
json_key_io: json_key_path_or_io, scope: scope
|
80
91
|
)
|
81
|
-
Session.new(credentials)
|
92
|
+
Session.new(credentials, nil, client_options, request_options)
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
85
96
|
# Returns GoogleDrive::Session constructed from a config JSON file at
|
86
|
-
# +config+.
|
97
|
+
# +config+, potenially modified with +options+.
|
87
98
|
#
|
88
99
|
# +config+ is the path to the config file.
|
89
100
|
#
|
@@ -102,13 +113,24 @@ module GoogleDrive
|
|
102
113
|
# scope
|
103
114
|
# scope=
|
104
115
|
# save
|
116
|
+
#
|
117
|
+
# +options+ is a hash which may contain the following keys:
|
118
|
+
# client_secret: if present, this will overwrite config.client_secret
|
119
|
+
# client_id: if present, this will overwrite config.client_id
|
120
|
+
# client_options: a hash or ::Google::Apis::ClientOptions. See
|
121
|
+
# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/ClientOptions
|
122
|
+
# for an explanation of legal sub-fields.
|
123
|
+
# request_options: a hash or ::Google::Apis::RequestOptions. See
|
124
|
+
# https://www.rubydoc.info/github/google/google-api-ruby-client/Google/Apis/RequestOptions
|
125
|
+
# for an explanation of legal sub-fields.
|
105
126
|
def self.from_config(config, options = {})
|
106
127
|
if config.is_a?(String)
|
107
128
|
config_path = config
|
108
129
|
config = Config.new(config_path)
|
109
130
|
if config.type == 'service_account'
|
110
131
|
return from_service_account_key(
|
111
|
-
config_path, options[:scope] || DEFAULT_SCOPE
|
132
|
+
config_path, options[:scope] || DEFAULT_SCOPE, options[:client_options],
|
133
|
+
options[:request_options]
|
112
134
|
)
|
113
135
|
end
|
114
136
|
end
|
@@ -153,10 +175,15 @@ module GoogleDrive
|
|
153
175
|
|
154
176
|
config.save
|
155
177
|
|
156
|
-
Session.new(
|
178
|
+
Session.new(
|
179
|
+
credentials, nil, options[:client_options], options[:request_options]
|
180
|
+
)
|
157
181
|
end
|
158
182
|
|
159
|
-
def initialize(
|
183
|
+
def initialize(
|
184
|
+
credentials_or_access_token, proxy = nil, client_options = nil,
|
185
|
+
request_options = nil
|
186
|
+
)
|
160
187
|
if proxy
|
161
188
|
raise(
|
162
189
|
ArgumentError,
|
@@ -179,7 +206,9 @@ module GoogleDrive
|
|
179
206
|
else
|
180
207
|
credentials = credentials_or_access_token
|
181
208
|
end
|
182
|
-
@fetcher = ApiClientFetcher.new(
|
209
|
+
@fetcher = ApiClientFetcher.new(
|
210
|
+
credentials, client_options, request_options
|
211
|
+
)
|
183
212
|
else
|
184
213
|
@fetcher = nil
|
185
214
|
end
|
@@ -418,6 +447,24 @@ module GoogleDrive
|
|
418
447
|
|
419
448
|
alias folder_by_url collection_by_url
|
420
449
|
|
450
|
+
# Returns GoogleDrive::Collection with given +id+.
|
451
|
+
#
|
452
|
+
# e.g.
|
453
|
+
# # https://drive.google.com/drive/folders/1rPPuzAew4tO3ORc88Vz1JscPCcnrX7-J
|
454
|
+
# session.collection_by_id("1rPPuzAew4tO3ORc88Vz1JscPCcnrX7-J")
|
455
|
+
def collection_by_id(id)
|
456
|
+
file = file_by_id(id)
|
457
|
+
unless file.is_a?(Collection)
|
458
|
+
raise(
|
459
|
+
GoogleDrive::Error,
|
460
|
+
format('The file with the ID is not a folder: %s', id)
|
461
|
+
)
|
462
|
+
end
|
463
|
+
file
|
464
|
+
end
|
465
|
+
|
466
|
+
alias folder_by_id collection_by_id
|
467
|
+
|
421
468
|
# Creates a top-level folder with given title. Returns GoogleDrive::Collection
|
422
469
|
# object.
|
423
470
|
def create_collection(title, file_properties = {})
|
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.12
|
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-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|