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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba33dff85d9c33103980ca68e978e27222461f2d
4
- data.tar.gz: e5cd5d3c4d52b199b175c0d3af64bdd0fafaf738
3
+ metadata.gz: 492a3919d811e0f12440c6475fe34d4b4193c4fb
4
+ data.tar.gz: e862884d9ba2f534dcdd9e831fb59b1a840462cb
5
5
  SHA512:
6
- metadata.gz: a63897c797aa9e2a6b2fb4627f561bcb46d00c5ec12636da9d50b10d205b5599eb0a27c744fc7bc418dd8a5a963b8fc46d8a740a272972c4ca1bbd5f4b3dd27f
7
- data.tar.gz: 23a82f4cde8e63584101302c912ed0c93c0d8f8eba2c45bd770d16fc897e5c563c8fddb613955186e570ad568c259bb9694d17605d5e0b0a90a1567949bef7dd
6
+ metadata.gz: bfb558b9870f38bafc153e359af5026945c19e810f5cffc00bde9733bf699a5d0b4770a212888a6c5fccba10218f4927b0f96d317c16fb6c01ad1a71ac876d9b
7
+ data.tar.gz: 4c536bbc102a12b02e8cf134380ce4ac0a4b09db3b95b91ae9d20b3eec8771e7cf19dabde496397823f642c42c6434c98c3cb118bb0e20bab0293eed8ac06751
data/.gitignore CHANGED
@@ -15,3 +15,5 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+
19
+ examples/creds.yml
data/README.md CHANGED
@@ -21,6 +21,8 @@ Or install it yourself as:
21
21
  Get a [[Google OAuth2 token]](https://developers.google.com/oauthplayground)
22
22
  with the spreadsheet scope.
23
23
 
24
+ Or check out `examples/full.rb` for help generating one more easily.
25
+
24
26
 
25
27
  Then do this:
26
28
 
@@ -0,0 +1,4 @@
1
+ ---
2
+ client_id: your-client-id-here
3
+ client_secret: your-client-secret-here
4
+ doc_key: get-from-spreadsheet-url
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'])
@@ -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
@@ -1,3 +1,3 @@
1
1
  class GoogleDocSeed
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -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.1
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: 2013-05-06 00:00:00.000000000 Z
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.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