gplus 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +5 -0
- data/README.md +9 -1
- data/Rakefile +13 -0
- data/lib/gplus/client.rb +2 -0
- data/lib/gplus/person.rb +13 -0
- data/lib/gplus/version.rb +1 -1
- data/spec/gplus/person_spec.rb +31 -0
- data/spec/spec_helper.rb +1 -1
- metadata +15 -15
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.1.0: 2012/01/28
|
4
|
+
|
5
|
+
* Add support for listPeopleByActivity API call
|
6
|
+
* Use the `redirect_uri` that Gplus was initialized with as the default in `#get_token`. You now only have to specify an explicit `redirect_uri` when calling `#get_token` if you overrode your default `redirect_uri` when you called `#authorize_url`.
|
7
|
+
|
3
8
|
## v2.0.1: 2012/01/11
|
4
9
|
|
5
10
|
* Fix file permissions so that gplus's files are world readable
|
data/README.md
CHANGED
@@ -142,7 +142,15 @@ If you want more than 20 results, take the `:nextPageToken` returned from your f
|
|
142
142
|
people = @gplus.search_people('Larry Page', :maxResults => 20)
|
143
143
|
more_people = @gplus.search_people('Larry Page', :maxResults => 20, :pageToken => people[:nextPageToken])
|
144
144
|
|
145
|
-
|
145
|
+
List people who +1'd or reshared an activity with `.list_people_by_activity`:
|
146
|
+
|
147
|
+
# Get people who +1'd an activity
|
148
|
+
people = @gplus.list_people_by_activity(activity_id, 'plusoners')
|
149
|
+
|
150
|
+
# Get people who reshared an activity
|
151
|
+
people = @gplus.list_people_by_activity(activity_id, 'resharers')
|
152
|
+
|
153
|
+
See the Google+ API documentation for [People](http://developers.google.com/+/api/latest/people), [People: get](http://developers.google.com/+/api/latest/people/get), [People: search](http://developers.google.com/+/api/latest/people/search), and [People: listByActivity](https://developers.google.com/+/api/latest/people/listByActivity).
|
146
154
|
|
147
155
|
## [Activities](http://developers.google.com/+/api/latest/activities)
|
148
156
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
|
+
|
2
3
|
require "bundler/gem_tasks"
|
3
4
|
|
5
|
+
# Define a task to make sure the gem's files are world readable.
|
6
|
+
task :set_permissions do
|
7
|
+
system("find . -type f -exec chmod 644 {} \\;")
|
8
|
+
system("find . -type d -exec chmod 755 {} \\;")
|
9
|
+
end
|
10
|
+
|
11
|
+
# Add :set_permissions as a dependency for the :build, :install, and :release
|
12
|
+
# tasks that bundler provides, so that the correct permissions are always set.
|
13
|
+
task :build => :set_permissions
|
14
|
+
task :install => :set_permissions
|
15
|
+
task :release => :set_permissions
|
16
|
+
|
4
17
|
require 'rspec/core/rake_task'
|
5
18
|
RSpec::Core::RakeTask.new('spec')
|
6
19
|
task :default => :spec
|
data/lib/gplus/client.rb
CHANGED
@@ -65,6 +65,8 @@ module Gplus
|
|
65
65
|
# @param [Hash] opts Additional access token options (passed through to OAuth2::Client#get_token)
|
66
66
|
# @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].
|
67
67
|
def get_token(auth_code, params = {}, opts = {})
|
68
|
+
defaults = { :redirect_uri => @redirect_uri }
|
69
|
+
params = defaults.merge(params)
|
68
70
|
@access_token = @oauth_client.auth_code.get_token(auth_code, params, opts)
|
69
71
|
end
|
70
72
|
|
data/lib/gplus/person.rb
CHANGED
@@ -23,5 +23,18 @@ module Gplus
|
|
23
23
|
def search_people(query, options = {})
|
24
24
|
get("people", options.merge(:query => query))
|
25
25
|
end
|
26
|
+
|
27
|
+
# List all of the people in the specified collection for a particular activity.
|
28
|
+
# @see https://developers.google.com/+/api/latest/people/listByActivity The Google+ 'People: listByActivity' documentation.
|
29
|
+
# @see https://developers.google.com/+/api/#pagination The Google+ pagination documentation.
|
30
|
+
#
|
31
|
+
# @param [String] activity_id The ID of the activity to get the list of people for.
|
32
|
+
# @param [String] collection The collection of people to list. Acceptable values are 'plusoners' and 'resharers'.
|
33
|
+
# @option options [Integer] maxResults (20) The number of people, between 1 and 100, to return.
|
34
|
+
# @option options [String] pageToken The page of people to fetch. Pass the value of :nextPageToken from the previous result set to get the next page of results.
|
35
|
+
# @return [Hash] A nested hash representation of a {https://developers.google.com/+/api/latest/people/listByActivity#response list of people}.
|
36
|
+
def list_people_by_activity(activity_id, collection, options = {})
|
37
|
+
get("activities/#{activity_id}/people/#{collection}", options)
|
38
|
+
end
|
26
39
|
end
|
27
40
|
end
|
data/lib/gplus/version.rb
CHANGED
data/spec/gplus/person_spec.rb
CHANGED
@@ -39,4 +39,35 @@ describe Gplus::Person do
|
|
39
39
|
@client.search_people(@person_json['displayName'], :pageToken => @page).should == @people_json
|
40
40
|
end
|
41
41
|
end
|
42
|
+
|
43
|
+
describe '.list_people_by_activity' do
|
44
|
+
before do
|
45
|
+
@activity, @activity_json = fixture('activity.json')
|
46
|
+
@people, @people_json = fixture('people.json')
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should return a list of people who reshared an activity" do
|
50
|
+
stub_api_request(:get, "activities/#{@activity_json['id']}/people/resharers").to_return(:body => @people)
|
51
|
+
@client.list_people_by_activity(@activity_json['id'], 'resharers').should == @people_json
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return a list of people who plusoned an activity" do
|
55
|
+
stub_api_request(:get, "activities/#{@activity_json['id']}/people/plusoners").to_return(:body => @people)
|
56
|
+
@client.list_people_by_activity(@activity_json['id'], 'plusoners').should == @people_json
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should accept a :maxResults argument" do
|
60
|
+
@results = 2
|
61
|
+
|
62
|
+
stub_api_request(:get, "activities/#{@activity_json['id']}/people/plusoners", :maxResults => @results.to_s).to_return(:body => @people)
|
63
|
+
@client.list_people_by_activity(@activity_json['id'], 'plusoners', :maxResults => @results).should == @people_json
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should accept a :pageToken argument" do
|
67
|
+
@page = '1234567'
|
68
|
+
|
69
|
+
stub_api_request(:get, "activities/#{@activity_json['id']}/people/plusoners", :pageToken => @page).to_return(:body => @people)
|
70
|
+
@client.list_people_by_activity(@activity_json['id'], 'plusoners', :pageToken => @page).should == @people_json
|
71
|
+
end
|
72
|
+
end
|
42
73
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,6 @@ def fixture(file)
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def stub_api_request(method, path, query = {})
|
15
|
-
query[:key] = @api_key unless @api_key
|
15
|
+
query[:key] = @api_key unless @api_key == nil or @api_key == ''
|
16
16
|
stub_request(method, "#{Gplus::Client::DEFAULT_ENDPOINT}/#{Gplus::Client::DEFAULT_API_VERSION}/#{path}").with(:query => query)
|
17
17
|
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: 2.0
|
4
|
+
version: 2.1.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: 2012-01-
|
12
|
+
date: 2012-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
16
|
-
requirement: &
|
16
|
+
requirement: &22418700 !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: *
|
24
|
+
version_requirements: *22418700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth2
|
27
|
-
requirement: &
|
27
|
+
requirement: &22434380 !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: *
|
35
|
+
version_requirements: *22434380
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &22433800 !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: *
|
46
|
+
version_requirements: *22433800
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &22433340 !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: *
|
57
|
+
version_requirements: *22433340
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: simplecov
|
60
|
-
requirement: &
|
60
|
+
requirement: &22432900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *22432900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &22432260 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *22432260
|
80
80
|
description: A complete implementation of the Google plus API for Ruby
|
81
81
|
email:
|
82
82
|
- nicholas@2suggestions.com.au
|
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
version: 1.3.6
|
129
129
|
requirements: []
|
130
130
|
rubyforge_project:
|
131
|
-
rubygems_version: 1.8.
|
131
|
+
rubygems_version: 1.8.15
|
132
132
|
signing_key:
|
133
133
|
specification_version: 3
|
134
134
|
summary: Google+ API implementation with support for authorized requests, People,
|