gplus 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,26 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.0.0: 2012/01/03
4
+
5
+ ### Breaking API changes
6
+
7
+ * Rename `#authorize` to `#get_token` and change method signature to match `OAuth2::Strategy::AuthCode#get_token`.
8
+ Convert `access_token = authorize(params[:code])` to `access_token = get_token(params[:code])` in your OAuth callback action.
9
+ * Define new `#authorize` method, for authorization a client instance with a user's `token`, `refresh_token` and `token_expires_at` after initialization.
10
+ * `#search_people` and `#search_activities` now take a mandatory query parameter, followed by an options hash.
11
+ Convert `search_people(:query => 'Frankie', :maxResults => 5)` to `search_people('Frankie', :maxResults => 5)`.
12
+ * `#authorize_url` now accepts an options hash, instead of just a `redirect_uri` parameter. Use the options hash to request a different `access_type` amongst other things.
13
+ Convert `authorize_url('http://example.org/callback')` to `authorize_url(:redirect_uri => 'http://example.org/callback')`.
14
+
15
+ ### Other changes
16
+
17
+ * Bugfix: Authorized requests with params now call OAuth2 methods correctly
18
+ * Bugfix: Fixed access token refreshing
19
+ * `Activity`, `Comment` and `Person` are now modules included in `Client`
20
+ * Better YARD documentation
21
+ * Files are now autoloaded
22
+ * Added link to Rails 3.1 example app
23
+
3
24
  ## v1.0.1: 2011/12/30
4
25
 
5
26
  * Fix bug in `#access_token` where `@access_token` was not being returned correctly
