omniauth-tradegecko 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ .yardoc
5
+ coverage
6
+ doc/
7
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 TradeGecko Pte Ltd
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,16 @@
1
+ # Omniauth::TradeGecko
2
+
3
+ This is the TradeGecko strategy for authenticating to TradeGecko via OmniAuth.
4
+ For more information about the TradeGecko API check out [http://tradegecko.com/apps/api](http://tradegecko.com/apps/api)
5
+
6
+ ## Usage
7
+ In `config/initializers/tradegecko.rb`
8
+
9
+ ```ruby
10
+ use OmniAuth::Builder do
11
+ provider :tradegecko, ENV['TRADEGECKO_ID'], ENV['TRADEGECKO_SECRET']
12
+ end
13
+ ```
14
+
15
+ ## Questions
16
+ Contact me at [bradleypriest@gmail.com](mailto:bradleypriest@gmail.com) or [@bradleypriest](http://twitter.com/bradleypriest)
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new
6
+
7
+ desc 'Default: run specs.'
8
+ task :default => :spec
@@ -0,0 +1,30 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class TradeGecko < OmniAuth::Strategies::OAuth2
6
+ option :name, :tradegecko
7
+
8
+ option :client_options, {
9
+ site: "https://api.tradegecko.com",
10
+ authorize_path: "/oauth/authorize"
11
+ }
12
+
13
+ uid { raw_info["id"] }
14
+
15
+ info do
16
+ {
17
+ first_name: raw_info["first_name"],
18
+ last_name: raw_info["last_name"],
19
+ email: raw_info["email"]
20
+ }
21
+ end
22
+
23
+ def raw_info
24
+ @raw_info ||= access_token.get('/users/current').parsed
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ OmniAuth.config.add_camelization 'tradegecko', 'TradeGecko'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module TradeGecko
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ require "omniauth-tradegecko/version"
2
+ require 'omniauth/strategies/tradegecko'
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-tradegecko/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Bradley Priest"]
6
+ gem.email = ["bradley@tradegecko.com"]
7
+ gem.description = %q{Omniauth strategy for TradeGecko}
8
+ gem.summary = %q{Omniauth strategy for TradeGecko}
9
+ gem.homepage = "https://github.com/tradegecko/omniauth-tradegecko"
10
+
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "omniauth-tradegecko"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Omniauth::TradeGecko::VERSION
16
+
17
+ gem.add_dependency 'omniauth', '~> 1.0'
18
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
19
+ gem.add_development_dependency 'rspec', '~> 2.7'
20
+ gem.add_development_dependency 'rack-test'
21
+ gem.add_development_dependency 'simplecov'
22
+ gem.add_development_dependency 'webmock'
23
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::TradeGecko do
4
+ let(:strategy) do
5
+ OmniAuth::Strategies::TradeGecko.new({})
6
+ end
7
+ context :options do
8
+ subject { strategy.options }
9
+ its(:name) { should eql :tradegecko }
10
+ end
11
+
12
+ context :client_options do
13
+ subject { strategy.options.client_options }
14
+ its(:site) { should eql "https://api.tradegecko.com" }
15
+ its(:authorize_path) { should eql "/oauth/authorize" }
16
+ end
17
+
18
+ context :raw_info do
19
+ before do
20
+ strategy.stub(:raw_info) do
21
+ {
22
+ "first_name" => "Invader",
23
+ "last_name" => "Zim",
24
+ "email" => "invaderzim@example.com"
25
+ }
26
+ end
27
+ end
28
+ it "exposes user info" do
29
+ strategy.info.should eql({
30
+ first_name: "Invader",
31
+ last_name: "Zim",
32
+ email: "invaderzim@example.com"
33
+ })
34
+ end
35
+ end
36
+ end
@@ -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 'webmock/rspec'
8
+ require 'omniauth'
9
+ require 'omniauth-tradegecko'
10
+
11
+ RSpec.configure do |config|
12
+ config.include WebMock::API
13
+ config.include Rack::Test::Methods
14
+ config.extend OmniAuth::Test::StrategyMacros, type: :strategy
15
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-tradegecko
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bradley Priest
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-04-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth
16
+ requirement: !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: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: simplecov
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Omniauth strategy for TradeGecko
111
+ email:
112
+ - bradley@tradegecko.com
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - LICENSE
120
+ - README.md
121
+ - Rakefile
122
+ - lib/omniauth-tradegecko.rb
123
+ - lib/omniauth-tradegecko/version.rb
124
+ - lib/omniauth/strategies/tradegecko.rb
125
+ - omniauth-tradegecko.gemspec
126
+ - spec/omniauth/strategies/tradegecko_spec.rb
127
+ - spec/spec_helper.rb
128
+ homepage: https://github.com/tradegecko/omniauth-tradegecko
129
+ licenses: []
130
+ post_install_message:
131
+ rdoc_options: []
132
+ require_paths:
133
+ - lib
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ none: false
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ required_rubygems_version: !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ! '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project:
148
+ rubygems_version: 1.8.23
149
+ signing_key:
150
+ specification_version: 3
151
+ summary: Omniauth strategy for TradeGecko
152
+ test_files:
153
+ - spec/omniauth/strategies/tradegecko_spec.rb
154
+ - spec/spec_helper.rb
155
+ has_rdoc: