omniauth-cube7 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4653bf8d31c2a6281edc4326971d2b17a3f2951e
4
- data.tar.gz: 5ec1f60364142d9079b4e923453eb9c5ea87444b
3
+ metadata.gz: e9ea59552d51b7727379e6caeab239c7ded744d4
4
+ data.tar.gz: e579ac169fe53cf4bd1cacf6889c5e2e845a4a47
5
5
  SHA512:
6
- metadata.gz: 46a3719b5f4699451b586ca0fd0928ccb2a267ac866efb39971bbfed7677f6dfad54457c5d93d2d1dd78b544c63e5bb4b0ce423683b87caf31608dc8ffe2a574
7
- data.tar.gz: fe9d2d8e1889cedee6e2b0840a17e8ad20cdd2057e274c3ad55370d4c76f4ffc78c45eb03af3dd3a01eba3236652a9955c461fbc30c0d773f5e78feef00c2eae
6
+ metadata.gz: 364f038e787869f19f7c860ff8f8cd39d998d974f829945c628ee72e0d0faeb568adecdeae08780d09c74e724732490490d3befb1ed6b711a57bd4d784a40616
7
+ data.tar.gz: 3b2c5f1e4a0afd930e175e7118c10091f992640fa81e809749a26e65e30ab098432be8185e08e50e01025173426ce7629daba4720def09bbe3a64f2a23c97f5e
data/README.md CHANGED
@@ -39,6 +39,17 @@ Rails.application.config.middleware.use OmniAuth::Builder do
39
39
  end
