mage-hand 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/mage-hand.rb +5 -4
- data/lib/ob_port/client.rb +21 -11
- data/mage-hand.gemspec +2 -2
- metadata +4 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/mage-hand.rb
CHANGED
@@ -5,10 +5,10 @@ module MageHand
|
|
5
5
|
protected
|
6
6
|
|
7
7
|
def obsidian_portal_login_required
|
8
|
-
@mage_client = MageHand::Client.new(session[:request_token], session[:
|
9
|
-
request.url, params)
|
8
|
+
@mage_client = MageHand::Client.new(session[:request_token], session[:access_token_key],
|
9
|
+
session[:access_token_secret], request.url, params)
|
10
10
|
store_tokens
|
11
|
-
return true
|
11
|
+
return true unless @mage_client.access_token.nil?
|
12
12
|
|
13
13
|
redirect_to @mage_client.request_token.authorize_url
|
14
14
|
false
|
@@ -24,6 +24,7 @@ module MageHand
|
|
24
24
|
|
25
25
|
def store_tokens
|
26
26
|
session[:request_token] = @mage_client.request_token
|
27
|
-
session[:
|
27
|
+
session[:access_token_key] = @mage_client.access_token_key
|
28
|
+
session[:access_token_secret] = @mage_client.access_token_secret
|
28
29
|
end
|
29
30
|
end
|
data/lib/ob_port/client.rb
CHANGED
@@ -1,32 +1,42 @@
|
|
1
1
|
module MageHand
|
2
|
-
LOGIN_URL = '
|
2
|
+
LOGIN_URL = 'http://www.obsidianportal.com/'
|
3
3
|
API_URL = 'http://api.obsidianportal.com/v1/users/me.json'
|
4
4
|
|
5
5
|
class Client
|
6
6
|
cattr_accessor :key, :secret
|
7
|
-
attr_accessor :consumer, :request_token, :access_token
|
7
|
+
attr_accessor :consumer, :request_token, :access_token,:access_token_key, :access_token_secret
|
8
8
|
|
9
9
|
def self.configure(key, secret)
|
10
10
|
self.key = key
|
11
11
|
self.secret = secret
|
12
12
|
end
|
13
13
|
|
14
|
-
def initialize(
|
14
|
+
def initialize(session_request_token=nil, session_access_token_key=nil, session_access_token_secret=nil,
|
15
|
+
callback=nil, params=nil)
|
16
|
+
@request_token = session_request_token
|
17
|
+
@access_token_key = session_access_token_key
|
18
|
+
@access_token_secret = session_access_token_secret
|
19
|
+
|
15
20
|
@consumer = OAuth::Consumer.new( Client.key,Client.secret, {
|
16
|
-
:
|
17
|
-
:
|
18
|
-
:
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
:site => 'http://api.obsidianportal.com',
|
22
|
+
:request_token_url => 'https://www.obsidianportal.com/oauth/request_token',
|
23
|
+
:authorize_url => 'https://www.obsidianportal.com/oauth/authorize',
|
24
|
+
:access_token_url => 'https://www.obsidianportal.com/oauth/access_token'})
|
25
|
+
|
26
|
+
if logged_in?
|
27
|
+
@access_token = OAuth::AccessToken.new(@consumer, access_token_key, access_token_secret)
|
28
|
+
elsif params[:oauth_verifier]
|
29
|
+
temp_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
|
30
|
+
@access_token_key = temp_token.token
|
31
|
+
@access_token_secret = temp_token.secret
|
32
|
+
@access_token = OAuth::AccessToken.new(@consumer, @access_token_key, @access_token_secret)
|
23
33
|
else
|
24
34
|
@request_token = @consumer.get_request_token(:oauth_callback => callback)
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
28
38
|
def logged_in?
|
29
|
-
|
39
|
+
!!access_token_secret
|
30
40
|
end
|
31
41
|
end
|
32
42
|
end
|
data/mage-hand.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mage-hand}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Steven Hammond"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-24}
|
13
13
|
s.description = %q{mage-hand is a ghostly hand that reaches across the internet to access the Obsidian Portal API.}
|
14
14
|
s.email = %q{shammond@northpub.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mage-hand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Steven Hammond
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-24 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|