omniauth-namba 0.0.1 → 1.0.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 +5 -3
- data/lib/omniauth-namba/version.rb +1 -1
- data/lib/omniauth/strategies/namba.rb +9 -1
- data/spec/omniauth/strategies/namba_spec.rb +11 -5
- metadata +12 -12
data/README.md
CHANGED
@@ -12,21 +12,23 @@ Add the strategy to your `Gemfile`:
|
|
12
12
|
For a Rails application you'd now create an initializer `config/initializers/omniauth.rb`:
|
13
13
|
|
14
14
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
15
|
-
provider :namba, 'key', 'secret'
|
15
|
+
provider :namba, 'key', 'secret', locale: "kg"
|
16
16
|
end
|
17
17
|
|
18
18
|
Or for a Rack application:
|
19
19
|
|
20
20
|
use OmniAuth::Builder do
|
21
|
-
provider :namba, "key", "secret"
|
21
|
+
provider :namba, "key", "secret", locale: "kg"
|
22
22
|
end
|
23
23
|
|
24
24
|
If you use omniauth with Devise just add configuration to `devise.rb` initializer:
|
25
25
|
|
26
26
|
Devise.setup do |config|
|
27
|
-
config.omniauth :namba, "key", "secret"
|
27
|
+
config.omniauth :namba, "key", "secret", locale: "kg"
|
28
28
|
end
|
29
29
|
|
30
|
+
Use `:net` locale if you want to access [namba.net][] API. `"kg"` is the default locale so you can simply use `provider :namba, "key", "secret"`
|
31
|
+
|
30
32
|
## Auth hash
|
31
33
|
|
32
34
|
{
|
@@ -8,6 +8,7 @@ module OmniAuth
|
|
8
8
|
|
9
9
|
option :name, "namba"
|
10
10
|
option :client_options, {
|
11
|
+
:locale => "kg",
|
11
12
|
:site => "http://api.namba.kg",
|
12
13
|
:request_token_path => "/oauth/request_token.php",
|
13
14
|
:authorize_url => "http://login.namba.kg/login2.php",
|
@@ -36,8 +37,15 @@ module OmniAuth
|
|
36
37
|
}
|
37
38
|
end
|
38
39
|
|
40
|
+
def initialize app, *args, &block
|
41
|
+
super
|
42
|
+
raise ArgumentError.new("Available locales are only kg or net") if options.locale && !%w(kg net).include?(options.locale)
|
43
|
+
options.client_options.site = "http://api.namba.#{options.locale || 'kg'}"
|
44
|
+
options.client_options.authorize_url = "http://login.namba.#{options.locale || 'kg'}/login2.php"
|
45
|
+
end
|
46
|
+
|
39
47
|
def raw_info
|
40
|
-
@raw_info ||= MultiJson.load(access_token.get(
|
48
|
+
@raw_info ||= MultiJson.load(access_token.get("http://api.namba.#{options.locale || 'kg'}/getUserInfo2.php").body)
|
41
49
|
rescue ::Errno::ETIMEDOUT
|
42
50
|
raise ::Timeout::Error
|
43
51
|
end
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe "OmniAuth Namba" do
|
4
4
|
subject do
|
5
|
-
OmniAuth::Strategies::Namba.new(nil,
|
5
|
+
OmniAuth::Strategies::Namba.new(nil, { :locale => "kg" })
|
6
6
|
end
|
7
7
|
|
8
8
|
it 'should add a camelization for itself' do
|
@@ -10,18 +10,24 @@ describe "OmniAuth Namba" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should has correct Namba site' do
|
13
|
-
subject.options.client_options.site.should eq(
|
13
|
+
subject.options.client_options.site.should eq("http://api.namba.#{subject.options.locale}")
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should has correct request token path' do
|
17
|
-
subject.options.client_options.request_token_path.should eq(
|
17
|
+
subject.options.client_options.request_token_path.should eq("/oauth/request_token.php")
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should has correct access token path' do
|
21
|
-
subject.options.client_options.access_token_path.should eq(
|
21
|
+
subject.options.client_options.access_token_path.should eq("/oauth/access_token.php")
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should has correct authorize url' do
|
25
|
-
subject.options.client_options.authorize_url.should eq(
|
25
|
+
subject.options.client_options.authorize_url.should eq("http://login.namba.#{subject.options.locale}/login2.php")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should not allow add locales except kg or kz' do
|
29
|
+
expect {
|
30
|
+
OmniAuth::Strategies::Namba.new(nil, { :locale => "za" })
|
31
|
+
}.to raise_error(ArgumentError, "Available locales are only kg or net")
|
26
32
|
end
|
27
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-namba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2013-02-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: omniauth-oauth
|
17
|
-
requirement: &
|
17
|
+
requirement: &82856400 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *82856400
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &82856150 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 2.7.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *82856150
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: rake
|
39
|
-
requirement: &
|
39
|
+
requirement: &82855960 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *82855960
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: webmock
|
50
|
-
requirement: &
|
50
|
+
requirement: &82855730 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *82855730
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rack-test
|
61
|
-
requirement: &
|
61
|
+
requirement: &82855520 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *82855520
|
70
70
|
description: Authenticate to Namba using OAuth.
|
71
71
|
email:
|
72
72
|
- sergey.kishenin@gmail.com
|