omniauth-untappd 0.0.1 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/oauth2/untappd_client.rb +22 -0
- data/lib/omniauth/strategies/untappd.rb +0 -12
- data/lib/omniauth-untappd/version.rb +1 -1
- data/lib/omniauth-untappd.rb +3 -2
- data/spec/oauth2/untappd_client_spec.rb +25 -0
- data/spec/spec_helper.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3163d5fb4eb4e058eaa19aec1a5bade542c6fda
|
4
|
+
data.tar.gz: 394f945ab90fa2b2d298e63019aa0dc60239ec23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78ac968481f9340e4d4eee8d3165c51e15efa4d9805bc76235f937a28285b7ee17c12dcd03a14030aecd8a2c34bc3fe35c665245b959043fbe01a68588fbe4cd
|
7
|
+
data.tar.gz: 85d0f9a6c4803201831c3d21471daa66ae1826851cc59560bd1ad2e53e269099b37c52eed7873bc460257ac23ed646f1be87cc4fe199ef18284915c2a7ab7266
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Omniauth::Untappd
|
2
2
|
|
3
|
-
[](https://travis-ci.org/sabotatore/omniauth-untappd) [](https://codeclimate.com/github/sabotatore/omniauth-untappd)
|
4
|
-
|
5
3
|
Untappd OAuth2 Strategy for OmniAuth.
|
6
4
|
|
5
|
+
[](http://badge.fury.io/rb/omniauth-untappd) [](https://gemnasium.com/sabotatore/omniauth-untappd)
|
6
|
+
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Add to your `Gemfile`:
|
10
10
|
|
11
|
-
gem 'omniauth-untappd'
|
11
|
+
gem 'omniauth-untappd'
|
12
12
|
|
13
13
|
And then execute:
|
14
14
|
|
@@ -32,7 +32,7 @@ See more details on the omniauth module: https://github.com/intridea/omniauth#re
|
|
32
32
|
|
33
33
|
OmniAuth Untappd is tested under 1.9.2, 1.9.3 and 2.0.0
|
34
34
|
|
35
|
-
[](https://travis-ci.org/sabotatore/omniauth-untappd)
|
35
|
+
[](https://travis-ci.org/sabotatore/omniauth-untappd) [](https://codeclimate.com/github/sabotatore/omniauth-untappd)
|
36
36
|
|
37
37
|
## License
|
38
38
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module OAuth2
|
2
|
+
class UntappdClient < OAuth2::Client
|
3
|
+
def get_token(params, access_token_opts = {}, access_token_class = AccessToken)
|
4
|
+
response = request(options[:token_method], token_url, request_token_opts(params))
|
5
|
+
access_token_class.new(self, parse_token(response), access_token_opts)
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def parse_token(response)
|
11
|
+
access_token = response.parsed.is_a?(Hash) && response.parsed['response']['access_token']
|
12
|
+
raise Error.new(response) if options[:raise_errors] && !access_token
|
13
|
+
access_token
|
14
|
+
end
|
15
|
+
|
16
|
+
def request_token_opts(params)
|
17
|
+
{ raise_errors: options[:raise_errors],
|
18
|
+
parse: params.delete(:parse),
|
19
|
+
params: params }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -66,15 +66,3 @@ module OmniAuth
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
70
|
-
module OAuth2
|
71
|
-
class UntappdClient < OAuth2::Client
|
72
|
-
def get_token(params, access_token_opts={}, access_token_class = AccessToken)
|
73
|
-
opts = { raise_errors: options[:raise_errors], parse: params.delete(:parse), params: params }
|
74
|
-
response = request(options[:token_method], token_url, opts)
|
75
|
-
untappd_response = response.parsed['response']
|
76
|
-
raise Error.new(response) if options[:raise_errors] && !(untappd_response.is_a?(Hash) && untappd_response['access_token'])
|
77
|
-
access_token_class.from_hash(self, untappd_response.merge(access_token_opts))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
data/lib/omniauth-untappd.rb
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require '
|
1
|
+
require 'omniauth-untappd/version'
|
2
|
+
require 'oauth2/untappd_client'
|
3
|
+
require 'omniauth/strategies/untappd'
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OAuth2::UntappdClient do
|
4
|
+
subject(:client) { OAuth2::UntappdClient.new('abc', 'def') }
|
5
|
+
|
6
|
+
context '#get_token' do
|
7
|
+
subject { client.get_token({}) }
|
8
|
+
let(:response) { double('Response', parsed: parsed_response, body: parsed_response) }
|
9
|
+
|
10
|
+
before { client.stub(request: response) }
|
11
|
+
|
12
|
+
context 'correct response' do
|
13
|
+
let(:parsed_response) {{ 'response' => { 'access_token' => 'ACCESSTOKEN' }}}
|
14
|
+
|
15
|
+
its(:token) { should eql 'ACCESSTOKEN' }
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'incorrect response' do
|
19
|
+
let(:parsed_response) { 'unknown error' }
|
20
|
+
before { response.should_receive(:error=) }
|
21
|
+
|
22
|
+
it { expect { subject }.to raise_error(OAuth2::Error, parsed_response) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-untappd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitali Kulikou
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -122,10 +122,12 @@ files:
|
|
122
122
|
- LICENSE
|
123
123
|
- README.md
|
124
124
|
- Rakefile
|
125
|
+
- lib/oauth2/untappd_client.rb
|
125
126
|
- lib/omniauth-untappd.rb
|
126
127
|
- lib/omniauth-untappd/version.rb
|
127
128
|
- lib/omniauth/strategies/untappd.rb
|
128
129
|
- omniauth-untappd.gemspec
|
130
|
+
- spec/oauth2/untappd_client_spec.rb
|
129
131
|
- spec/omniauth/strategies/untappd_spec.rb
|
130
132
|
- spec/spec_helper.rb
|
131
133
|
homepage: https://github.com/sabotatore/omniauth-untappd
|