mage-hand 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
@@ -1,24 +1,29 @@
1
1
  require 'ob_port/client'
2
2
 
3
- module ObPort
3
+ module MageHand
4
4
 
5
5
  protected
6
6
 
7
- def ob_port_login_required
8
- @ob_client = ObPort::Client.new(session[:request_token], session[:access_token], request.url, params)
7
+ def obsidian_portal_login_required
8
+ @mage_client = MageHand::Client.new(session[:request_token], session[:access_token],
9
+ request.url, params)
9
10
  store_tokens
10
11
  return true if logged_in?
11
12
 
12
- redirect_to @ob_client.request_token.authorize_url
13
+ redirect_to @mage_client.request_token.authorize_url
13
14
  false
14
15
  end
15
16
 
16
17
  def logged_in?
17
- @ob_client.logged_in?
18
+ @mage_client.logged_in?
19
+ end
20
+
21
+ def obsidian_portal
22
+ @mage_client.access_token
18
23
  end
19
24
 
20
25
  def store_tokens
21
- session[:request_token] = @ob_client.request_token
22
- session[:access_token] = @ob_client.access_token
26
+ session[:request_token] = @mage_client.request_token
27
+ session[:access_token] = @mage_client.access_token
23
28
  end
24
29
  end
@@ -0,0 +1,32 @@
1
+ module MageHand
2
+ LOGIN_URL = 'https://www.obsidianportal.com/'
3
+ API_URL = 'http://api.obsidianportal.com/v1/users/me.json'
4
+
5
+ class Client
6
+ cattr_accessor :key, :secret
7
+ attr_accessor :consumer, :request_token, :access_token
8
+
9
+ def self.configure(key, secret)
10
+ self.key = key
11
+ self.secret = secret
12
+ end
13
+
14
+ def initialize(request_token=nil, access_token=nil, callback=nil, params=nil)
15
+ @consumer = OAuth::Consumer.new( Client.key,Client.secret, {
16
+ :request_token_path => 'https://www.obsidianportal.com/oauth/request_token',
17
+ :authorize_path=> 'https://www.obsidianportal.com/oauth/authorize',
18
+ :access_token_path => 'https://www.obsidianportal.com/oauth/access_token'})
19
+ if request_token
20
+ @request_token = request_token
21
+ @access_token = access_token || @request_token.get_access_token(
22
+ :oauth_verifier => params[:oauth_verifier])
23
+ else
24
+ @request_token = @consumer.get_request_token(:oauth_callback => callback)
25
+ end
26
+ end
27
+
28
+ def logged_in?
29
+ !!@access_token
30
+ end
31
+ end
32
+ end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mage-hand}
8
- s.version = "0.0.1"
8
+ s.version = "0.1.0"
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"]
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
25
25
  "Rakefile",
26
26
  "VERSION",
27
27
  "lib/mage-hand.rb",
28
+ "lib/ob_port/client.rb",
28
29
  "mage-hand.gemspec",
29
30
  "test/helper.rb",
30
31
  "test/test_mage-hand.rb"
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: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Steven Hammond
@@ -128,6 +128,7 @@ files:
128
128
  - Rakefile
129
129
  - VERSION
130
130
  - lib/mage-hand.rb
131
+ - lib/ob_port/client.rb
131
132
  - mage-hand.gemspec
132
133
  - test/helper.rb
133
134
  - test/test_mage-hand.rb