middleman-google_drive 0.3.1 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1444f49e8dd2e69181f1f42e01a783bd9226337
4
- data.tar.gz: 5b43bfe69f682548aec934b385c2c5b1d1e4ff1c
3
+ metadata.gz: df94f7285904bfdc980f5c9b41f462419510d229
4
+ data.tar.gz: d21820a19625117878fac1a193f31886405cc2b1
5
5
  SHA512:
6
- metadata.gz: 5de759a9721c14e20fec1fc4350ad79fac369d1c74cf783eb6c5875f7b607895f2723cadf4ccc25b2614db79813f815f3f98e497350cb2aba9a40f9a0b73ec4c
7
- data.tar.gz: e71caa750dc0b8b3df218fbed18f4784258a427e29711bb390be000d20c6a26639ea4629639e5a2c776e7bee0fd4e01d40f37d0b30ab92b7115abe91f0a5716f
6
+ metadata.gz: f0491070a92dac3f1b78bcf9c344505ff85d00e06ced6c3f8483fd549fd0d4793f30198ff327073e8fb7590a06f4a9506fb502f26b707b6e3889f36f1ce425f2
7
+ data.tar.gz: 335652541d98d74f3ac22138bbdc2c618c0f11977f22e93fbfd83d33b3f32843cba2aff811ea8c496bb8e137e1cfd9ab5d988ec66d17eaa6a43d07662f622a75
data/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ inherit_from: .rubocop_todo.yml
2
+ AllCops:
3
+ Include:
4
+ - '**/Rakefile'
5
+ - '**/Capfile'
6
+ Exclude:
7
+ - 'db/migrate/**/*'
8
+ - 'vendor/**/*'
9
+ RunRailsCops: true
10
+
11
+ Style/HashSyntax:
12
+ EnforcedStyle: hash_rockets
13
+
14
+ Style/LineLength:
15
+ Max: 100
16
+
17
+ Style/NumericLiterals:
18
+ Enabled: false
19
+
20
+ Style/ClassAndModuleChildren:
21
+ Enabled: false
22
+
23
+ Style/SignalException:
24
+ EnforcedStyle: only_raise
25
+
26
+ Style/ClassLength:
27
+ Enabled: false
28
+
29
+ Style/MethodLength:
30
+ Enabled: false
@@ -27,14 +27,39 @@ module Middleman
27
27
  def handle_option(option, type)
28
28
  if option.is_a? Hash
29
29
  option.each do |name, key|
30
- @app.data.store(name, load_doc(key.to_s, type))
30
+ store_data(name, load_doc(key.to_s, type))
31
31
  end
32
32
  elsif type == 'spreadsheet'
33
33
  load_doc(option.to_s, type).each do |name, sheet|
34
- @app.data.store(name, sheet)
34
+ store_data(name, sheet)
35
35
  end
36
36
  else
37
- @app.data.store('doc', load_doc(option.to_s, type))
37
+ store_data('doc', load_doc(option.to_s, type))
38
+ end
39
+ rescue Faraday::ConnectionFailed => exc
40
+ if @drive.server?
41
+ puts "== FAILED to load Google Doc \"#{exc.message}\""
42
+ else
43
+ puts <<-MSG
44
+ == Could not connect to Google Drive. Local data will be used.
45
+ MSG
46
+ end
47
+ rescue GoogleDrive::GoogleDriveError => exc
48
+ if @drive.server?
49
+ puts "== FAILED to load Google Doc \"#{exc.message}\""
50
+ else
51
+ puts <<-MSG
52
+
53
+ Could not load the Google Doc.
54
+
55
+ Things to check:
56
+ - Make sure the Google Doc key is correct
57
+ - Make sure you're logging in with the correct account
58
+ - Make sure you have access to the document
59
+
60
+ Google said "#{exc.message}." It might be a lie.
61
+ MSG
62
+ @drive.clear_auth
38
63
  end
39
64
  end
40
65
 
@@ -55,23 +80,14 @@ module Middleman
55
80
  == #{doc['alternateLink']}
56
81
  MSG
57
82
  data
58
- rescue ::GoogleDrive::GoogleDriveError => exc
59
- if @drive.server?
60
- puts "== FAILED to load Google Doc \"#{exc.message}\""
61
- else
62
- puts <<-MSG
63
-
64
- Could not load the Google Doc.
65
-
66
- Things to check:
67
- - Make sure the Google Doc key is correct
68
- - Make sure you're logging in with the correct account
69
- - Make sure you have access to the document
83
+ end
70
84
 
71
- Google said "#{exc.message}." It might be a lie.
72
- MSG
73
- @drive.clear_auth
85
+ def store_data(key, data)
86
+ backup_file = File.join(@app.root, @app.data_dir, "#{key}.json")
87
+ File.open(backup_file, 'w') do |f|
88
+ f.write(JSON.pretty_generate(data))
74
89
  end
90
+ @app.data.store(key, data)
75
91
  end
76
92
  end
77
93
  end
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module GoogleDrive
3
- VERSION = '0.3.1'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-google_drive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mark
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-09 00:00:00.000000000 Z
12
+ date: 2015-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: middleman-core
@@ -132,6 +132,7 @@ extensions: []
132
132
  extra_rdoc_files: []
133
133
  files:
134
134
  - ".gitignore"
135
+ - ".rubocop.yml"
135
136
  - Gemfile
136
137
  - LICENSE.txt
137
138
  - README.md