omniauth-getglue 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,40 @@
1
+ *.gem
2
+ *.rbc
3
+ *.sw[a-p]
4
+ *.tmproj
5
+ *.tmproject
6
+ *.un~
7
+ *~
8
+ .DS_Store
9
+ .Spotlight-V100
10
+ .Trashes
11
+ ._*
12
+ .bundle
13
+ .config
14
+ .directory
15
+ .elc
16
+ .emacs.desktop
17
+ .emacs.desktop.lock
18
+ .redcar
19
+ .yardoc
20
+ Desktop.ini
21
+ Gemfile.lock
22
+ Icon?
23
+ InstalledFiles
24
+ Session.vim
25
+ Thumbs.db
26
+ \#*\#
27
+ _yardoc
28
+ auto-save-list
29
+ coverage
30
+ doc
31
+ lib/bundler/man
32
+ pkg
33
+ pkg/*
34
+ rdoc
35
+ spec/reports
36
+ test/tmp
37
+ test/version_tmp
38
+ tmp
39
+ tmtags
40
+ tramp
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format=nested
3
+ --backtrace
@@ -0,0 +1 @@
1
+ SimpleCov.start
@@ -0,0 +1,3 @@
1
+ --markup markdown
2
+ -
3
+ LICENSE.md
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Jason Barry
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,46 @@
1
+ # OmniAuth GetGlue
2
+
3
+ This gem is an OmniAuth 1.0 Strategy for the [GetGlue API](http://getglue.com/api)
4
+
5
+ ## Usage
6
+
7
+ Add the strategy to your `Gemfile` alongside OmniAuth:
8
+
9
+ ```ruby
10
+ gem 'omniauth'
11
+ gem 'omniauth-getglue'
12
+ ```
13
+
14
+ Then integrate the strategy into your middleware:
15
+
16
+ ```ruby
17
+ use OmniAuth::Builder do
18
+ provider :getglue, ENV['GETGLUE_CONSUMER_KEY_'], ENV['GETGLUE_CONSUMER_SECRET']
19
+ end
20
+ ```
21
+
22
+ In Rails, you'll want to add to the middleware stack:
23
+
24
+ ```ruby
25
+ Rails.application.config.middleware.use OmniAuth::Builder do
26
+ provider :getglue, ENV['GETGLUE_CONSUMER_KEY_'], ENV['GETGLUE_CONSUMER_SECRET']
27
+ end
28
+ ```
29
+
30
+ You will have to put in your consumer key and secret.
31
+
32
+ For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
33
+
34
+ ## Note on Patches/Pull Requests
35
+
36
+ * Fork the project.
37
+ * Make your feature addition or bug fix.
38
+ * Add tests for it. This is important so I don't break it in a
39
+ future version unintentionally.
40
+ * Commit, do not mess with rakefile, version, or history.
41
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
42
+ * Send me a pull request. Bonus points for topic branches.
43
+
44
+ ## Copyright
45
+
46
+ Copyright (c) 2012 Jason Barry. See [LICENSE](https://github.com/jcbarry/omniauth-getglue/blob/master/LICENSE.md) for details.
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require 'bundler'
4
+ Bundler::GemHelper.install_tasks
5
+
6
+ require 'rspec/core/rake_task'
7
+ RSpec::Core::RakeTask.new(:spec)
8
+
9
+ task :default => :spec
10
+ task :test => :spec
11
+
12
+ require 'yard'
13
+ namespace :doc do
14
+ YARD::Rake::YardocTask.new do |task|
15
+ task.files = ['LICENSE.md', 'lib/**/*.rb']
16
+ task.options = ['--markup', 'markdown']
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'multi_json'
5
+ gem 'omniauth-getglue', :path => '../'
@@ -0,0 +1,29 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-getglue'
4
+ require 'pp'
5
+
6
+ ENV['CONSUMER_KEY'] = ''
7
+ ENV['CONSUMER_SECRET'] = ''
8
+
9
+ class App < Sinatra::Base
10
+ get '/' do
11
+ redirect '/auth/getglue'
12
+ end
13
+
14
+ get '/auth/:provider/callback' do
15
+ MultiJson.encode(request.env)
16
+ end
17
+
18
+ get '/auth/failure' do
19
+ MultiJson.encode(request.env)
20
+ end
21
+ end
22
+
23
+ use Rack::Session::Cookie
24
+
25
+ use OmniAuth::Builder do
26
+ provider :getglue, ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET']
27
+ end
28
+
29
+ run App.new
@@ -0,0 +1 @@
1
+ require 'omniauth/getglue'
@@ -0,0 +1 @@
1
+ require 'omniauth/strategies/getglue'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module GetGlue
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ require 'omniauth-oauth'
2
+ require 'nokogiri'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class GetGlue < OmniAuth::Strategies::OAuth
7
+ option :client_options, {
8
+ :site => 'http://api.getglue.com',
9
+ :authorize_url => 'http://getglue.com/oauth/authorize',
10
+ :request_token_url => 'https://api.getglue.com/oauth/request_token',
11
+ :access_token_url => 'https://api.getglue.com/oauth/access_token'
12
+ }
13
+
14
+ uid { username }
15
+
16
+ info do
17
+ {
18
+ 'uid' => username,
19
+ 'name' => display_name
20
+ }
21
+ end
22
+
23
+ extra do
24
+ { 'raw_info' => 'raw_info' }
25
+ end
26
+
27
+ def username
28
+ raw_info.xpath("/adaptiveblue/response/profile/username").inner_text
29
+ end
30
+
31
+ def display_name
32
+ raw_info.xpath("/adaptiveblue/response/profile/displayName").inner_text
33
+ end
34
+
35
+ def raw_info
36
+ @raw_info ||= Nokogiri::XML(access_token.get('http://api.getglue.com/v2/user/profile').body)
37
+ end
38
+ end
39
+ end
40
+ end
41
+
42
+ OmniAuth.config.add_camelization 'getglue', 'GetGlue'
@@ -0,0 +1,29 @@
1
+ # encoding: utf-8
2
+ require File.expand_path('../lib/omniauth/getglue/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'omniauth-getglue'
6
+ gem.version = OmniAuth::GetGlue::VERSION
7
+ gem.homepage = 'https://github.com/jcbarry/omniauth-getglue'
8
+
9
+ gem.author = 'Jason Barry'
10
+ gem.email = 'jay@jcbarry.com'
11
+ gem.description = 'GetGlue strategy for OmniAuth 1.0'
12
+ gem.summary = gem.description
13
+
14
+ gem.add_dependency "omniauth-oauth", "~> 1.0"
15
+ gem.add_dependency "nokogiri", "~> 1.5.0"
16
+
17
+ gem.add_development_dependency 'rake', '~> 0.9'
18
+ gem.add_development_dependency 'rdiscount', '~> 1.6'
19
+ gem.add_development_dependency 'rspec', '~> 2.7'
20
+ gem.add_development_dependency 'simplecov', '~> 0.5'
21
+ gem.add_development_dependency 'yard', '~> 0.7'
22
+ gem.add_development_dependency 'webmock', '~> 1.7'
23
+
24
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
25
+ gem.files = `git ls-files`.split("\n")
26
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
27
+
28
+ gem.require_paths = ['lib']
29
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'OmniAuth::Strategies::GetGlue Integration' do
4
+ pending 'write some tests yo'
5
+ end
@@ -0,0 +1,67 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::GetGlue do
4
+ before :each do
5
+ @request = double('Request')
6
+ @request.stub(:params) { {} }
7
+ end
8
+
9
+ subject do
10
+ OmniAuth::Strategies::GetGlue.new(nil, @options || {}).tap do |strategy|
11
+ strategy.stub(:request) { @request }
12
+ end
13
+ end
14
+
15
+ describe '#client_options' do
16
+ it 'has correct GetGlue site' do
17
+ subject.options.client_options.site.should eq('http://api.getglue.com')
18
+ end
19
+
20
+ it 'has correct authorize url' do
21
+ subject.options.client_options.authorize_url.should eq('http://getglue.com/oauth/authorize')
22
+ end
23
+
24
+ it 'has correct request token url' do
25
+ subject.options.client_options.request_token_url.should eq('https://api.getglue.com/oauth/request_token')
26
+ end
27
+
28
+ it 'has correct access token url' do
29
+ subject.options.client_options.access_token_url.should eq('https://api.getglue.com/oauth/access_token')
30
+ end
31
+ end
32
+
33
+ describe '#uid' do
34
+ it 'returns the uid from raw_info' do
35
+ subject.stub(:username) { 'hjsimpson' }
36
+ subject.uid.should eq('hjsimpson')
37
+ end
38
+ end
39
+
40
+ describe '#info' do
41
+ before :each do
42
+ subject.stub(:username) { 'hjsimpson' }
43
+ subject.stub(:display_name) { 'Homer J. Simpson' }
44
+ end
45
+
46
+ context 'when data is present in raw info' do
47
+ it 'returns the name' do
48
+ subject.info['uid'].should eq('hjsimpson')
49
+ end
50
+
51
+ it 'returns the email' do
52
+ subject.info['name'].should eq('Homer J. Simpson')
53
+ end
54
+ end
55
+ end
56
+
57
+ describe '#extra' do
58
+ before :each do
59
+ @raw_info_hash = { "profile" => [] }
60
+ subject.stub(:raw_info) { @raw_info_hash }
61
+ end
62
+
63
+ it 'returns a Hash' do
64
+ subject.extra.should be_a(Hash)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'simplecov'
4
+ require 'omniauth-getglue'
5
+ require 'rspec'
6
+ require 'webmock/rspec'
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-getglue
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Jason Barry
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-02-24 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70145289076860 !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: *70145289076860
25
+ - !ruby/object:Gem::Dependency
26
+ name: nokogiri
27
+ requirement: &70145289076360 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.5.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70145289076360
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70145289075840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70145289075840
47
+ - !ruby/object:Gem::Dependency
48
+ name: rdiscount
49
+ requirement: &70145289075360 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70145289075360
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70145289074720 !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: *70145289074720
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: &70145289074100 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '0.5'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70145289074100
80
+ - !ruby/object:Gem::Dependency
81
+ name: yard
82
+ requirement: &70145289073160 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: '0.7'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70145289073160
91
+ - !ruby/object:Gem::Dependency
92
+ name: webmock
93
+ requirement: &70145289072680 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ~>
97
+ - !ruby/object:Gem::Version
98
+ version: '1.7'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70145289072680
102
+ description: GetGlue strategy for OmniAuth 1.0
103
+ email: jay@jcbarry.com
104
+ executables: []
105
+ extensions: []
106
+ extra_rdoc_files: []
107
+ files:
108
+ - .gemtest
109
+ - .gitignore
110
+ - .rspec
111
+ - .simplecov
112
+ - .yardopts
113
+ - Gemfile
114
+ - LICENSE.md
115
+ - README.md
116
+ - Rakefile
117
+ - example/Gemfile
118
+ - example/config.ru
119
+ - lib/omniauth-getglue.rb
120
+ - lib/omniauth/getglue.rb
121
+ - lib/omniauth/getglue/version.rb
122
+ - lib/omniauth/strategies/getglue.rb
123
+ - omniauth-getglue.gemspec
124
+ - spec/integration_spec.rb
125
+ - spec/omniauth/strategies/getglue_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: https://github.com/jcbarry/omniauth-getglue
128
+ licenses: []
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ! '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ requirements: []
146
+ rubyforge_project:
147
+ rubygems_version: 1.8.10
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: GetGlue strategy for OmniAuth 1.0
151
+ test_files:
152
+ - spec/integration_spec.rb
153
+ - spec/omniauth/strategies/getglue_spec.rb
154
+ - spec/spec_helper.rb
155
+ has_rdoc: