omniauth-viadeo 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=progress
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.2@oviadeo
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem 'omniauth-oauth2'
6
+
7
+ group :development, :test do
8
+ gem 'guard'
9
+ gem 'guard-rspec'
10
+ gem 'guard-bundler'
11
+ gem 'growl'
12
+ gem 'rb-fsevent'
13
+ gem 'multi_json'
14
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,72 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ omniauth-viadeo (0.0.1)
5
+ omniauth-oauth2 (~> 1.0.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ addressable (2.2.6)
11
+ crack (0.3.1)
12
+ diff-lcs (1.1.3)
13
+ faraday (0.7.6)
14
+ addressable (~> 2.2)
15
+ multipart-post (~> 1.1)
16
+ rack (~> 1.1)
17
+ ffi (1.0.11)
18
+ growl (1.0.3)
19
+ guard (1.0.0)
20
+ ffi (>= 0.5.0)
21
+ thor (~> 0.14.6)
22
+ guard-bundler (0.1.3)
23
+ bundler (>= 1.0.0)
24
+ guard (>= 0.2.2)
25
+ guard-rspec (0.6.0)
26
+ guard (>= 0.10.0)
27
+ hashie (1.2.0)
28
+ multi_json (1.0.4)
29
+ multipart-post (1.1.4)
30
+ oauth2 (0.5.2)
31
+ faraday (~> 0.7)
32
+ multi_json (~> 1.0)
33
+ omniauth (1.0.2)
34
+ hashie (~> 1.2)
35
+ rack
36
+ omniauth-oauth2 (1.0.0)
37
+ oauth2 (~> 0.5.0)
38
+ omniauth (~> 1.0)
39
+ rack (1.4.1)
40
+ rack-test (0.6.1)
41
+ rack (>= 1.0)
42
+ rake (0.9.2.2)
43
+ rb-fsevent (0.4.3.1)
44
+ rspec (2.7.0)
45
+ rspec-core (~> 2.7.0)
46
+ rspec-expectations (~> 2.7.0)
47
+ rspec-mocks (~> 2.7.0)
48
+ rspec-core (2.7.1)
49
+ rspec-expectations (2.7.0)
50
+ diff-lcs (~> 1.1.2)
51
+ rspec-mocks (2.7.0)
52
+ thor (0.14.6)
53
+ webmock (1.7.10)
54
+ addressable (~> 2.2, > 2.2.5)
55
+ crack (>= 0.1.7)
56
+
57
+ PLATFORMS
58
+ ruby
59
+
60
+ DEPENDENCIES
61
+ growl
62
+ guard
63
+ guard-bundler
64
+ guard-rspec
65
+ multi_json
66
+ omniauth-oauth2
67
+ omniauth-viadeo!
68
+ rack-test
69
+ rake
70
+ rb-fsevent
71
+ rspec (~> 2.7.0)
72
+ webmock
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec', :version => 2 do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
6
+
7
+
8
+ guard 'bundler' do
9
+ watch('Gemfile')
10
+ watch(/^.+\.gemspec/)
11
+ end
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+
2
+
3
+ ## License
4
+
5
+ Copyright (c) 2012 by Vincent Coste
6
+
7
+ 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:
8
+
9
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
+
11
+ 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.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/example/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source :rubygems
2
+
3
+ gem 'sinatra'
4
+ gem 'multi_json'
5
+ gem 'omniauth-linkedin', :path => '../'
6
+ #gem 'omniauth-linkedin'
data/example/config.ru ADDED
@@ -0,0 +1,27 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra/base'
3
+ require 'omniauth-linkedin'
4
+
5
+ class App < Sinatra::Base
6
+ get '/' do
7
+ redirect '/auth/linkedin'
8
+ end
9
+
10
+ get '/auth/:provider/callback' do
11
+ content_type 'application/json'
12
+ MultiJson.encode(request.env)
13
+ end
14
+
15
+ get '/auth/failure' do
16
+ content_type 'application/json'
17
+ MultiJson.encode(request.env)
18
+ end
19
+ end
20
+
21
+ use Rack::Session::Cookie
22
+
23
+ use OmniAuth::Builder do
24
+ provider :linkedin, ENV['LINKEDIN_CONSUMER_KEY'], ENV['LINKEDIN_CONSUMER_SECRET']
25
+ end
26
+
27
+ run App.new
@@ -0,0 +1,9 @@
1
+ require "omniauth-viadeo/version"
2
+ require 'omniauth/strategies/viadeo'
3
+
4
+
5
+ module Omniauth
6
+ module Viadeo
7
+ # Your code goes here...
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Viadeo
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,71 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Viadeo < OmniAuth::Strategies::OAuth2
6
+ option :name, "viadeo"
7
+
8
+ uid{ raw_info['id'] }
9
+
10
+ extra do
11
+ {
12
+ 'raw_info' => raw_info
13
+ }
14
+ end
15
+
16
+ option :client_options, {
17
+ :site => 'https://api.viadeo.com/',
18
+ :authorize_url => 'https://secure.viadeo.com/oauth-provider/authorize2',
19
+ :token_url => 'https://secure.viadeo.com/oauth-provider/access_token2'
20
+ }
21
+
22
+ def auth_hash
23
+ OmniAuth::Utils.deep_merge(
24
+ super, {
25
+ 'uid' => raw_info['id'],
26
+ 'user_info' => info,
27
+ 'extra' => {
28
+ 'user_hash' => raw_info,
29
+ },
30
+ }
31
+ )
32
+ end
33
+
34
+ def raw_info
35
+ @raw_info ||= MultiJson.decode(@access_token.get('/me').body)
36
+ end
37
+
38
+ def request_phase
39
+ options[:response_type] ||= 'code'
40
+ super
41
+ end
42
+
43
+ def callback_phase
44
+ options[:grant_type] ||= 'authorization_code'
45
+ super
46
+ end
47
+
48
+ info do
49
+ {
50
+ :name => raw_info['name'],
51
+ :link => raw_info['link'],
52
+ :first_name => raw_info['first_name'],
53
+ :last_name => raw_info['last_name'],
54
+ :gender => raw_info['gender'],
55
+ :nickname => raw_info['nickname'],
56
+ :has_picture => raw_info['has_picture'] ,
57
+ :picture_small => raw_info['picture_small'],
58
+ :picture_large => raw_info['picture_large'],
59
+ :headline => raw_info['headline'],
60
+ :introduction => raw_info['introduction'],
61
+ :interests => raw_info['interests'],
62
+ :location => raw_info['location'],
63
+ :is_premium => raw_info['is_premium'],
64
+ :premium_since => raw_info['premium_since']
65
+ }
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-viadeo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-viadeo"
7
+ s.version = Omniauth::Viadeo::VERSION
8
+ s.authors = ["Vincent Coste"]
9
+ s.email = ["coste.vincent@gmail.com"]
10
+ s.homepage = "https://github.com/pasta/omniauth-viadeo"
11
+ s.summary = %q{Viadeo strategy for OmniAuth.}
12
+ s.description = %q{Viadeo strategy for OmniAuth.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_runtime_dependency 'omniauth-oauth2', '~> 1.0.0'
20
+
21
+ s.add_development_dependency 'rspec', '~> 2.7.0'
22
+ s.add_development_dependency 'rake'
23
+ s.add_development_dependency 'webmock'
24
+ s.add_development_dependency 'rack-test'
25
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe "OmniAuth::Strategies::Viadeo" do
4
+ subject do
5
+ OmniAuth::Strategies::Viadeo.new(nil)
6
+ end
7
+
8
+ context 'client options' do
9
+ it 'has correct Viadeo api site' do
10
+ subject.options.client_options.site.should eq('https://api.viadeo.com/')
11
+ end
12
+
13
+
14
+
15
+ it 'has correct access token path' do
16
+ subject.options.client_options.token_url.should eq('https://secure.viadeo.com/oauth-provider/access_token2')
17
+ end
18
+
19
+ it 'has correct authorize url' do
20
+ subject.options.client_options.authorize_url.should eq('https://secure.viadeo.com/oauth-provider/authorize2')
21
+ end
22
+ end
23
+
24
+ context '#uid' do
25
+ before :each do
26
+ subject.stub(:raw_info) { { 'id' => '123' } }
27
+ end
28
+
29
+ it 'returns the id from raw_info' do
30
+ subject.uid.should eq('123')
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ $:.unshift File.expand_path('..', __FILE__)
2
+ $:.unshift File.expand_path('../../lib', __FILE__)
3
+
4
+ require 'rspec'
5
+ require 'rack/test'
6
+ require 'webmock/rspec'
7
+ require 'omniauth'
8
+ require 'omniauth-viadeo'
9
+
10
+ RSpec.configure do |config|
11
+ config.include WebMock::API
12
+ config.include Rack::Test::Methods
13
+ config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
14
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-viadeo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Vincent Coste
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-25 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth2
16
+ requirement: &70285739839060 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70285739839060
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70285739838160 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.7.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70285739838160
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70285739837580 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70285739837580
47
+ - !ruby/object:Gem::Dependency
48
+ name: webmock
49
+ requirement: &70285739836580 !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: *70285739836580
58
+ - !ruby/object:Gem::Dependency
59
+ name: rack-test
60
+ requirement: &70285739835820 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70285739835820
69
+ description: Viadeo strategy for OmniAuth.
70
+ email:
71
+ - coste.vincent@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .rspec
77
+ - .rvmrc
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - Guardfile
81
+ - README.md
82
+ - Rakefile
83
+ - example/Gemfile
84
+ - example/config.ru
85
+ - lib/omniauth-viadeo.rb
86
+ - lib/omniauth-viadeo/version.rb
87
+ - lib/omniauth/strategies/viadeo.rb
88
+ - omniauth-viadeo.gemspec
89
+ - spec/omniauth/strategies/viadeo_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: https://github.com/pasta/omniauth-viadeo
92
+ licenses: []
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 1.8.10
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Viadeo strategy for OmniAuth.
115
+ test_files:
116
+ - spec/omniauth/strategies/viadeo_spec.rb
117
+ - spec/spec_helper.rb