mage-hand 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ 0.5.0
2
+ - Renamed MageHand to MageHandController for the controller include
3
+ - Renamed MageHandController::logged_in? to MageHandController::logged_in_op?
4
+ - Error classes
5
+ - Added MageHandUser to provide common user functionality
6
+ - Updated documentation
7
+ - MOAR Tests
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -0,0 +1,10 @@
1
+ module MageHandUser
2
+ include MageHand
3
+
4
+ def save_op_tokens(access_token_key, access_token_secret)
5
+ self.access_token_key = access_token_key
6
+ self.access_token_secret = access_token_secret
7
+
8
+ save!
9
+ end
10
+ end
@@ -8,6 +8,8 @@ require 'ob_port/campaign'
8
8
  require 'ob_port/wiki_page'
9
9
  require 'ob_port/errors'
10
10
 
11
+ require 'mage-hand-user'
12
+
11
13
  module MageHand
12
14
  def self.set_app_keys(app_key, app_secret)
13
15
  Client.set_app_keys(app_key, app_secret)
@@ -25,8 +27,7 @@ module MageHandController
25
27
  protected
26
28
 
27
29
  def obsidian_portal_login_required
28
- @mage_client = Client.get_client(session[:request_token], session[:access_token_key],
29
- session[:access_token_secret], request.url, params)
30
+ obsidian_portal
30
31
  store_tokens
31
32
  return true if logged_in?
32
33
 
@@ -34,29 +35,19 @@ module MageHandController
34
35
  false
35
36
  end
36
37
 
37
- def logged_in?
38
- @mage_client.logged_in?
38
+ def logged_in_op?
39
+ !!@obsidian_portal && @obsidian_portal.logged_in?
39
40
  end
40
41
 
41
42
  def obsidian_portal
42
- @mage_client
43
+ @obsidian_portal ||= Client.get_client(session[:request_token], session[:access_token_key],
44
+ session[:access_token_secret], request.url, params)
43
45
  end
44
46
 
45
47
  def store_tokens
46
- current_user.save_op_tokens(@mage_client.access_token_key, @mage_client.access_token_secret)
48
+ current_user.save_op_tokens(@mage_client.access_token_key, @mage_client.access_token_secret) if current_user
47
49
  session[:request_token] = @mage_client.request_token
48
50
  session[:access_token_key] = @mage_client.access_token_key
49
51
  session[:access_token_secret] = @mage_client.access_token_secret
50
52
  end
51
53
  end
52
-
53
- module MageHandUser
54
- include MageHand
55
-
56
- def save_op_tokens(access_token_key, access_token_secret)
57
- self.access_token_key = access_token_key
58
- self.access_token_secret = access_token_secret
59
-
60
- save!
61
- end
62
- end
@@ -1,2 +1,4 @@
1
- class OAuthConfigurationError < StandardError
1
+ module MageHand
2
+ class MageHandNotInitialized < StandardError; end
3
+ class OAuthConfigurationError < StandardError; end
2
4
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mage-hand"
8
- s.version = "0.4.1"
8
+ s.version = "0.4.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"]
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.files = [
21
21
  ".document",
22
22
  ".rvmrc",
23
+ "CHANGELOG",
23
24
  "Gemfile",
24
25
  "Gemfile.lock",
25
26
  "LICENSE.txt",
@@ -27,6 +28,7 @@ Gem::Specification.new do |s|
27
28
  "Rakefile",
28
29
  "TODO",
29
30
  "VERSION",
31
+ "lib/mage-hand-user.rb",
30
32
  "lib/mage-hand.rb",
31
33
  "lib/ob_port/base.rb",
32
34
  "lib/ob_port/campaign.rb",
@@ -38,7 +40,9 @@ Gem::Specification.new do |s|
38
40
  "test/helper.rb",
39
41
  "test/test_base.rb",
40
42
  "test/test_campaign.rb",
41
- "test/test_client.rb"
43
+ "test/test_client.rb",
44
+ "test/test_mage_hand_controller.rb",
45
+ "test/test_mage_hand_user.rb"
42
46
  ]
43
47
  s.homepage = "http://github.com/shammond42/mage-hand"
44
48
  s.licenses = ["MIT"]
@@ -6,7 +6,7 @@ class TestClient < Test::Unit::TestCase
6
6
  assert_nothing_raised {MageHand::Client.set_app_keys('asdfasdf','asdfasdfasdfasdfasdf')}
7
7
  end
8
8
  should "raise an exception when the app keys are not set" do
9
- assert_raise(OAuthConfigurationError) do
9
+ assert_raise(MageHand::OAuthConfigurationError) do
10
10
  # @request_token = stub('request token')
11
11
  MageHand::Client.send(:reset_client)
12
12
  MageHand::get_client
@@ -0,0 +1,14 @@
1
+ require 'helper'
2
+
3
+ class TestMageHandUser < Test::Unit::TestCase
4
+ include MageHandController
5
+
6
+ context 'The Mage Hand Controller Module' do
7
+ setup do
8
+
9
+ end
10
+
11
+ should 'be know if the user is logged into obsidian portal' do
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestMageHandUser < Test::Unit::TestCase
4
+ class User
5
+ include MageHandUser
6
+ attr_accessor :access_token_key, :access_token_secret, :saved
7
+ @saved = false
8
+ def save!
9
+ @saved = true
10
+ end
11
+ end
12
+
13
+ context 'The Mage Hand User Module' do
14
+ should 'be able to save op authorization tokens' do
15
+ user = User.new
16
+ assert !user.saved
17
+ user.save_op_tokens('abcdefg', '1234567')
18
+ assert user.saved
19
+ assert_equal 'abcdefg', user.access_token_key
20
+ assert_equal '1234567', user.access_token_secret
21
+ end
22
+ end
23
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mage-hand
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -183,6 +183,7 @@ extra_rdoc_files:
183
183
  files:
184
184
  - .document
185
185
  - .rvmrc
186
+ - CHANGELOG
186
187
  - Gemfile
187
188
  - Gemfile.lock
188
189
  - LICENSE.txt
@@ -190,6 +191,7 @@ files:
190
191
  - Rakefile
191
192
  - TODO
192
193
  - VERSION
194
+ - lib/mage-hand-user.rb
193
195
  - lib/mage-hand.rb
194
196
  - lib/ob_port/base.rb
195
197
  - lib/ob_port/campaign.rb
@@ -202,6 +204,8 @@ files:
202
204
  - test/test_base.rb
203
205
  - test/test_campaign.rb
204
206
  - test/test_client.rb
207
+ - test/test_mage_hand_controller.rb
208
+ - test/test_mage_hand_user.rb
205
209
  homepage: http://github.com/shammond42/mage-hand
206
210
  licenses:
207
211
  - MIT
@@ -217,7 +221,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
217
221
  version: '0'
218
222
  segments:
219
223
  - 0
220
- hash: -2130833917453379504
224
+ hash: 4609764136026977758
221
225
  required_rubygems_version: !ruby/object:Gem::Requirement
222
226
  none: false
223
227
  requirements: