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.
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ script: bundle exec rspec spec
@@ -1,3 +1,7 @@
1
+ ## v0.0.1.rc2 (TBD)
2
+
3
+ * Generalize #update_oauth! method for an oauthable ActiveRecord object. See active_record_inclusions.rb for more.
4
+
1
5
  ## v0.0.1.rc1 (2012-09-20)
2
6
 
3
7
  * Add OAuth2 token encryption.
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 be tested against?
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
 
@@ -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.0.1.rc1"
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
- define_method :update_access_token! do |access_token|
24
- self.oauth_access_token = GoogleAPI.encrypt!(access_token)
25
- self.oauth_access_token_expires_at = 59.minutes.from_now
26
- self.save
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
@@ -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.update_access_token!(@access_token.token)
26
+ object.update_oauth!(@access_token.token)
27
27
  end
28
28
 
29
29
  @access_token
@@ -54,7 +54,7 @@ describe GoogleAPI::Client do
54
54
  end
55
55
 
56
56
  it "should update the object's stored OAuth information" do
57
- object.should_receive(:update_access_token!)
57
+ object.should_receive(:update_oauth!)
58
58
  client.access_token
59
59
  end
60
60
 
@@ -18,7 +18,7 @@ class User
18
18
  }
19
19
  end
20
20
 
21
- def update_access_token!(access_token)
21
+ def update_oauth!(access_token, refresh_token = nil, additional_attrs = {})
22
22
  end
23
23
 
24
24
  def google
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.0.1.rc1
5
- prerelease: 6
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-09-21 00:00:00.000000000 Z
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: -4437608343180398710
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: 1.3.1
165
+ version: '0'
166
+ segments:
167
+ - 0
168
+ hash: -3705329295137939947
165
169
  requirements: []
166
170
  rubyforge_project:
167
171
  rubygems_version: 1.8.24