google-drive 0.1.6b
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 +7 -0
- data/.bundle/binstubs/autospec +16 -0
- data/.bundle/binstubs/bundler +16 -0
- data/.bundle/binstubs/cucumber +16 -0
- data/.bundle/binstubs/erubis +16 -0
- data/.bundle/binstubs/htmldiff +16 -0
- data/.bundle/binstubs/ldiff +16 -0
- data/.bundle/binstubs/middleman +16 -0
- data/.bundle/binstubs/nokogiri +16 -0
- data/.bundle/binstubs/oauth +16 -0
- data/.bundle/binstubs/rackup +16 -0
- data/.bundle/binstubs/rake +16 -0
- data/.bundle/binstubs/rdoc +16 -0
- data/.bundle/binstubs/ri +16 -0
- data/.bundle/binstubs/rspec +16 -0
- data/.bundle/binstubs/thor +16 -0
- data/.bundle/binstubs/tilt +16 -0
- data/.bundle/binstubs/yard +16 -0
- data/.bundle/binstubs/yardoc +16 -0
- data/.bundle/binstubs/yri +16 -0
- data/Gemfile +19 -0
- data/README.md +2 -0
- data/Rakefile +22 -0
- data/features/support/env.rb +4 -0
- data/google-drive.gemspec +29 -0
- data/lib/gdrive/extension.rb +64 -0
- data/lib/gdrive/helpers.rb +63 -0
- data/lib/gdrive/version.rb +5 -0
- data/lib/google-drive.rb +10 -0
- data/lib/google-drive/extension.rb +64 -0
- data/lib/google-drive/helpers.rb +63 -0
- data/lib/google-drive/version.rb +5 -0
- data/lib/middleman_extension.rb +1 -0
- metadata +151 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8e4939479bc386bf41be0d5d0a31ffb5b401be29
|
|
4
|
+
data.tar.gz: 74305d210f8af97127caa907177395e2523e993e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0cec6bfedf72cd3547b23db1aaeec9c1e1d66303ecb15f979b54c220075ee0bdbe5ee04b2bda49dce08285d9ed156a5a29da4f3db5f2874effe8e741c996278e
|
|
7
|
+
data.tar.gz: 61668790cfda53efa3d4f35b977e8d3368cd24c2a801e6d2bba4a1b8309fa1b2830f5a438941c65733c3110779e0cc12341a32bac07aad1cdda26698532e4ecb
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'autospec' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rspec-core', 'autospec')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'bundler' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('bundler', 'bundler')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'cucumber' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('cucumber', 'cucumber')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'erubis' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('erubis', 'erubis')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('diff-lcs', 'htmldiff')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'ldiff' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('diff-lcs', 'ldiff')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'middleman' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('middleman-core', 'middleman')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'nokogiri' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('nokogiri', 'nokogiri')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'oauth' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('oauth', 'oauth')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rackup' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rack', 'rackup')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rdoc' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rdoc', 'rdoc')
|
data/.bundle/binstubs/ri
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'ri' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rdoc', 'ri')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'thor' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('thor', 'thor')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'tilt' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('tilt', 'tilt')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'yard' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('yard', 'yard')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'yardoc' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('yard', 'yardoc')
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
#
|
|
3
|
+
# This file was generated by Bundler.
|
|
4
|
+
#
|
|
5
|
+
# The application 'yri' is installed as part of a gem, and
|
|
6
|
+
# this file is here to facilitate running it.
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
require 'pathname'
|
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../../Gemfile",
|
|
11
|
+
Pathname.new(__FILE__).realpath)
|
|
12
|
+
|
|
13
|
+
require 'rubygems'
|
|
14
|
+
require 'bundler/setup'
|
|
15
|
+
|
|
16
|
+
load Gem.bin_path('yard', 'yri')
|
data/Gemfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# If you have OpenSSL installed, we recommend updating
|
|
2
|
+
# the following line to use "https"
|
|
3
|
+
source 'http://rubygems.org'
|
|
4
|
+
|
|
5
|
+
# Specify your gem's dependencies in gdrive.gemspec
|
|
6
|
+
gemspec
|
|
7
|
+
|
|
8
|
+
group :development do
|
|
9
|
+
gem 'rake'
|
|
10
|
+
gem 'rdoc'
|
|
11
|
+
gem 'yard'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
group :test do
|
|
15
|
+
gem 'cucumber'
|
|
16
|
+
gem 'fivemat'
|
|
17
|
+
gem 'aruba'
|
|
18
|
+
gem 'rspec'
|
|
19
|
+
end
|
data/README.md
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require 'cucumber/rake/task'
|
|
5
|
+
|
|
6
|
+
Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t|
|
|
7
|
+
ENV["TEST"] = "true"
|
|
8
|
+
|
|
9
|
+
exempt_tags = ""
|
|
10
|
+
exempt_tags << "--tags ~@nojava" if RUBY_PLATFORM == "java"
|
|
11
|
+
|
|
12
|
+
t.cucumber_opts = "--color --tags ~@wip #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
require 'rake/clean'
|
|
16
|
+
|
|
17
|
+
task :test => ["cucumber"]
|
|
18
|
+
|
|
19
|
+
# desc "Build HTML documentation"
|
|
20
|
+
# task :doc do
|
|
21
|
+
# sh 'bundle exec yard'
|
|
22
|
+
# end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
require "google-drive/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |s|
|
|
6
|
+
s.name = "google-drive"
|
|
7
|
+
s.version = Middleman::GoogleDriveMiddleman::VERSION
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.authors = ["ALDO Digital Lab"]
|
|
10
|
+
# s.email = ["email@example.com"]
|
|
11
|
+
s.homepage = "http://github.com/aldogroup/Google-Drive"
|
|
12
|
+
s.summary = %q{Google Drive for Aldo Group}
|
|
13
|
+
# s.description = %q{A longer description of your extension}
|
|
14
|
+
|
|
15
|
+
s.files = `git ls-files`.split("\n")
|
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
|
|
20
|
+
# The version of middleman-core your extension depends on
|
|
21
|
+
s.add_dependency("middleman-core", [">= 3.2.2"])
|
|
22
|
+
|
|
23
|
+
# Additional dependencies
|
|
24
|
+
s.add_dependency "rack"
|
|
25
|
+
s.add_dependency 'multipart-post', '>= 1.2', '< 3'
|
|
26
|
+
s.add_dependency("oauth2", [">= 0.5.0"])
|
|
27
|
+
s.add_dependency("google_drive", [">= 0.3.8"])
|
|
28
|
+
# s.add_runtime_dependency("gem-name", "gem-version")
|
|
29
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'rack'
|
|
3
|
+
|
|
4
|
+
module Middleman
|
|
5
|
+
class GoogleDriveMiddlemanExtension < Extension
|
|
6
|
+
# option :offline, 'false', 'Load the data locally if set to true'
|
|
7
|
+
|
|
8
|
+
def initialize(app, options_hash={}, &block)
|
|
9
|
+
# Call super to build options from the options_hash
|
|
10
|
+
super
|
|
11
|
+
unless File.directory?('data/cache')
|
|
12
|
+
FileUtils.mkdir 'data/cache'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# app.extend google-driveConnector
|
|
16
|
+
# end
|
|
17
|
+
|
|
18
|
+
app.helpers do
|
|
19
|
+
puts '== Google Drive Loaded'
|
|
20
|
+
def session
|
|
21
|
+
# Create Google Authentication Session with Access Token
|
|
22
|
+
settings = YAML.load(File.open('data/credentials.yml'))
|
|
23
|
+
client = OAuth2::Client.new(
|
|
24
|
+
settings['google']['client_id'], settings['google']['client_secret'],
|
|
25
|
+
site: 'https://accounts.google.com',
|
|
26
|
+
token_url: '/o/oauth2/token',
|
|
27
|
+
authorize_url: '/o/oauth2/auth'
|
|
28
|
+
)
|
|
29
|
+
auth_token = OAuth2::AccessToken.from_hash( client, { refresh_token: settings['google']['refresh_token'] })
|
|
30
|
+
auth_token = auth_token.refresh!
|
|
31
|
+
gdauth = GoogleDrive.login_with_oauth(auth_token)
|
|
32
|
+
return session = gdauth.collection_by_title(banner).subcollection_by_title(season).subcollection_by_title(campaign)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def gdrive(locale, page)
|
|
36
|
+
get_worksheet_data(locale, page)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_worksheet_data(locale, page)
|
|
40
|
+
locale = locale.lstrip.rstrip
|
|
41
|
+
page = page.lstrip.rstrip
|
|
42
|
+
cache_file = ::File.join('data/cache', "#{locale}_#{page}.yml")
|
|
43
|
+
time = Time.now
|
|
44
|
+
if offline
|
|
45
|
+
puts "== You are currently viewing #{page} using the offline mode".green
|
|
46
|
+
return page_data_request = YAML.load(::File.read(cache_file))
|
|
47
|
+
end
|
|
48
|
+
if development?
|
|
49
|
+
if req.params['nocache'] || req.GET.include?('nocache')
|
|
50
|
+
puts "== You are viewing #{page} directly from google drive".red
|
|
51
|
+
return page_data_request = YAML.load(session.file_by_title(locale).worksheet_by_title(page).list.to_hash_array.to_yaml)
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
if !::File.exist?(cache_file) || ::File.mtime(cache_file) < (time - cache_duration)
|
|
55
|
+
result = session.file_by_title(locale).worksheet_by_title(page).list.to_hash_array.to_yaml
|
|
56
|
+
::File.open(cache_file, 'w') { |f| f << result }
|
|
57
|
+
end
|
|
58
|
+
return page_data_request = YAML.load(::File.read(cache_file))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Middleman
|
|
2
|
+
class GoogleDriveMiddlemanDataHelpers < GoogleDriveMiddlemanExtension
|
|
3
|
+
def initialize(app, options_hash={}, &block)
|
|
4
|
+
super
|
|
5
|
+
|
|
6
|
+
app.helpers do
|
|
7
|
+
|
|
8
|
+
def getItemByPosition(grid_position, page_data_request)
|
|
9
|
+
item_by_position = page_data_request.find { |k| k['grid_position'] == grid_position }
|
|
10
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def getItemByPositionAndType(grid_position, page_type, page_data_request)
|
|
14
|
+
item_by_position = page_data_request.find {|k| k['grid_position'] == grid_position && k['type'] == page_type }
|
|
15
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def getItemByType(type, page_data_request)
|
|
19
|
+
item_by_position = page_data_request.find { |k| k['type'] == type}
|
|
20
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def getItemByPage(page, page_data_request)
|
|
24
|
+
item_by_position = page_data_request.find { |k| k['page'] == page}
|
|
25
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def getAllItemsByPosition(grid_position, page_data_request)
|
|
29
|
+
item_by_position = page_data_request.find_all {|k| k['grid_position'] == grid_position }
|
|
30
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def getAllItemsByType(type, page_data_request)
|
|
34
|
+
item_by_position = page_data_request.find_all {|k| k['type'] == type }
|
|
35
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def getAllItemsByPage(page, page_data_request)
|
|
39
|
+
item_by_position = page_data_request.find_all { |k| k['page'] == page }
|
|
40
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def getCell(grid_position, column_name, page_data_request)
|
|
44
|
+
getItemByPosition(grid_position, page_data_request)[column_name]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def getData(data_type, data_name, page_data)
|
|
48
|
+
request = page_data.find_all {|k| k["#{data_type}"].match /#{data_name}/}
|
|
49
|
+
if request.length == 1
|
|
50
|
+
return request[0]
|
|
51
|
+
else
|
|
52
|
+
return request ? request : 'Error: No Data Found'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def getAllData(data_type, data_name, page_data)
|
|
57
|
+
return page_data.find_all { |k| k["#{data_type}"].match /#{data_name}(.*)/ }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/google-drive.rb
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require "middleman-core"
|
|
2
|
+
require 'google-drive/version'
|
|
3
|
+
|
|
4
|
+
::Middleman::Extensions.register(:googledrive) do
|
|
5
|
+
require 'google_drive'
|
|
6
|
+
require 'google-drive/extension'
|
|
7
|
+
require 'google-drive/helpers'
|
|
8
|
+
::Middleman::GoogleDriveMiddlemanExtension
|
|
9
|
+
::Middleman::GoogleDriveMiddlemanDataHelpers
|
|
10
|
+
end
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
require 'rack'
|
|
3
|
+
|
|
4
|
+
module Middleman
|
|
5
|
+
class GoogleDriveExtension < Extension
|
|
6
|
+
# option :offline, 'false', 'Load the data locally if set to true'
|
|
7
|
+
|
|
8
|
+
def initialize(app, options_hash={}, &block)
|
|
9
|
+
# Call super to build options from the options_hash
|
|
10
|
+
super
|
|
11
|
+
unless File.directory?('data/cache')
|
|
12
|
+
FileUtils.mkdir 'data/cache'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# app.extend google-driveConnector
|
|
16
|
+
# end
|
|
17
|
+
|
|
18
|
+
app.helpers do
|
|
19
|
+
puts '== Google Drive Loaded'
|
|
20
|
+
def session
|
|
21
|
+
# Create Google Authentication Session with Access Token
|
|
22
|
+
settings = YAML.load(File.open('data/credentials.yml'))
|
|
23
|
+
client = OAuth2::Client.new(
|
|
24
|
+
settings['google']['client_id'], settings['google']['client_secret'],
|
|
25
|
+
site: 'https://accounts.google.com',
|
|
26
|
+
token_url: '/o/oauth2/token',
|
|
27
|
+
authorize_url: '/o/oauth2/auth'
|
|
28
|
+
)
|
|
29
|
+
auth_token = OAuth2::AccessToken.from_hash( client, { refresh_token: settings['google']['refresh_token'] })
|
|
30
|
+
auth_token = auth_token.refresh!
|
|
31
|
+
gdauth = GoogleDrive.login_with_oauth(auth_token)
|
|
32
|
+
return session = gdauth.collection_by_title(banner).subcollection_by_title(season).subcollection_by_title(campaign)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def gdrive(locale, page)
|
|
36
|
+
get_worksheet_data(locale, page)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_worksheet_data(locale, page)
|
|
40
|
+
locale = locale.lstrip.rstrip
|
|
41
|
+
page = page.lstrip.rstrip
|
|
42
|
+
cache_file = ::File.join('data/cache', "#{locale}_#{page}.yml")
|
|
43
|
+
time = Time.now
|
|
44
|
+
if offline
|
|
45
|
+
puts "== You are currently viewing #{page} using the offline mode".green
|
|
46
|
+
return page_data_request = YAML.load(::File.read(cache_file))
|
|
47
|
+
end
|
|
48
|
+
if development?
|
|
49
|
+
if req.params['nocache'] || req.GET.include?('nocache')
|
|
50
|
+
puts "== You are viewing #{page} directly from google drive".red
|
|
51
|
+
return page_data_request = YAML.load(session.file_by_title(locale).worksheet_by_title(page).list.to_hash_array.to_yaml)
|
|
52
|
+
end
|
|
53
|
+
else
|
|
54
|
+
if !::File.exist?(cache_file) || ::File.mtime(cache_file) < (time - cache_duration)
|
|
55
|
+
result = session.file_by_title(locale).worksheet_by_title(page).list.to_hash_array.to_yaml
|
|
56
|
+
::File.open(cache_file, 'w') { |f| f << result }
|
|
57
|
+
end
|
|
58
|
+
return page_data_request = YAML.load(::File.read(cache_file))
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Middleman
|
|
2
|
+
class GoogleDriveDataHelpers < GoogleDriveExtension
|
|
3
|
+
def initialize(app, options_hash={}, &block)
|
|
4
|
+
super
|
|
5
|
+
|
|
6
|
+
app.helpers do
|
|
7
|
+
|
|
8
|
+
def getItemByPosition(grid_position, page_data_request)
|
|
9
|
+
item_by_position = page_data_request.find { |k| k['grid_position'] == grid_position }
|
|
10
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def getItemByPositionAndType(grid_position, page_type, page_data_request)
|
|
14
|
+
item_by_position = page_data_request.find {|k| k['grid_position'] == grid_position && k['type'] == page_type }
|
|
15
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def getItemByType(type, page_data_request)
|
|
19
|
+
item_by_position = page_data_request.find { |k| k['type'] == type}
|
|
20
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def getItemByPage(page, page_data_request)
|
|
24
|
+
item_by_position = page_data_request.find { |k| k['page'] == page}
|
|
25
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def getAllItemsByPosition(grid_position, page_data_request)
|
|
29
|
+
item_by_position = page_data_request.find_all {|k| k['grid_position'] == grid_position }
|
|
30
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def getAllItemsByType(type, page_data_request)
|
|
34
|
+
item_by_position = page_data_request.find_all {|k| k['type'] == type }
|
|
35
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def getAllItemsByPage(page, page_data_request)
|
|
39
|
+
item_by_position = page_data_request.find_all { |k| k['page'] == page }
|
|
40
|
+
item_by_position ? item_by_position : '<span>no item found!</span>'
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def getCell(grid_position, column_name, page_data_request)
|
|
44
|
+
getItemByPosition(grid_position, page_data_request)[column_name]
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def getData(data_type, data_name, page_data)
|
|
48
|
+
request = page_data.find_all {|k| k["#{data_type}"].match /#{data_name}/}
|
|
49
|
+
if request.length == 1
|
|
50
|
+
return request[0]
|
|
51
|
+
else
|
|
52
|
+
return request ? request : 'Error: No Data Found'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def getAllData(data_type, data_name, page_data)
|
|
57
|
+
return page_data.find_all { |k| k["#{data_type}"].match /#{data_name}(.*)/ }
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'google-drive'
|
metadata
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: google-drive
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.6b
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ALDO Digital Lab
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: middleman-core
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - '>='
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.2.2
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - '>='
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.2.2
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rack
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: multipart-post
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - '>='
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '1.2'
|
|
48
|
+
- - <
|
|
49
|
+
- !ruby/object:Gem::Version
|
|
50
|
+
version: '3'
|
|
51
|
+
type: :runtime
|
|
52
|
+
prerelease: false
|
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
54
|
+
requirements:
|
|
55
|
+
- - '>='
|
|
56
|
+
- !ruby/object:Gem::Version
|
|
57
|
+
version: '1.2'
|
|
58
|
+
- - <
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3'
|
|
61
|
+
- !ruby/object:Gem::Dependency
|
|
62
|
+
name: oauth2
|
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - '>='
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: 0.5.0
|
|
68
|
+
type: :runtime
|
|
69
|
+
prerelease: false
|
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - '>='
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 0.5.0
|
|
75
|
+
- !ruby/object:Gem::Dependency
|
|
76
|
+
name: google_drive
|
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - '>='
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: 0.3.8
|
|
82
|
+
type: :runtime
|
|
83
|
+
prerelease: false
|
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - '>='
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: 0.3.8
|
|
89
|
+
description:
|
|
90
|
+
email:
|
|
91
|
+
executables: []
|
|
92
|
+
extensions: []
|
|
93
|
+
extra_rdoc_files: []
|
|
94
|
+
files:
|
|
95
|
+
- .bundle/binstubs/autospec
|
|
96
|
+
- .bundle/binstubs/bundler
|
|
97
|
+
- .bundle/binstubs/cucumber
|
|
98
|
+
- .bundle/binstubs/erubis
|
|
99
|
+
- .bundle/binstubs/htmldiff
|
|
100
|
+
- .bundle/binstubs/ldiff
|
|
101
|
+
- .bundle/binstubs/middleman
|
|
102
|
+
- .bundle/binstubs/nokogiri
|
|
103
|
+
- .bundle/binstubs/oauth
|
|
104
|
+
- .bundle/binstubs/rackup
|
|
105
|
+
- .bundle/binstubs/rake
|
|
106
|
+
- .bundle/binstubs/rdoc
|
|
107
|
+
- .bundle/binstubs/ri
|
|
108
|
+
- .bundle/binstubs/rspec
|
|
109
|
+
- .bundle/binstubs/thor
|
|
110
|
+
- .bundle/binstubs/tilt
|
|
111
|
+
- .bundle/binstubs/yard
|
|
112
|
+
- .bundle/binstubs/yardoc
|
|
113
|
+
- .bundle/binstubs/yri
|
|
114
|
+
- Gemfile
|
|
115
|
+
- README.md
|
|
116
|
+
- Rakefile
|
|
117
|
+
- features/support/env.rb
|
|
118
|
+
- google-drive.gemspec
|
|
119
|
+
- lib/gdrive/extension.rb
|
|
120
|
+
- lib/gdrive/helpers.rb
|
|
121
|
+
- lib/gdrive/version.rb
|
|
122
|
+
- lib/google-drive.rb
|
|
123
|
+
- lib/google-drive/extension.rb
|
|
124
|
+
- lib/google-drive/helpers.rb
|
|
125
|
+
- lib/google-drive/version.rb
|
|
126
|
+
- lib/middleman_extension.rb
|
|
127
|
+
homepage: http://github.com/aldogroup/Google-Drive
|
|
128
|
+
licenses: []
|
|
129
|
+
metadata: {}
|
|
130
|
+
post_install_message:
|
|
131
|
+
rdoc_options: []
|
|
132
|
+
require_paths:
|
|
133
|
+
- lib
|
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - '>='
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
|
+
requirements:
|
|
141
|
+
- - '>'
|
|
142
|
+
- !ruby/object:Gem::Version
|
|
143
|
+
version: 1.3.1
|
|
144
|
+
requirements: []
|
|
145
|
+
rubyforge_project:
|
|
146
|
+
rubygems_version: 2.2.2
|
|
147
|
+
signing_key:
|
|
148
|
+
specification_version: 4
|
|
149
|
+
summary: Google Drive for Aldo Group
|
|
150
|
+
test_files:
|
|
151
|
+
- features/support/env.rb
|