gplus 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +27 -0
- data/gplus.gemspec +4 -0
- data/lib/gplus.rb +3 -4
- data/lib/gplus/client.rb +38 -0
- data/lib/gplus/person.rb +7 -0
- data/lib/gplus/version.rb +1 -1
- metadata +28 -3
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Gplus: A Google+ API client library for Ruby
|
2
|
+
|
3
|
+
## Intro
|
4
|
+
|
5
|
+
The Google+ API was opened today (15th September 2011).
|
6
|
+
|
7
|
+
So far, there are two stub gems, `googleplus` and `google_plus`, both of which do literally nothing.
|
8
|
+
|
9
|
+
Lets work together to get Ruby on Google+ ASAP!
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
gem install gplus
|
14
|
+
|
15
|
+
## Using the gem
|
16
|
+
|
17
|
+
To make requests, you need to [create an application](https://code.google.com/apis/console) with access to the Google+ API.
|
18
|
+
|
19
|
+
Next, [create an OAuth 2.0 client ID](http://code.google.com/apis/console#access). You'll need to pick a product name, an optional logo, and a domain to redirect to after authorization.
|
20
|
+
|
21
|
+
You can then specify additional redirect URIs and allowed javascript origins.
|
22
|
+
|
23
|
+
You'll need the Client ID and Client secret that are generated. Keep them secure!
|
24
|
+
|
25
|
+
Create a Google+ client:
|
26
|
+
|
27
|
+
client = Gplus::Client.new(:client_id => 'YOUR_CLIENT_ID', :client_secret => 'YOUR_CLIENT_SECRET')
|
data/gplus.gemspec
CHANGED
@@ -14,4 +14,8 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "gplus"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Gplus::VERSION
|
17
|
+
|
18
|
+
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6')
|
19
|
+
gem.add_runtime_dependency 'multi_json', '~> 1.0'
|
20
|
+
gem.add_runtime_dependency 'oauth2', '~> 0.5'
|
17
21
|
end
|
data/lib/gplus.rb
CHANGED
data/lib/gplus/client.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'gplus/person'
|
2
|
+
|
3
|
+
module Gplus
|
4
|
+
class Client
|
5
|
+
def initialize(options = {})
|
6
|
+
@client_id = options[:client_id]
|
7
|
+
@client_secret = options[:client_secret]
|
8
|
+
@redirect_uri = options[:redirect_uri]
|
9
|
+
@token = options[:token]
|
10
|
+
|
11
|
+
@oauth_client = OAuth2::Client.new(
|
12
|
+
@client_id,
|
13
|
+
@client_secret,
|
14
|
+
:site => 'https://www.googleapis.com/plus/',
|
15
|
+
:authorize_url => 'https://accounts.google.com/o/oauth2/auth',
|
16
|
+
:token_url => 'https://accounts.google.com/o/oauth2/token'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def authorize_url(redirect_uri = @redirect_uri)
|
21
|
+
@oauth_client.auth_code.authorize_url(:redirect_uri => redirect_uri, :scope => 'https://www.googleapis.com/auth/plus.me')
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize(auth_code, redirect_uri = @redirect_uri)
|
25
|
+
@access_token = @oauth_client.auth_code.get_token(auth_code, :redirect_uri => redirect_uri)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def access_token
|
30
|
+
@access_token ||= OAuth2::AccessToken.new(@oauth_client, @token)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get(path)
|
34
|
+
response = access_token.get("v1/#{path}")
|
35
|
+
MultiJson.decode(response.body)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/gplus/person.rb
ADDED
data/lib/gplus/version.rb
CHANGED
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: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,29 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
date: 2011-09-16 00:00:00.000000000Z
|
13
|
-
dependencies:
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: &22201720 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *22201720
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: oauth2
|
27
|
+
requirement: &22197600 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.5'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *22197600
|
14
36
|
description: An *actual* Google+ gem!
|
15
37
|
email:
|
16
38
|
- nicholas@2suggestions.com.au
|
@@ -20,9 +42,12 @@ extra_rdoc_files: []
|
|
20
42
|
files:
|
21
43
|
- .gitignore
|
22
44
|
- Gemfile
|
45
|
+
- README.md
|
23
46
|
- Rakefile
|
24
47
|
- gplus.gemspec
|
25
48
|
- lib/gplus.rb
|
49
|
+
- lib/gplus/client.rb
|
50
|
+
- lib/gplus/person.rb
|
26
51
|
- lib/gplus/version.rb
|
27
52
|
homepage: https://github.com/nfm/gplus
|
28
53
|
licenses: []
|
@@ -41,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
41
66
|
requirements:
|
42
67
|
- - ! '>='
|
43
68
|
- !ruby/object:Gem::Version
|
44
|
-
version:
|
69
|
+
version: 1.3.6
|
45
70
|
requirements: []
|
46
71
|
rubyforge_project:
|
47
72
|
rubygems_version: 1.8.10
|