omniauth-plurk 1.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in omniauth-plurk.gemspec
4
+ gemspec
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,2 @@
1
+ require "omniauth-plurk/version"
2
+ require 'omniauth/strategies/plurk'
@@ -0,0 +1,5 @@
1
+ module Omniauth
2
+ module Plurk
3
+ VERSION = "1.0.0.rc2"
4
+ end
5
+ end
@@ -0,0 +1,66 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+ class Plurk < OmniAuth::Strategies::OAuth
7
+ option :name, 'plurk'
8
+
9
+ def initialize(*args)
10
+ super
11
+ # taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L15-21
12
+ options.client_options = {
13
+ :access_token_path => '/OAuth/access_token',
14
+ :authorize_path => '/OAuth/authorize',
15
+ :request_token_path => '/OAuth/request_token',
16
+ :site => 'http://www.plurk.com',
17
+ }
18
+ end
19
+
20
+ def consumer
21
+ consumer = ::OAuth::Consumer.new(options.consumer_key, options.consumer_secret, options.client_options)
22
+ consumer
23
+ end
24
+
25
+ uid { access_token.params[:id] }
26
+
27
+ info do
28
+ {
29
+ 'name' => raw_info['full_name'],
30
+ 'nickname' => raw_info['display_name'] || raw_info['nick_name'],
31
+ 'location' => raw_info['location'],
32
+ 'image' => raw_info['has_profile_image'] == 1 ? "http://avatars.plurk.com/#{raw_info['id']}-medium#{raw_info['avatar']}.gif" : 'http://www.plurk.com/static/default_medium.gif',
33
+ 'urls' => {'Plurk' => 'http://plurk.com/' + raw_info['nick_name']},
34
+ }
35
+ end
36
+
37
+ extra do
38
+ { :raw_info => raw_info }
39
+ end
40
+
41
+ #taken from https://github.com/intridea/omniauth/blob/0-3-stable/oa-oauth/lib/omniauth/strategies/oauth/tsina.rb#L52-67
42
+ def request_phase
43
+ request_token = consumer.get_request_token(:oauth_callback => callback_url)
44
+ session['oauth'] ||= {}
45
+ session['oauth'][name.to_s] = {'callback_confirmed' => true, 'request_token' => request_token.token, 'request_secret' => request_token.secret}
46
+
47
+ if request_token.callback_confirmed?
48
+ redirect request_token.authorize_url(options[:authorize_params])
49
+ else
50
+ redirect request_token.authorize_url(options[:authorize_params].merge(:oauth_callback => callback_url))
51
+ end
52
+
53
+ rescue ::Timeout::Error => e
54
+ fail!(:timeout, e)
55
+ rescue ::Net::HTTPFatalError, ::OpenSSL::SSL::SSLError => e
56
+ fail!(:service_unavailable, e)
57
+ end
58
+
59
+ def raw_info
60
+ @raw_info ||= MultiJson.decode(access_token.get('/APP/Profile/getOwnProfile').body)['user_info']
61
+ rescue ::Errno::ETIMEDOUT
62
+ raise ::Timeout::Error
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-plurk/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "omniauth-plurk"
7
+ s.version = Omniauth::Plurk::VERSION
8
+ s.authors = ["Scott Ballantyne"]
9
+ s.email = ["ussballantyne@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{an omniauth strategy for plurk}
12
+ s.description = %q{an omniauth strategy for plurk}
13
+
14
+ s.rubyforge_project = "omniauth-plurk"
15
+ s.add_dependency 'omniauth', '~> 1.0.0.rc2'
16
+ s.add_dependency 'omniauth-oauth2', '~> 1.0.0.rc2'
17
+
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+
24
+ # specify any dependencies here; for example:
25
+ # s.add_development_dependency "rspec"
26
+ # s.add_runtime_dependency "rest-client"
27
+ end
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-plurk
3
+ version: !ruby/object:Gem::Version
4
+ hash: 3545533129
5
+ prerelease: 6
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ - rc
11
+ - 2
12
+ version: 1.0.0.rc2
13
+ platform: ruby
14
+ authors:
15
+ - Scott Ballantyne
16
+ autorequire:
17
+ bindir: bin
18
+ cert_chain: []
19
+
20
+ date: 2011-10-30 00:00:00 Z
21
+ dependencies:
22
+ - !ruby/object:Gem::Dependency
23
+ name: omniauth
24
+ prerelease: false
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ hash: 3545533129
31
+ segments:
32
+ - 1
33
+ - 0
34
+ - 0
35
+ - rc
36
+ - 2
37
+ version: 1.0.0.rc2
38
+ type: :runtime
39
+ version_requirements: *id001
40
+ - !ruby/object:Gem::Dependency
41
+ name: omniauth-oauth2
42
+ prerelease: false
43
+ requirement: &id002 !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ hash: 3545533129
49
+ segments:
50
+ - 1
51
+ - 0
52
+ - 0
53
+ - rc
54
+ - 2
55
+ version: 1.0.0.rc2
56
+ type: :runtime
57
+ version_requirements: *id002
58
+ description: an omniauth strategy for plurk
59
+ email:
60
+ - ussballantyne@gmail.com
61
+ executables: []
62
+
63
+ extensions: []
64
+
65
+ extra_rdoc_files: []
66
+
67
+ files:
68
+ - .gitignore
69
+ - Gemfile
70
+ - README
71
+ - Rakefile
72
+ - lib/omniauth-plurk.rb
73
+ - lib/omniauth-plurk/version.rb
74
+ - lib/omniauth/strategies/plurk.rb
75
+ - omniauth-plurk.gemspec
76
+ homepage: ""
77
+ licenses: []
78
+
79
+ post_install_message:
80
+ rdoc_options: []
81
+
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ">"
97
+ - !ruby/object:Gem::Version
98
+ hash: 25
99
+ segments:
100
+ - 1
101
+ - 3
102
+ - 1
103
+ version: 1.3.1
104
+ requirements: []
105
+
106
+ rubyforge_project: omniauth-plurk
107
+ rubygems_version: 1.8.11
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: an omniauth strategy for plurk
111
+ test_files: []
112
+