google-api 0.0.1.rc1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/CHANGELOG.md +4 -0
- data/README.md +4 -4
- data/google-api.gemspec +1 -1
- data/lib/google-api/active_record_inclusions.rb +10 -4
- data/lib/google-api/client.rb +1 -1
- data/spec/google-api/client_spec.rb +1 -1
- data/spec/support/oauthable_object.rb +1 -1
- metadata +10 -6
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
**This gem is in its infancy! Proceed at your own risk...**
|
2
|
-
|
3
1
|
# Google API
|
4
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/agrobbin/google-api.png?branch=master)](https://travis-ci.org/agrobbin/google-api) [![Dependency Status](https://gemnasium.com/agrobbin/google-api.png)](https://gemnasium.com/agrobbin/google-api)
|
4
|
+
|
5
5
|
A simple but powerful ruby API wrapper for Google's services.
|
6
6
|
|
7
7
|
## Installation
|
@@ -66,12 +66,12 @@ user.google.drive.files.list
|
|
66
66
|
|
67
67
|
This will fetch all files and folders in the user's Google Drive and return them in an array of hashes.
|
68
68
|
|
69
|
-
## What Google APIs has this gem
|
69
|
+
## What Google APIs has this gem been tested against?
|
70
70
|
|
71
71
|
* Calendar
|
72
72
|
* Drive
|
73
73
|
|
74
|
-
## I need to use an API that is not yet tested
|
74
|
+
## Help! I need to use an API that is not yet tested
|
75
75
|
|
76
76
|
Open an issue, and we will do our best to fully test the API you need. Or, you can submit a pull request with any necessary updates!
|
77
77
|
|
data/google-api.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
12
|
gem.name = "google-api"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = "0.
|
14
|
+
gem.version = "0.1.0"
|
15
15
|
|
16
16
|
gem.add_runtime_dependency 'mime-types', '~> 1.0'
|
17
17
|
gem.add_runtime_dependency 'oauth2', '~> 0.8.0'
|
@@ -20,10 +20,16 @@ module GoogleAPI
|
|
20
20
|
}
|
21
21
|
end
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
# This method is used both within the GoogleAPI and can be used outside it in your own app to update
|
24
|
+
# the OAuth2 values in the database. Refresh token doesn't need to be passed, and any other attributes
|
25
|
+
# that you want to update on the object can be passed as a final parameter.
|
26
|
+
define_method :update_oauth! do |access_token, refresh_token = nil, additional_attrs = {}|
|
27
|
+
attrs = {
|
28
|
+
oauth_access_token: GoogleAPI.encrypt!(access_token),
|
29
|
+
oauth_access_token_expires_at: 59.minutes.from_now # it's actually an hour from now, but just to make sure we don't overlap at all, let's set it to 59 minutes
|
30
|
+
}.merge(additional_attrs)
|
31
|
+
attrs[:oauth_refresh_token] = GoogleAPI.encrypt!(refresh_token) if refresh_token
|
32
|
+
update_attributes(attrs)
|
27
33
|
end
|
28
34
|
|
29
35
|
define_method :google do
|
data/lib/google-api/client.rb
CHANGED
@@ -23,7 +23,7 @@ module GoogleAPI
|
|
23
23
|
if @access_token.expired?
|
24
24
|
GoogleAPI.logger.info "Access Token expired for #{object.class.name}(#{object.id}), refreshing..."
|
25
25
|
@access_token = @access_token.refresh!
|
26
|
-
object.
|
26
|
+
object.update_oauth!(@access_token.token)
|
27
27
|
end
|
28
28
|
|
29
29
|
@access_token
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Alex Robbin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
@@ -116,6 +116,7 @@ extra_rdoc_files: []
|
|
116
116
|
files:
|
117
117
|
- .gitignore
|
118
118
|
- .rspec
|
119
|
+
- .travis.yml
|
119
120
|
- CHANGELOG.md
|
120
121
|
- Gemfile
|
121
122
|
- LICENSE
|
@@ -155,13 +156,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
156
|
version: '0'
|
156
157
|
segments:
|
157
158
|
- 0
|
158
|
-
hash: -
|
159
|
+
hash: -3705329295137939947
|
159
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
161
|
none: false
|
161
162
|
requirements:
|
162
|
-
- - ! '
|
163
|
+
- - ! '>='
|
163
164
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
165
|
+
version: '0'
|
166
|
+
segments:
|
167
|
+
- 0
|
168
|
+
hash: -3705329295137939947
|
165
169
|
requirements: []
|
166
170
|
rubyforge_project:
|
167
171
|
rubygems_version: 1.8.24
|