omniauth-klout 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in omniauth-klout.gemspec
4
+ gemspec
@@ -0,0 +1,38 @@
1
+ # OmniAuth Klout
2
+
3
+ An OmniAuth strategy for Klout
4
+
5
+ ## Warning - Noob alert
6
+
7
+ While this works, this is brand new and relatively untested in the real world. (Also my first omniauth strategy)
8
+ Klout's 'OAuth2' API doesn't actually follow the spec, which makes things a bit more fun!
9
+
10
+ ## Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ gem 'omniauth-klout'
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install omniauth-klout
23
+
24
+ ## Basic Usage
25
+
26
+ use OmniAuth::Builder do
27
+ provider :klout, ENV['KLOUT_KEY'], ENV['KLOUT_SECRET']
28
+ end
29
+
30
+ ## License
31
+
32
+ © Alex Heeton & Enthuse.me
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
35
+
36
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
37
+
38
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-klout/version"
2
+ require "omniauth/strategies/klout"
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Klout
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Klout
6
+ include OmniAuth::Strategy
7
+ SITE = 'https://api.klout.com'
8
+ AUTHORIZE_URL = 'https://api.klout.com/v2/oauth/'
9
+
10
+ def initialize(app, api_key, api_secret)
11
+ @api_key = api_key
12
+ @api_secret = api_secret
13
+ super(app)
14
+ end
15
+
16
+ def request_phase
17
+ redirect request_url
18
+ end
19
+
20
+ uid { request.params['user'] }
21
+ info do
22
+ {
23
+ authCode: request.params['authCode'],
24
+ }
25
+ end
26
+
27
+ private
28
+ def request_url
29
+ "#{AUTHORIZE_URL}?apiKey=#{@api_key}&redirect=#{callback_url}"
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'omniauth-klout/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "omniauth-klout"
8
+ gem.version = Omniauth::Klout::VERSION
9
+ gem.authors = ["Alex Heeton"]
10
+ gem.email = ["Alex@Heeton.me"]
11
+ gem.description = %q{An OmniAuth strategy for Klout}
12
+ gem.summary = %q{An OmniAuth strategy for Klout}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'omniauth', '~> 1.0'
21
+ gem.add_development_dependency 'rspec', '~> 2.7'
22
+ gem.add_development_dependency 'rack-test'
23
+ gem.add_development_dependency 'simplecov'
24
+ gem.add_development_dependency 'webmock'
25
+
26
+ end
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Klout do
4
+ subject do
5
+ OmniAuth::Strategies::Klout.new(double, 'api_key', 'api_secret')
6
+ end
7
+
8
+ describe "#request_phase" do
9
+ it "redirects to a request URL" do
10
+ subject.should_receive(:request_url)
11
+ subject.request_phase
12
+ end
13
+ end
14
+
15
+ 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-klout'
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,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-klout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Heeton
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-24 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: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '2.7'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rack-test
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
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: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: simplecov
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: webmock
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
+ description: An OmniAuth strategy for Klout
95
+ email:
96
+ - Alex@Heeton.me
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - Gemfile
103
+ - README.md
104
+ - Rakefile
105
+ - lib/omniauth-klout.rb
106
+ - lib/omniauth-klout/version.rb
107
+ - lib/omniauth/strategies/klout.rb
108
+ - omniauth-klout.gemspec
109
+ - spec/omniauth/strategies/klout_spec.rb
110
+ - spec/spec_helper.rb
111
+ homepage: ''
112
+ licenses: []
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ none: false
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubyforge_project:
131
+ rubygems_version: 1.8.24
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: An OmniAuth strategy for Klout
135
+ test_files:
136
+ - spec/omniauth/strategies/klout_spec.rb
137
+ - spec/spec_helper.rb