google_doc_seed 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +2 -0
- data/examples/creds.example.yml +4 -0
- data/examples/full.rb +18 -0
- data/google_doc_seed.gemspec +3 -0
- data/lib/google_doc_seed/version.rb +1 -1
- data/lib/google_doc_seed.rb +17 -0
- metadata +33 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492a3919d811e0f12440c6475fe34d4b4193c4fb
|
4
|
+
data.tar.gz: e862884d9ba2f534dcdd9e831fb59b1a840462cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfb558b9870f38bafc153e359af5026945c19e810f5cffc00bde9733bf699a5d0b4770a212888a6c5fccba10218f4927b0f96d317c16fb6c01ad1a71ac876d9b
|
7
|
+
data.tar.gz: 4c536bbc102a12b02e8cf134380ce4ac0a4b09db3b95b91ae9d20b3eec8771e7cf19dabde496397823f642c42c6434c98c3cb118bb0e20bab0293eed8ac06751
|
data/.gitignore
CHANGED
data/README.md
CHANGED
data/examples/full.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Interactively prompts for access, then retrieves a spreadsheet
|
2
|
+
#
|
3
|
+
# Create an app here: https://console.developers.google.com
|
4
|
+
# See also: https://developers.google.com/drive/web/quickstart/quickstart-ruby
|
5
|
+
#
|
6
|
+
# Pre-reqs
|
7
|
+
# gem install launchy
|
8
|
+
# gem install google-api-client
|
9
|
+
# cp creds.example.yml creds.yml
|
10
|
+
# vim creds.yml
|
11
|
+
|
12
|
+
require '../lib/google_doc_seed'
|
13
|
+
require 'yaml'
|
14
|
+
|
15
|
+
creds = YAML.load_file('creds.yml')
|
16
|
+
token = GoogleDocSeed.get_access_token(creds['client_id'], creds['client_secret'])
|
17
|
+
seeder = GoogleDocSeed.new(token['access_token'])
|
18
|
+
puts seeder.to_csv_string(creds['doc_key'])
|
data/google_doc_seed.gemspec
CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "google-api-client"
|
24
|
+
spec.add_development_dependency "launchy"
|
25
|
+
|
23
26
|
|
24
27
|
spec.add_dependency "google_drive", "~> 0.3.5"
|
25
28
|
end
|
data/lib/google_doc_seed.rb
CHANGED
@@ -3,6 +3,23 @@ require "google_drive"
|
|
3
3
|
require "csv"
|
4
4
|
|
5
5
|
class GoogleDocSeed
|
6
|
+
def self.get_access_token(client_id, client_secret)
|
7
|
+
require 'google/api_client'
|
8
|
+
require 'launchy'
|
9
|
+
|
10
|
+
client = Google::APIClient.new(application_name: 'RubyGoogleDocSeed',
|
11
|
+
application_version: GoogleDocSeed::VERSION)
|
12
|
+
|
13
|
+
client.authorization.client_id = client_id
|
14
|
+
client.authorization.client_secret = client_secret
|
15
|
+
client.authorization.redirect_uri = 'urn:ietf:wg:oauth:2.0:oob'
|
16
|
+
client.authorization.scope = 'https://spreadsheets.google.com/feeds'
|
17
|
+
Launchy.open(client.authorization.authorization_uri)
|
18
|
+
puts 'Enter authorization code: '
|
19
|
+
client.authorization.code = gets.chomp
|
20
|
+
client.authorization.fetch_access_token!
|
21
|
+
end
|
22
|
+
|
6
23
|
def initialize(token)
|
7
24
|
@session = GoogleDrive.login_with_oauth(token)
|
8
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_doc_seed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Leavitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: google-api-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: launchy
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: google_drive
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -64,6 +92,8 @@ files:
|
|
64
92
|
- LICENSE.txt
|
65
93
|
- README.md
|
66
94
|
- Rakefile
|
95
|
+
- examples/creds.example.yml
|
96
|
+
- examples/full.rb
|
67
97
|
- google_doc_seed.gemspec
|
68
98
|
- lib/google_doc_seed.rb
|
69
99
|
- lib/google_doc_seed/version.rb
|
@@ -87,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
117
|
version: '0'
|
88
118
|
requirements: []
|
89
119
|
rubyforge_project:
|
90
|
-
rubygems_version: 2.0.
|
120
|
+
rubygems_version: 2.0.3
|
91
121
|
signing_key:
|
92
122
|
specification_version: 4
|
93
123
|
summary: Pulls a Google Spreadsheet into a CSV
|