omniauth-dwolla 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ coverage/*
5
+ pkg/*
6
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-dwolla.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # OmniAuth Dwolla
2
+
3
+ Dwolla OAuth2 Strategy for OmniAuth 1.0.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-dwolla'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ `OmniAuth::Strategies::Dwolla` is simply a Rack middleware. Read the OmniAuth 1.0 docs for detailed instructions: https://github.com/intridea/omniauth.
18
+
19
+ Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
20
+
21
+ ```ruby
22
+ Rails.application.config.middleware.use OmniAuth::Builder do
23
+ provider :dwolla, ENV['DWOLLA_KEY'], ENV['DWOLLA_SECRET']
24
+ end
25
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-dwolla/version"
2
+ require "omniauth/strategies/dwolla"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Dwolla
3
+ VERSION = "0.0.11"
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ require 'omniauth-oauth2'
2
+ require 'dwolla'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Dwolla < OmniAuth::Strategies::OAuth2
7
+ DEFAULT_SCOPE = 'send|transactions|balance|request|accountinfofull'
8
+
9
+ option :client_options, {
10
+ :site => 'https://www.dwolla.com',
11
+ :authorize_url => '/oauth/v2/authenticate',
12
+ :token_url => '/oauth/v2/token'
13
+ }
14
+
15
+ uid { raw_info.id }
16
+
17
+ info do
18
+ prune!({
19
+ 'name' => raw_info.name,
20
+ 'latitude' => raw_info.latitude,
21
+ 'longitude' => raw_info.longitude,
22
+ 'city' => raw_info.city,
23
+ 'state' => raw_info.state,
24
+ 'type' => raw_info.type
25
+ })
26
+ end
27
+
28
+ def authorize_params
29
+ super.tap do |params|
30
+ params[:scope] ||= DEFAULT_SCOPE
31
+ end
32
+ end
33
+
34
+ def raw_info
35
+ @raw_info ||= ::Dwolla::User.me(access_token.token).fetch
36
+ end
37
+
38
+ private
39
+
40
+ def prune!(hash)
41
+ hash.delete_if do |_, value|
42
+ prune!(value) if value.is_a?(Hash)
43
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,29 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-dwolla/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-dwolla"
7
+ s.version = Omniauth::Dwolla::VERSION
8
+ s.authors = ["Jefferson Girao"]
9
+ s.email = ["contato@jefferson.eti.br"]
10
+ s.homepage = "https://github.com/jeffersongirao/omniauth-dwolla"
11
+ s.summary = %q{OmniAuth strategy for Dwolla.}
12
+ s.description = %q{OmniAuth strategy for Dwolla.}
13
+
14
+ s.rubyforge_project = "omniauth-dwolla"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'omniauth', '~> 1.0'
22
+ s.add_dependency 'omniauth-oauth2', '~> 1.0'
23
+ s.add_dependency 'dwolla', '>= 0.0.10'
24
+
25
+ s.add_development_dependency 'rake'
26
+ s.add_development_dependency 'rspec', '~> 2.7'
27
+ s.add_development_dependency 'rack-test'
28
+ s.add_development_dependency 'simplecov'
29
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Dwolla do
4
+ subject do
5
+ OmniAuth::Strategies::Dwolla.new(nil, @options || {})
6
+ end
7
+
8
+ it_should_behave_like 'an oauth2 strategy'
9
+
10
+ describe '#client' do
11
+ it 'should have the correct dwolla site' do
12
+ subject.client.site.should eq("https://www.dwolla.com")
13
+ end
14
+
15
+ it 'should have the correct authorization url' do
16
+ subject.client.options[:authorize_url].should eq("/oauth/v2/authenticate")
17
+ end
18
+
19
+ it 'should have the correct token url' do
20
+ subject.client.options[:token_url].should eq('/oauth/v2/token')
21
+ end
22
+ end
23
+
24
+ describe '#authorize_params' do
25
+ it 'includes default scope for email and offline access' do
26
+ subject.authorize_params.should be_a(Hash)
27
+ subject.authorize_params[:scope].should eq('send|transactions|balance|request|accountinfofull')
28
+ end
29
+ end
30
+ end
31
+
@@ -0,0 +1,15 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ SimpleCov.start
5
+ require 'rspec'
6
+ require 'rack/test'
7
+ require 'omniauth'
8
+ require 'omniauth-dwolla'
9
+
10
+ Dir[File.expand_path('../support/**/*', __FILE__)].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
15
+ end
@@ -0,0 +1,40 @@
1
+ # NOTE it would be useful if this lived in omniauth-oauth2 eventually
2
+ # Thanks to Josh Ellithorpe for this file -Will
3
+
4
+ shared_examples 'an oauth2 strategy' do
5
+ describe '#client' do
6
+ it 'should be initialized with symbolized client_options' do
7
+ @options = { :client_options => { 'authorize_url' => 'https://example.com' } }
8
+ subject.client.options[:authorize_url].should == 'https://example.com'
9
+ end
10
+ end
11
+
12
+ describe '#authorize_params' do
13
+ it 'should include any authorize params passed in the :authorize_params option' do
14
+ @options = { :authorize_params => { :foo => 'bar', :baz => 'zip' } }
15
+ subject.authorize_params['foo'].should eq('bar')
16
+ subject.authorize_params['baz'].should eq('zip')
17
+ end
18
+
19
+ it 'should include top-level options that are marked as :authorize_options' do
20
+ @options = { :authorize_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
21
+ subject.authorize_params['scope'].should eq('bar')
22
+ subject.authorize_params['foo'].should eq('baz')
23
+ end
24
+ end
25
+
26
+ describe '#token_params' do
27
+ it 'should include any token params passed in the :token_params option' do
28
+ @options = { :token_params => { :foo => 'bar', :baz => 'zip' } }
29
+ subject.token_params['foo'].should eq('bar')
30
+ subject.token_params['baz'].should eq('zip')
31
+ end
32
+
33
+ it 'should include top-level options that are marked as :token_options' do
34
+ @options = { :token_options => [:scope, :foo], :scope => 'bar', :foo => 'baz' }
35
+ subject.token_params['scope'].should eq('bar')
36
+ subject.token_params['foo'].should eq('baz')
37
+ end
38
+ end
39
+ end
40
+
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-dwolla
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.11
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jefferson Girao
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: &2166954920 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *2166954920
25
+ - !ruby/object:Gem::Dependency
26
+ name: omniauth-oauth2
27
+ requirement: &2166954340 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2166954340
36
+ - !ruby/object:Gem::Dependency
37
+ name: dwolla
38
+ requirement: &2166953820 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.0.10
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *2166953820
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: &2166953280 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *2166953280
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &2166952520 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.7'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *2166952520
69
+ - !ruby/object:Gem::Dependency
70
+ name: rack-test
71
+ requirement: &2166951940 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *2166951940
80
+ - !ruby/object:Gem::Dependency
81
+ name: simplecov
82
+ requirement: &2166951240 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *2166951240
91
+ description: OmniAuth strategy for Dwolla.
92
+ email:
93
+ - contato@jefferson.eti.br
94
+ executables: []
95
+ extensions: []
96
+ extra_rdoc_files: []
97
+ files:
98
+ - .gitignore
99
+ - Gemfile
100
+ - README.md
101
+ - Rakefile
102
+ - lib/omniauth-dwolla.rb
103
+ - lib/omniauth-dwolla/version.rb
104
+ - lib/omniauth/strategies/dwolla.rb
105
+ - omniauth-dwolla.gemspec
106
+ - spec/omniauth/strategies/dwolla_spec.rb
107
+ - spec/spec_helper.rb
108
+ - spec/support/shared_examples.rb
109
+ homepage: https://github.com/jeffersongirao/omniauth-dwolla
110
+ licenses: []
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ segments:
122
+ - 0
123
+ hash: -1117197958278180261
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ segments:
131
+ - 0
132
+ hash: -1117197958278180261
133
+ requirements: []
134
+ rubyforge_project: omniauth-dwolla
135
+ rubygems_version: 1.8.10
136
+ signing_key:
137
+ specification_version: 3
138
+ summary: OmniAuth strategy for Dwolla.
139
+ test_files:
140
+ - spec/omniauth/strategies/dwolla_spec.rb
141
+ - spec/spec_helper.rb
142
+ - spec/support/shared_examples.rb