google_driver 0.0.2 → 0.0.3
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 +8 -8
- data/lib/google_driver/document.rb +26 -18
- data/lib/google_driver/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YTJkMmVkZjRlZjQzOGE1YzJkYjFkNjMxMDVkOWEzYzIwNGY4ZTliMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2Y3MWE4MTVlNmMyYWE0ZDZhMDhlZjgyNjE4ZThjMmFjZmY0ZmU5YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmZhNzZhNjY5ODdlZWVlOTAxNjM0MmE1NjNiZTkyNjBhMjU3MjM0NzdhYzNm
|
10
|
+
MzdhNjA2NDkwZTBmNTYwZTRhYWZlNzVmNjAzMDliMDFjMzg4MDU0MDQyNTVk
|
11
|
+
YWQ1ZjM2ZTUyNDg1OGM2ODM5MGQzZjJmOWViMmQ0MjRjM2MwYzE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjEyZWFhOWNmNDFmNmVjYTBhZTE5ODllZDhjYTJlMzMwYjMyYjVkYzMyOGM5
|
14
|
+
YjYxYjExMzNkODYzMjJmNTBjYTk0ZjQ4M2VkZmZlMjgxZjc2ZmZhNjBhZmYz
|
15
|
+
ZTliNzBjNGQ3NjcyYWE2YzUwYWNhY2Q2NzdkMWYzZjAyNDUyYzI=
|
@@ -1,38 +1,46 @@
|
|
1
1
|
module GoogleDriver
|
2
2
|
class Document
|
3
|
-
attr_accessor :exports, :response
|
3
|
+
attr_accessor :exports, :response, :file_id
|
4
4
|
|
5
5
|
def initialize(response, api)
|
6
|
+
@api = api
|
7
|
+
@drive = get_drive_api
|
8
|
+
|
6
9
|
@response = response
|
10
|
+
@file_id = response.data.to_hash['id']
|
7
11
|
@exports = response.data.to_hash['exportLinks']
|
8
|
-
@api = api
|
9
12
|
end
|
10
13
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
def
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
# refresh document information
|
15
|
+
# used when we don't immediate get exportLinks in the response
|
16
|
+
def update
|
17
|
+
response = @api.client.execute(
|
18
|
+
api_method: @drive.files.get,
|
19
|
+
:parameters => { 'fileId' => @file_id }
|
20
|
+
)
|
21
|
+
@response = response
|
22
|
+
@file_id = response.data.to_hash['id']
|
23
|
+
@exports = response.data.to_hash['exportLinks']
|
19
24
|
end
|
20
25
|
|
21
26
|
def list
|
22
27
|
@exports.keys
|
23
28
|
end
|
24
29
|
|
30
|
+
def get_drive_api
|
31
|
+
@drive = @api.client.discovered_api('drive', 'v2')
|
32
|
+
end
|
33
|
+
|
25
34
|
def download(type)
|
26
35
|
loops = 0
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
36
|
+
while loops < 5 do
|
37
|
+
self.update()
|
38
|
+
if @exports and @exports.keys.include?(type)
|
39
|
+
return @api.client.execute(uri: @exports[type]).body
|
40
|
+
else
|
41
|
+
loops+=1
|
42
|
+
sleep(5*loops) # Wait an increasing amount of time between loops
|
32
43
|
end
|
33
|
-
loops+=1
|
34
|
-
sleep(5)
|
35
|
-
self.download(type)
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_driver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seth Wolfwood
|
@@ -124,3 +124,4 @@ test_files:
|
|
124
124
|
- spec/google_driver_api_spec.rb
|
125
125
|
- spec/google_driver_document_spec.rb
|
126
126
|
- spec/spec_helper.rb
|
127
|
+
has_rdoc:
|