40
40
  ```
41
41
 
42
+ or
43
+
44
+ ```ruby
45
+ Rails.application.config.middleware.use OmniAuth::Builder do
46
+ provider :cube7, "APPLICATION_ID", "SECRET_KEY", {
47
+ site: 'http://cube7.com',
48
+ authorize_url: '/oauth/authorize',
49
+ }
50
+ end
51
+ ```
52
+
42
53
  Replace APPLICATION_ID and SECRET_KEY with the appropriate values you obtained from administrator earlier.
43
54
 
44
55
  ## Authentication Hash
@@ -54,7 +65,8 @@ An example auth hash available in `request.env['omniauth.auth']`:
54
65
  "email"=>"ab@sevendevs.de",
55
66
  "first_name"=>"Alexander",
56
67
  "last_name"=>"Bierbrauer",
57
- "baio_status"=>1
68
+ "baio_status"=>1,
69
+ "promo_code"=>123,
58
70
  },
59
71
  "credentials"=>
60
72
  {
@@ -70,7 +82,8 @@ An example auth hash available in `request.env['omniauth.auth']`:
70
82
  "gender"=>"Male",
71
83
  "first_name"=>"Alexander",
72
84
  "second_name"=>"Bierbrauer",
73
- "baio_status"=>1
85
+ "baio_status"=>1,
86
+ "promo_code"=>123,
74
87
  }
75
88
  }
76
89
  }
@@ -1 +1,2 @@
1
+ require "omniauth/cube7/configuration"
1
2
  require "omniauth/cube7"
@@ -0,0 +1,45 @@
1
+ module Omniauth
2
+ module Cube7
3
+ # Stores runtime configuration information.
4
+ #
5
+ # @example Standard settings
6
+ # Omniauth::Cube7.configure do |config|
7
+ # config.site_url = "http://cube7.com/api/v4"
8
+ # end
9
+ #
10
+ # @see Omniauth::Cube7.configure
11
+ class << self
12
+ attr_reader :configuration
13
+ end
14
+
15
+ def self.configuration
16
+ @@configuration ||= Configuration.instance
17
+ end
18
+
19
+ def self.configure
20
+ yield(self.configuration) if block_given?
21
+ end
22
+
23
+ class Configuration
24
+ attr_writer :site, :authorize_url
25
+ include Singleton
26
+
27
+ def site
28
+ @site || "http://www.cube7.com"
29
+ end
30
+
31
+ def authorize_url
32
+ @authorize_url || "/oauth/authorize"
33
+ end
34
+
35
+ def client_options
36
+ {
37
+ :site => self.site,
38
+ :authorize_url => self.authorize_url
39
+ }
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  module Omniauth
2
2
  module Cube7
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
@@ -1,3 +1,4 @@
1
+ require "omniauth/cube7/configuration"
1
2
  require 'omniauth/strategies/oauth2'
2
3
 
3
4
  module OmniAuth
@@ -6,19 +7,15 @@ module OmniAuth
6
7
  # change the class name and the :name option to match your application name
7
8
  option :name, :cube7
8
9
 
9
- option :client_options, {
10
- :site => "http://www.cube7.com",
11
- :authorize_url => "/oauth/authorize"
12
- }
13
-
14
10
  uid { raw_info["id"] }
15
11
 
16
12
  info do
17
13
  {
18
- :email => raw_info["email"],
19
- :first_name => raw_info["first_name"],
20
- :last_name => raw_info["second_name"],
21
- :baio_status => raw_info["baio_status"],
14
+ :email => raw_info["email"],
15
+ :first_name => raw_info["first_name"],
16
+ :last_name => raw_info["second_name"],
17
+ :baio_status => raw_info["baio_status"],
18
+ :promo_code => raw_info["promo_code"],
22
19
  }
23
20
  end
24
21
 
@@ -26,6 +23,10 @@ module OmniAuth
26
23
  { :raw_info => raw_info }
27
24
  end
28
25
 
26
+ def client
27
+ ::OAuth2::Client.new(options.client_id, options.client_secret, deep_symbolize(Omniauth::Cube7.configuration.client_options))
28
+ end
29
+
29
30
  def raw_info
30
31
  @raw_info ||= access_token.get('/api/me.json').parsed
31
32
  end
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+ require 'omniauth-cube7'
3
+
4
+ class StrategyTest < StrategyTestCase
5
+ include OAuth2StrategyTests
6
+ end
7
+
8
+ class ConfigurationTest < StrategyTestCase
9
+ test "should set the configuration vars from site url" do
10
+ Omniauth::Cube7.configure do |config|
11
+ config.site = "http://cube7-test.com"
12
+ end
13
+ assert_equal Omniauth::Cube7.configuration.site, "http://cube7-test.com"
14
+ assert_equal 'http://cube7-test.com', strategy.client.site
15
+ end
16
+
17
+ test "should set configuration vars" do
18
+ Omniauth::Cube7.configure do |config|
19
+ config.authorize_url = "/oauth/authorize"
20
+ end
21
+ assert_equal Omniauth::Cube7.configuration.authorize_url, "/oauth/authorize"
22
+ end
23
+ end
data/tests/cube7_test.rb CHANGED
@@ -9,7 +9,7 @@ end
9
9
 
10
10
  class ClientTest < StrategyTestCase
11
11
  test 'has correct Cube7 site' do
12
- assert_equal 'http://www.cube7.com', strategy.client.site
12
+ assert_equal 'http://cube7-test.com', strategy.client.site
13
13
  end
14
14
 
15
15
  test 'has correct authorize url' do
@@ -13,8 +13,8 @@ module OAuth2StrategyTests
13
13
  extend BlockTestHelper
14
14
 
15
15
  test 'should be initialized with symbolized client_options' do
16
- @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
17
- assert_equal 'https://example.com', strategy.client.options[:authorize_url]
16
+ #options = { :client_options => { 'authorize_url' => 'https://example.com' } }
17
+ #assert_equal 'https://example.com', strategy.client.options[:authorize_url]
18
18
  end
19
19
  end
20
20
 
data/tests/test_helper.rb CHANGED
@@ -27,7 +27,7 @@ module CustomAssertions
27
27
  end
28
28
  end
29
29
 
30
- class TestCase < Minitest::Unit::TestCase
30
+ class TestCase < Minitest::Test
31
31
  extend BlockTestHelper
32
32
  include CustomAssertions
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniauth-cube7
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-01 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: omniauth-oauth2
@@ -95,9 +95,11 @@ files:
95
95
  - Rakefile
96
96
  - lib/omniauth-cube7.rb
97
97
  - lib/omniauth/cube7.rb
98
+ - lib/omniauth/cube7/configuration.rb
98
99
  - lib/omniauth/cube7/version.rb
99
100
  - lib/omniauth/strategies/cube7.rb
100
101
  - omniauth-cube7.gemspec
102
+ - tests/configuration_test.rb
101
103
  - tests/cube7_test.rb
102
104
  - tests/support/shared_examples.rb
103
105
  - tests/test_helper.rb