data/README.md CHANGED
@@ -11,11 +11,16 @@ It currently has full support for the People, Activities and Comments APIs, usin
11
11
  * [Documentation](http://rubydoc.info/github/nfm/gplus/master/frames)
12
12
  * [Issues](https://github.com/nfm/gplus/issues)
13
13
  * [Changelog](https://github.com/nfm/gplus/blob/master/CHANGELOG.md)
14
+ * [Example Rails 3.1 app](https://github.com/nfm/gplus-rails-demo)
14
15
 
15
16
  ## Installation
16
17
 
17
18
  Add `gplus` to your Gemfile, then run `bundle install`.
18
19
 
20
+ ## Example Rails application
21
+
22
+ Take a look at the [example Rails 3.1 application](https://github.com/nfm/gplus-rails-demo) to see gplus in action. You can either browse the repository to see how I'm using it, or clone it and follow the instructions in that repositories README to test it.
23
+
19
24
  ## Creating and configuring your application
20
25
 
21
26
  To make requests, you need to [create an application](https://code.google.com/apis/console) with access to the Google+ API.
@@ -46,9 +51,9 @@ First, create an API client using your Client ID, Client Secret, and one of the
46
51
  :redirect_uri => 'http://example.com/oauth/callback'
47
52
  )
48
53
 
49
- Generate an authorization URL, and use it in a view:
54
+ Generate an authorization URL, and use it in a view. You may want to request offline access:
50
55
 
51
- @auth_url = @gplus.authorize_url
56
+ @auth_url = @gplus.authorize_url(:access_type => 'offline')
52
57
  => https://accounts.google.com/o/oauth2/auth?response_type=code&client_id=YOUR_CLIENT_ID&redirect_uri= ...
53
58
 
54
59
  = link_to 'Authorize This App', @auth_url
@@ -57,7 +62,7 @@ After the user authorizes your app, they will be redirected to your `redirect_ur
57
62
 
58
63
  class OauthController < ApplicationController
59
64
  def callback
60
- access_token = @gplus.authorize(params[:code])
65
+ access_token = @gplus.get_token(params[:code])
61
66
  current_user.update_attributes(
62
67
  :token => access_token.token,
63
68
  :refresh_token => access_token.refresh_token,
@@ -77,10 +82,16 @@ Now you can create an authorized client instance using the stored OAuth token:
77
82
  :redirect_uri => 'http://example.com/oauth/callback'
78
83
  )
79
84
 
85
+ Alternatively, you can authorize an existing client instance (after you initialize it) by calling `authorize` and passing in the stored `token`, `refresh_token` and `token_expires_at`:
86
+
87
+ @gplus.authorize(current_user.token, current_user.refresh_token, current_user.token_expires_at)
88
+
80
89
  ## Refreshing OAuth tokens
81
90
 
82
91
  Google+ OAuth tokens are currently only valid for 3600 seconds (one hour). You can use the `:refresh_token` to get a new OAuth token after your existing token expires, without requiring the user to re-authorize your application.
83
92
 
93
+ *Note* that you will only receive a `refresh_token` if you request `:access_type => 'offline'` when you generate your `authorize_url`.
94
+
84
95
  Gplus will automatically request a new token if the provided token has expired. You should check to see if this has occured so that you can store the new token. Otherwise, after the initial token expires, you'll be requesting a new token from Google each time you initialize an API client. This is slow!
85
96
 
86
97
  You can determine whether a token has been refreshed by calling `access_token_refreshed?`:
@@ -111,7 +122,7 @@ The person's profile will be returned as a nested hash:
111
122
 
112
123
  Search for public profiles with `.search_people`:
113
124
 
114
- people = @gplus.search_people(:query => 'Larry Page')
125
+ people = @gplus.search_people('Larry Page')
115
126
 
116
127
  Matching profiles will be returned in a nested hash. The actual profiles are in the `:items` array:
117
128
 
@@ -122,14 +133,12 @@ Matching profiles will be returned in a nested hash. The actual profiles are in
122
133
  By default, this will fetch 10 profiles. You can fetch between 1 and 20 by passing a `:maxResults` option:
123
134
 
124
135
  # Get 20 results
125
- @gplus.search_people(:query => 'Larry Page', :maxResults => 20)
136
+ @gplus.search_people('Larry Page', :maxResults => 20)
126
137
 
127
138
  If you want more than 20 results, take the `:nextPageToken` returned from your first request, and pass it as a `:pageToken` option:
128
139
 
129
- people = @gplus.search_people(:query => 'Larry Page', :maxResults => 20)
130
- more_people = @gplus.search_people(:query => 'Larry Page', :maxResults => 20, :pageToken => people[:nextPageToken])
131
-
132
- Omitting the `:query` option will simply return all profiles.
140
+ people = @gplus.search_people('Larry Page', :maxResults => 20)
141
+ more_people = @gplus.search_people('Larry Page', :maxResults => 20, :pageToken => people[:nextPageToken])
133
142
 
134
143
  See the Google+ API documentation for [People](http://developers.google.com/+/api/latest/people), [People: get](http://developers.google.com/+/api/latest/people/get) and [People: search](http://developers.google.com/+/api/latest/people/search).
135
144
 
@@ -167,7 +176,7 @@ If you want more than 100 results, take the `:nextPageToken` returned from your
167
176
 
168
177
  Search for public activities with `.search_activities`:
169
178
 
170
- activities = @gplus.search_activities(:query => 'Programming')
179
+ activities = @gplus.search_activities('Programming')
171
180
 
172
181
  Matching activities will be returned in a nested hash. The actual activities are in the `:items` array:
173
182
 
@@ -178,18 +187,16 @@ Matching activities will be returned in a nested hash. The actual activities are
178
187
  By default, this will fetch 10 activities. You can fetch between 1 and 20 by passing a `:maxResults` option:
179
188
 
180
189
  # Get 20 results
181
- @gplus.search_activities(:query => 'Programming', :maxResults => 20)
190
+ @gplus.search_activities('Programming', :maxResults => 20)
182
191
 
183
192
  If you want more than 20 results, take the `:nextPageToken` returned from your first request, and pass it as a `:pageToken` option:
184
193
 
185
- activities = @gplus.search_activities(:query => 'Programming', :maxResults => 20)
186
- more_activities = @gplus.search_activities(:query => 'Programming', :maxResults => 20, :pageToken => activities[:nextPageToken])
187
-
188
- Omitting the `:query` option will simply return all activities.
194
+ activities = @gplus.search_activities('Programming', :maxResults => 20)
195
+ more_activities = @gplus.search_activities('Programming', :maxResults => 20, :pageToken => activities[:nextPageToken])
189
196
 
190
197
  You can specify an order for the activities that are returned by passing an `:orderBy` option. Acceptable values are "best" and "recent" (the default).
191
198
 
192
- activities = @gplus.search_activities(:query => 'Programming', :orderBy => "best")
199
+ activities = @gplus.search_activities('Programming', :orderBy => "best")
193
200
 
194
201
  See the Google+ API documentation for [Activities](http://developers.google.com/+/api/latest/activities), [Activities: get](http://developers.google.com/+/api/latest/activities/get), [Activities: list](http://developers.google.com/+/api/latest/activities/list), and [Activities: search](http://developers.google.com/+/api/latest/activities/search).
195
202
 
data/Rakefile CHANGED
@@ -4,3 +4,10 @@ require "bundler/gem_tasks"
4
4
  require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new('spec')
6
6
  task :default => :spec
7
+
8
+ begin
9
+ require 'yard'
10
+ YARD::Rake::YardocTask.new(:yard)
11
+ rescue LoadError
12
+ puts "You need to install YARD. Run `bundle install`."
13
+ end
@@ -22,4 +22,5 @@ Gem::Specification.new do |gem|
22
22
  gem.add_development_dependency 'rspec'
23
23
  gem.add_development_dependency 'webmock'
24
24
  gem.add_development_dependency 'simplecov'
25
+ gem.add_development_dependency 'yard'
25
26
  end
@@ -1,4 +1,11 @@
1
1
  require 'oauth2'
2
2
 
3
- require "gplus/version"
4
- require "gplus/client"
3
+ # gplus: A complete implementation of the Google+ API for Ruby
4
+ # @see https://developers.google.com/+/api/ The official Google+ API documentation
5
+ module Gplus
6
+ autoload :Version, 'gplus/version'
7
+ autoload :Client, 'gplus/client'
8
+ autoload :Activity, 'gplus/activity'
9
+ autoload :Comment, 'gplus/comment'
10
+ autoload :Person, 'gplus/person'
11
+ end
@@ -1,35 +1,38 @@
1
1
  module Gplus
2
- class Client
2
+ # A collection of methods for Google+ Activities API calls.
3
+ # @see https://developers.google.com/+/api/latest/activities The Google+ Activities documentation.
4
+ module Activity
3
5
  # Get an Activity by its unique ID.
4
- # See http://developers.google.com/+/api/latest/activities/get for more details.
6
+ # @see https://developers.google.com/+/api/latest/activities/get The Google+ 'Activities: get' documentation.
5
7
  #
6
8
  # @param [String] id The unique ID of the activity you want to retrieve.
7
- # @return [Hash] A nested hash representation of an {http://developers.google.com/+/api/latest/activities#resource Activity resource}.
9
+ # @return [Hash] A nested hash representation of an {https://developers.google.com/+/api/latest/activities#resource Activity resource}.
8
10
  def get_activity(id)
9
11
  get("activities/#{id}")
10
12
  end
11
13
 
12
14
  # List a Person's Google+ activities.
13
- # See http://developers.google.com/+/api/latest/activities/list for more details.
15
+ # @see https://developers.google.com/+/api/latest/activities/list The Google+ 'Activities: list' documentation.
16
+ # @see https://developers.google.com/+/api/#pagination The Google+ pagination documentation.
14
17
  #
15
18
  # @param [String] person_id The unique ID of the person whose activities you want to list. Pass the string 'me' to list the activities for the person that the API client is authorized as.
16
- # @option options [Integer] maxResults The number of activities, between 1 and 100, to return. Defaults to 20.
19
+ # @option options [Integer] maxResults (20) The number of activities, between 1 and 100, to return.
17
20
  # @option options [String] pageToken The page of activities to fetch. Pass the value of :nextPageToken from the previous result set to get the next page of results.
18
- # @return [Hash] A nested hash representation of a {http://developers.google.com/+/api/latest/activities/list#response list of activities}.
21
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/activities/list#response list of activities}.
19
22
  def list_activities(person_id, options = {})
20
23
  get("people/#{person_id}/activities/public", options)
21
24
  end
22
25
 
23
26
  # Search all public Google+ activities.
24
- # See https://developers.google.com/+/api/latest/activities/search for more details
27
+ # @see https://developers.google.com/+/api/latest/activities/search The Google+ 'Activities: search' documentation.
25
28
  #
26
- # @option options [String] query The full text query to search for
27
- # @option options [Integer] maxResults The number of activities, between 1 and 20, to return. Defaults to 10.
29
+ # @param [String] query The full text query to search for.
30
+ # @option options [Integer] maxResults (10) The number of activities, between 1 and 20, to return.
28
31
  # @option options [String] pageToken The page of activities to fetch. Pass the value of :nextPageToken from the previous result set to get the next page of results.
29
- # @option options [String] orderBy Specifies how to order search results. Acceptable values are "best" and "recent". Defaults to "recent".
30
- # @return [Hash] A nested hash representation of a {http://developers.google.com/+/api/latest/activities/search#response search result for activities}.
31
- def search_activities(options = {})
32
- get("activities", options)
32
+ # @option options [String] orderBy ('recent') Specifies how to order search results. Acceptable values are 'best' and 'recent'.
33
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/activities/search#response search result for activities}.
34
+ def search_activities(query, options = {})
35
+ get("activities", options.merge(:query => query))
33
36
  end
34
37
  end
35
38
  end
@@ -1,10 +1,13 @@
1
- require 'gplus/activity'
2
- require 'gplus/comment'
3
- require 'gplus/person'
4
-
5
1
  module Gplus
2
+ # The main Gplus class, containing methods for initializing a Google+ client and requesting authorization
6
3
  class Client
4
+ include Activity
5
+ include Comment
6
+ include Person
7
+
8
+ # The default Google+ API endpoint that all requests are sent to.
7
9
  DEFAULT_ENDPOINT = 'https://www.googleapis.com/plus'
10
+ # The default version of the Google+ API to send requests to.
8
11
  DEFAULT_API_VERSION = 'v1'
9
12
 
10
13
  attr_accessor :endpoint, :api_version
@@ -42,20 +45,39 @@ module Gplus
42
45
  end
43
46
 
44
47
  # Generate an authorization URL where a user can authorize your application to access their Google+ data.
48
+ # @see https://code.google.com/apis/accounts/docs/OAuth2WebServer.html#formingtheurl The set of query string parameters supported by the Google Authorization Server for web server applications.
45
49
  #
46
- # @param [String] redirect_uri An optional over-ride for the redirect_uri you initialized the API client with.
50
+ # @param [Hash] options Additional parameters used in the OAuth request.
51
+ # @option options [String] :redirect_uri An optional over-ride for the redirect_uri you initialized the API client with.
52
+ # @option options [String] :access_type ('online'). Indicates if your application needs to access a Google API when the user is not present at the browser. Allowed values are 'online' and 'offline'.
47
53
  # @return [String] A Google account authorization URL for your application.
48
- def authorize_url(redirect_uri = @redirect_uri)
49
- @oauth_client.auth_code.authorize_url(:redirect_uri => redirect_uri, :scope => 'https://www.googleapis.com/auth/plus.me')
54
+ def authorize_url(options = {})
55
+ defaults = { :scope => 'https://www.googleapis.com/auth/plus.me', :redirect_uri => @redirect_uri }
56
+ options = defaults.merge(options)
57
+ @oauth_client.auth_code.authorize_url(options)
50
58
  end
51
59
 
52
- # Authorize an API client instance to access the user's private data.
60
+ # Retrieve an OAuth access token using the short-lived authentication code given to you after a user authorizes your application.
53
61
  #
54
62
  # @param [String] auth_code The code returned to your redirect_uri after the user authorized your application to access their Google+ data.
55
- # @param [String] redirect_uri An optional over-ride for the redirect_uri you initialized the API client with.
56
- # @return [OAuth2::AccessToken] An OAuth access token. Store access_token[:token] and access_token[:refresh_token] to get persistent access to the user's data until access_token[:expires_at].
57
- def authorize(auth_code, redirect_uri = @redirect_uri)
58
- @access_token = @oauth_client.auth_code.get_token(auth_code, :redirect_uri => redirect_uri)
63
+ # @param [Hash] params Additional parameters for the token endpoint (passed through to OAuth2::Client#get_token)
64
+ # @param [Hash] opts Additional access token options (passed through to OAuth2::Client#get_token)
65
+ # @return [OAuth2::AccessToken] An OAuth access token. Store access_token[:token], access_token[:refresh_token] and access_token[:expires_at] to get persistent access to the user's data until access_token[:expires_at].
66
+ def get_token(auth_code, params = {}, opts = {})
67
+ @access_token = @oauth_client.auth_code.get_token(auth_code, params, opts)
68
+ end
69
+
70
+ # Authorize a Gplus::Client instance to access the user's private data, after initialization
71
+ #
72
+ # @param [String] :token The OAuth token to authorize the API client for authenticated requests (for non-public data).
73
+ # @param [String] :refresh_token The OAuth refresh_token, to request a new token if the provided token has expired.
74
+ # @param [Integer] :token_expires_at The time that the OAuth token expires at in seconds since the epoch.
75
+ # @return An OAuth2::AccessToken
76
+ def authorize(token, refresh_token, token_expires_at)
77
+ @token = token
78
+ @refresh_token = refresh_token
79
+ @token_expires_at = token_expires_at
80
+ access_token
59
81
  end
60
82
 
61
83
  # Retrieve or create an OAuth2::AccessToken, using the :token and :refresh_token specified when the API client instance was initialized
@@ -65,7 +87,7 @@ module Gplus
65
87
  if @token
66
88
  @access_token ||= OAuth2::AccessToken.new(@oauth_client, @token, :refresh_token => @refresh_token, :expires_at => @token_expires_at)
67
89
  if @access_token.expired?
68
- @access_token.refresh!
90
+ @access_token = @access_token.refresh!
69
91
  @access_token_refreshed = true
70
92
  end
71
93
  @access_token
@@ -80,7 +102,7 @@ module Gplus
80
102
  private
81
103
  def get(path, params = {})
82
104
  if access_token
83
- response = access_token.get("#{self.api_version}/#{path}", params)
105
+ response = access_token.get("#{self.api_version}/#{path}", :params => params)
84
106
  else
85
107
  response = @oauth_client.request(:get, "#{self.api_version}/#{path}", { :params => params.merge(:key => @api_key) })
86
108
  end
@@ -1,21 +1,24 @@
1
1
  module Gplus
2
- class Client
2
+ # A collection of methods for Google+ Comments API calls.
3
+ # @see https://developers.google.com/+/api/latest/comments The Google+ Comments documentation
4
+ module Comment
3
5
  # Get a Comment by its unique ID.
4
- # See https://developers.google.com/+/api/latest/comments/get for more details.
6
+ # @see https://developers.google.com/+/api/latest/comments/get The Google+ 'Comments: get' documentation
5
7
  #
6
8
  # @param [String] id The unique ID of the comment you want to retrieve.
7
- # @returb [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/comments#resource Comment resource}.
9
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/comments#resource Comment resource}.
8
10
  def get_comment(id)
9
11
  get("comments/#{id}")
10
12
  end
11
13
 
12
14
  # List an activity's comments.
13
- # See http://developers.google.com/+/api/latest/comments/list for more details.
15
+ # @see https://developers.google.com/+/api/latest/comments/list The Google+ 'Comments: list' documentation.
16
+ # @see https://developers.google.com/+/api/#pagination The Google+ pagination documentation.
14
17
  #
15
18
  # @param [String] activity_id The unique ID of the activity whose comments you want to list.
16
- # @option options [Integer] maxResults The number of comments, between 0 and 100, to return. Defaults to 20.
19
+ # @option options [Integer] maxResults (20) The number of comments, between 0 and 100, to return.
17
20
  # @option options [String] pageToken The page of comments to fetch. Pass the value of :nextPageToken from the previous result set to get the next page of results.
18
- # @return [Hash] A nested hash representation of a {http://developers.google.com/+/api/latest/comments/list#response list of comments}.
21
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/comments/list#response list of comments}.
19
22
  def list_comments(activity_id, options = {})
20
23
  get("activities/#{activity_id}/comments", options)
21
24
  end
@@ -1,23 +1,27 @@
1
1
  module Gplus
2
- class Client
2
+ # A collection of methods for Google+ People API calls.
3
+ # @see https://developers.google.com/+/api/latest/people The Google+ People documentation.
4
+ module Person
3
5
  # Get a person's Google+ profile.
4
- # See http://developers.google.com/+/api/latest/people/get for more details.
6
+ # @ https://developers.google.com/+/api/latest/people/get The Google+ 'People: get' documentation.
5
7
  #
6
8
  # @param [String] id The unique ID of the person whose profile you want to retrieve. Pass the string 'me' to fetch the profile for the person that the API client is authorized as.
7
- # @return [Hash] A nested hash representation of a {http://developers.google.com/+/api/latest/people#resource Person resource}
9
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/people#resource Person resource}
8
10
  def get_person(id)
9
11
  get("people/#{id}")
10
12
  end
11
13
 
12
14
  # Search all public Google+ profiles.
13
- # See https://developers.google.com/+/api/latest/people/search for more details
15
+ # @see https://developers.google.com/+/api/latest/people/search The Google+ 'People: search' documentation.
16
+ # @see https://developers.google.com/+/api/#pagination The Google+ pagination documentation.
14
17
  #
15
- # @option options [String] query The full text query to search for
16
- # @option options [Integer] maxResults The number of profiles, between 1 and 20, to return. Defaults to 10.
18
+ # @param [String] query The full text query to search for.
19
+ # @option options [String] language The preferred language to search with. See {https://developers.google.com/+/api/search#available-languages the official list of allowed language codes}.
20
+ # @option options [Integer] maxResults (10) The number of profiles, between 1 and 20, to return.
17
21
  # @option options [String] pageToken The page of profiles to fetch. Pass the value of :nextPageToken from the previous result set to get the next page of results.
18
- # @return [Hash] A nested hash representation of a {http://developers.google.com/+/api/latest/people/search#response search result for people}.
19
- def search_people(options = {})
20
- get("people", options)
22
+ # @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/people/search#response search result for people}.
23
+ def search_people(query, options = {})
24
+ get("people", options.merge(:query => query))
21
25
  end
22
26
  end
23
27
  end
@@ -1,3 +1,5 @@
1
1
  module Gplus
2
- VERSION = "1.0.1"
2
+ # The version of Gplus that you're using. I use semantic versioning to version Gplus.
3
+ # @see http://semver.org/
4
+ VERSION = "2.0.0"
3
5
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Gplus::Client do
3
+ describe Gplus::Activity do
4
4
  before do
5
5
  @api_key = '1234567'
6
6
  @client = Gplus::Client.new(:api_key => @api_key)
@@ -47,28 +47,23 @@ describe Gplus::Client do
47
47
  @activities, @activities_json = fixture('activities.json')
48
48
  end
49
49
 
50
- it "should list all public activities" do
51
- stub_api_request(:get, "activities").to_return(:body => @activities)
52
- @client.search_activities.should == @activities_json
53
- end
54
-
55
- it "should accept a :query argument" do
50
+ it "should require a :query parameter" do
56
51
  stub_api_request(:get, "activities", :query => @activity_json['title']).to_return(:body => @activity)
57
- @client.search_activities(:query => @activity_json['title']).should == @activity_json
52
+ @client.search_activities(@activity_json['title']).should == @activity_json
58
53
  end
59
54
 
60
55
  it "should accept a :maxResults argument" do
61
56
  @results = 2
62
57
 
63
- stub_api_request(:get, "activities", :maxResults => @results.to_s).to_return(:body => @activities)
64
- @client.search_activities(:maxResults => @results).should == @activities_json
58
+ stub_api_request(:get, "activities", :query => @activity_json['title'], :maxResults => @results.to_s).to_return(:body => @activities)
59
+ @client.search_activities(@activity_json['title'], :maxResults => @results).should == @activities_json
65
60
  end
66
61
 
67
62
  it "should accept a :pageToken argument" do
68
63
  @page = '1234567'
69
64
 
70
- stub_api_request(:get, "activities", :pageToken => @page).to_return(:body => @activities)
71
- @client.search_activities(:pageToken => @page).should == @activities_json
65
+ stub_api_request(:get, "activities", :query => @activity_json['title'], :pageToken => @page).to_return(:body => @activities)
66
+ @client.search_activities(@activity_json['title'], :pageToken => @page).should == @activities_json
72
67
  end
73
68
  end
74
69
  end
@@ -13,6 +13,10 @@ describe Gplus::Client do
13
13
  pending
14
14
  end
15
15
 
16
+ describe '.get_token' do
17
+ pending
18
+ end
19
+
16
20
  describe '.access_token' do
17
21
  pending
18
22
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Gplus::Client do
3
+ describe Gplus::Comment do
4
4
  before do
5
5
  @api_key = '1234567'
6
6
  @client = Gplus::Client.new(:api_key => @api_key)
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Gplus::Client do
3
+ describe Gplus::Person do
4
4
  before do
5
5
  @api_key = '1234567'
6
6
  @client = Gplus::Client.new(:api_key => @api_key)
@@ -20,28 +20,23 @@ describe Gplus::Client do
20
20
  @people, @people_json = fixture('people.json')
21
21
  end
22
22
 
23
- it "should list all public profiles" do
24
- stub_api_request(:get, "people").to_return(:body => @people)
25
- @client.search_people.should == @people_json
26
- end
27
-
28
- it "should accept a :query argument" do
23
+ it "should require a :query parameter" do
29
24
  stub_api_request(:get, "people", :query => @person_json['displayName']).to_return(:body => @person)
30
- @client.search_people(:query => @person_json['displayName']).should == @person_json
25
+ @client.search_people(@person_json['displayName']).should == @person_json
31
26
  end
32
27
 
33
- it "should accept a :maxResults argument" do
28
+ it "should accept a :maxResults option" do
34
29
  @results = 2
35
30
 
36
- stub_api_request(:get, "people", :maxResults => @results.to_s).to_return(:body => @people)
37
- @client.search_people(:maxResults => @results).should == @people_json
31
+ stub_api_request(:get, "people", :query => @person_json['displayName'], :maxResults => @results.to_s).to_return(:body => @people)
32
+ @client.search_people(@person_json['displayName'], :maxResults => @results).should == @people_json
38
33
  end
39
34
 
40
- it "should accept a :pageToken argument" do
35
+ it "should accept a :pageToken option" do
41
36
  @page = '1234567'
42
37
 
43
- stub_api_request(:get, "people", :pageToken => @page).to_return(:body => @people)
44
- @client.search_people(:pageToken => @page).should == @people_json
38
+ stub_api_request(:get, "people", :query => @person_json['displayName'], :pageToken => @page).to_return(:body => @people)
39
+ @client.search_people(@person_json['displayName'], :pageToken => @page).should == @people_json
45
40
  end
46
41
  end
47
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gplus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-30 00:00:00.000000000 Z
12
+ date: 2012-01-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &13724120 !ruby/object:Gem::Requirement
16
+ requirement: &10358020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *13724120
24
+ version_requirements: *10358020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: oauth2
27
- requirement: &13723180 !ruby/object:Gem::Requirement
27
+ requirement: &10357520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.5'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *13723180
35
+ version_requirements: *10357520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &13701640 !ruby/object:Gem::Requirement
38
+ requirement: &10356960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *13701640
46
+ version_requirements: *10356960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: webmock
49
- requirement: &13700100 !ruby/object:Gem::Requirement
49
+ requirement: &10356360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *13700100
57
+ version_requirements: *10356360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: simplecov
60
- requirement: &13697420 !ruby/object:Gem::Requirement
60
+ requirement: &10355760 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,18 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *13697420
68
+ version_requirements: *10355760
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: &10355100 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *10355100
69
80
  description: A complete implementation of the Google plus API for Ruby
70
81
  email:
71
82
  - nicholas@2suggestions.com.au
@@ -123,3 +134,4 @@ specification_version: 3
123
134
  summary: Google+ API implementation with support for authorized requests, People,
124
135
  and Activities
125
136
  test_files: []
137
+ has_rdoc: