omniauth-untappd 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eaa0bf0ab2a94cb9d65e0a3a2ed7b321d45553f6
4
- data.tar.gz: 9465866f51cc7bb4ccf5d23776e4b8eeb15f7e62
3
+ metadata.gz: c3163d5fb4eb4e058eaa19aec1a5bade542c6fda
4
+ data.tar.gz: 394f945ab90fa2b2d298e63019aa0dc60239ec23
5
5
  SHA512:
6
- metadata.gz: a9a77fe24a68ac2da31379382c5cc89f0b61b69f4b907843048ce3c54090cfd7c526d69ba2dcaad38d81fecf72165962cf54558a30f5918845582296851b5ae5
7
- data.tar.gz: 0ebf49fe5e7341d65f6a66fc795ae982ab31505c03ed72c6537f8155f6eb9637650cf26e45bd706566e14980910ae227138833305cc3b96670f8da0cdc3d458d
6
+ metadata.gz: 78ac968481f9340e4d4eee8d3165c51e15efa4d9805bc76235f937a28285b7ee17c12dcd03a14030aecd8a2c34bc3fe35c665245b959043fbe01a68588fbe4cd
7
+ data.tar.gz: 85d0f9a6c4803201831c3d21471daa66ae1826851cc59560bd1ad2e53e269099b37c52eed7873bc460257ac23ed646f1be87cc4fe199ef18284915c2a7ab7266
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
  # Omniauth::Untappd
2
2
 
3
- [![Build Status](https://travis-ci.org/sabotatore/omniauth-untappd.png)](https://travis-ci.org/sabotatore/omniauth-untappd) [![Code Climate](https://codeclimate.com/github/sabotatore/omniauth-untappd.png)](https://codeclimate.com/github/sabotatore/omniauth-untappd)
4
-
5
3
  Untappd OAuth2 Strategy for OmniAuth.
6
4
 
5
+ [![Gem Version](https://badge.fury.io/rb/omniauth-untappd.png)](http://badge.fury.io/rb/omniauth-untappd) [![Dependency Status](https://gemnasium.com/sabotatore/omniauth-untappd.png)](https://gemnasium.com/sabotatore/omniauth-untappd)
6
+
7
7
  ## Installation
8
8
 
9
9
  Add to your `Gemfile`:
10
10
 
11
- gem 'omniauth-untappd', github: 'sabotatore/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
- [![Build Status](https://travis-ci.org/sabotatore/omniauth-untappd.png)](https://travis-ci.org/sabotatore/omniauth-untappd)
35
+ [![Build Status](https://travis-ci.org/sabotatore/omniauth-untappd.png)](https://travis-ci.org/sabotatore/omniauth-untappd) [![Code Climate](https://codeclimate.com/github/sabotatore/omniauth-untappd.png)](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
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Untappd
3
- VERSION = "0.0.1"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -1,2 +1,3 @@
1
- require "omniauth-untappd/version"
2
- require 'omniauth/strategies/untappd'
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
@@ -6,6 +6,7 @@ require 'rspec'
6
6
  require 'rack/test'
7
7
  require 'webmock/rspec'
8
8
  require 'omniauth'
9
+ require 'oauth2'
9
10
  require 'omniauth-untappd'
10
11
 
11
12
  RSpec.configure do |config|
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.1
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-29 00:00:00.000000000 Z
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