omniauth-500px 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ coverage
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ # Specify your gem's dependencies in omniauth-twitter.gemspec
5
+ gemspec
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,2 @@
1
+ require "omniauth-500px/version"
2
+ require 'omniauth/strategies/500px'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module FiveHundredPx
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,55 @@
1
+ require 'omniauth-oauth'
2
+ require 'multi_json'
3
+
4
+ module OmniAuth
5
+ module Strategies
6
+
7
+ class FiveHundredPx < OmniAuth::Strategies::OAuth
8
+
9
+ option :name, '500px'
10
+
11
+ option :client_options, {
12
+ :access_token_path => "/v1/oauth/access_token",
13
+ :authorize_path => "/v1/oauth/authorize",
14
+ :request_token_path => "/v1/oauth/request_token",
15
+ :site => "https://api.500px.com"
16
+ }
17
+
18
+ uid {
19
+ user_info['id']
20
+ }
21
+
22
+ info do
23
+ {
24
+ :username => user_info['username'],
25
+ :fullname => user_info['fullname']
26
+ }
27
+ end
28
+
29
+ extra do
30
+ {
31
+ :raw_info => raw_info
32
+ }
33
+ end
34
+
35
+ # Return info gathered from the flickr.people.getInfo API call
36
+
37
+ def raw_info
38
+ @raw_info ||= MultiJson.load(access_token.get('/v1/users.json').body)
39
+ rescue ::Errno::ETIMEDOUT
40
+ raise ::Timeout::Error
41
+ end
42
+
43
+ # Provide the "Person" portion of the raw_info
44
+
45
+ def user_info
46
+ @user_info ||= raw_info.nil? ? {} : raw_info["user"]
47
+ end
48
+
49
+ def request_phase
50
+ options[:authorize_params] = {:perms => options[:scope]} if options[:scope]
51
+ super
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "omniauth-500px/version"
4
+
5
+ # p OmniAuth::FiveHundredPx::VERSION
6
+ Gem::Specification.new do |s|
7
+ s.name = "omniauth-500px"
8
+ s.version = OmniAuth::FiveHundredPx::VERSION
9
+ s.authors = ["Arthur Neves"]
10
+ s.email = ["arthurnn@gmail.com"]
11
+ s.homepage = "https://github.com/arthurnn/omniauth-500px"
12
+ s.summary = %q{OmniAuth strategy for 500px}
13
+ s.description = %q{OmniAuth strategy for 500px}
14
+
15
+ s.rubyforge_project = "omniauth-500px"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
23
+ s.add_development_dependency 'rspec', '~> 2.7'
24
+ s.add_development_dependency 'rack-test'
25
+ s.add_development_dependency 'simplecov'
26
+ s.add_development_dependency 'webmock'
27
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::FiveHundredPx do
4
+ subject do
5
+ OmniAuth::Strategies::FiveHundredPx.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct name' do
10
+ subject.options.name.should eq("500px")
11
+ end
12
+
13
+ it 'should have correct site' do
14
+ subject.options.client_options.site.should eq('https://api.500px.com')
15
+ end
16
+
17
+ it 'should have correct authorize url' do
18
+ subject.options.client_options.authorize_path.should eq('/v1/oauth/authorize')
19
+ end
20
+ end
21
+ 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-500px'
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,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-500px
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Arthur Neves
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-17 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: omniauth-oauth
16
+ requirement: &70258085928280 !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: *70258085928280
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70258085927060 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: '2.7'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70258085927060
36
+ - !ruby/object:Gem::Dependency
37
+ name: rack-test
38
+ requirement: &70258085926300 !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: *70258085926300
47
+ - !ruby/object:Gem::Dependency
48
+ name: simplecov
49
+ requirement: &70258085925000 !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: *70258085925000
58
+ - !ruby/object:Gem::Dependency
59
+ name: webmock
60
+ requirement: &70258085923100 !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: *70258085923100
69
+ description: OmniAuth strategy for 500px
70
+ email:
71
+ - arthurnn@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - Gemfile
78
+ - Rakefile
79
+ - lib/omniauth-500px.rb
80
+ - lib/omniauth-500px/version.rb
81
+ - lib/omniauth/strategies/500px.rb
82
+ - omniauth-500px.gemspec
83
+ - spec/omniauth/strategies/500px_spec.rb
84
+ - spec/spec_helper.rb
85
+ homepage: https://github.com/arthurnn/omniauth-500px
86
+ licenses: []
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project: omniauth-500px
105
+ rubygems_version: 1.8.15
106
+ signing_key:
107
+ specification_version: 3
108
+ summary: OmniAuth strategy for 500px
109
+ test_files:
110
+ - spec/omniauth/strategies/500px_spec.rb
111
+ - spec/spec_helper.rb