middleman-google_drive 0.3.7 → 0.3.8
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.rb +6 -7
- data/lib/middleman-google_drive/version.rb +1 -1
- data/test/google_drive_test.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3df0fbb18193aa6fe173b40a9ed814873cbb1582
|
4
|
+
data.tar.gz: f5c810323a5c049eb9e65536461aad67c97aa742
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f20fb3f52cb79986ff6a223daf4ce4a202ffc7a4cbc366fa04b26e0a83c87b14e098fc0cf55924326fbb6b486df3dc0cde9f8eabb150bd1322f52a79c15c9a45
|
7
|
+
data.tar.gz: aaacbd90befe43e65916c423ff4f799d7789cb5d986d763d1138417ec62e1bfe353a6aef377ff7b8ad7ba8ad1e2c49645a46c2d62a6c6c7569d51ebd3aacfb5a
|
data/lib/google_drive.rb
CHANGED
@@ -114,14 +114,13 @@ class GoogleDrive
|
|
114
114
|
if filename.nil?
|
115
115
|
# get a temporary file. The export is binary, so open the tempfile in
|
116
116
|
# write binary mode
|
117
|
-
Tempfile.create(
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
117
|
+
fp = Tempfile.create(
|
118
|
+
['googledoc', ".#{type}"], binmode: mime_for(type.to_s).binary?)
|
119
|
+
filename = fp.path
|
120
|
+
fp.write(contents)
|
121
|
+
fp.close
|
123
122
|
else
|
124
|
-
open(filename, 'wb') { |
|
123
|
+
open(filename, 'wb') { |f| f.write(contents) }
|
125
124
|
end
|
126
125
|
filename
|
127
126
|
end
|
data/test/google_drive_test.rb
CHANGED
@@ -30,14 +30,14 @@ class TestGoogleDrive < MiniTest::Test
|
|
30
30
|
def test_export_to_file
|
31
31
|
filename = @drive.export_to_file(@doc_file_id, :html)
|
32
32
|
assert_equal '.html', File.extname(filename)
|
33
|
-
assert File.exist?(filename)
|
33
|
+
assert File.exist?(filename), "Export file is missing #{filename}"
|
34
34
|
assert_not_nil File.read(filename) =~ /^<html>/
|
35
35
|
File.unlink(filename)
|
36
36
|
|
37
37
|
[@new_sheet_file_id, @old_sheet_file_id].each do |file_id|
|
38
38
|
filename = @drive.export_to_file(file_id, :xlsx)
|
39
39
|
assert_equal '.xlsx', File.extname(filename)
|
40
|
-
assert File.exist?(filename)
|
40
|
+
assert File.exist?(filename), "Export file is missing #{filename}"
|
41
41
|
File.unlink(filename)
|
42
42
|
end
|
43
43
|
end
|
@@ -45,9 +45,9 @@ class TestGoogleDrive < MiniTest::Test
|
|
45
45
|
def test_prepare_spreadsheet
|
46
46
|
[@old_sheet_file_id, @new_sheet_file_id].each do |file_id|
|
47
47
|
#filename = "/tmp/google_drive_#{file_id}.xlsx"
|
48
|
-
filename = @drive.export_to_file(file_id, :xlsx
|
48
|
+
filename = @drive.export_to_file(file_id, :xlsx)
|
49
49
|
assert_equal '.xlsx', File.extname(filename)
|
50
|
-
assert File.exist?(filename)
|
50
|
+
assert File.exist?(filename), "Export file is missing #{filename}"
|
51
51
|
data = @drive.prepare_spreadsheet(filename)
|
52
52
|
assert_has_key data, 'microcopy'
|
53
53
|
assert_has_key data['microcopy'], 'help'
|