omniauth-deviantart 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'pry'
7
+ end
@@ -0,0 +1,59 @@
1
+ # OmniAuth DeviantArt
2
+
3
+ This gem contains the DeviantArt strategy for OmniAuth 1.0.
4
+
5
+ ## Installing
6
+
7
+ Add to your `Gemfile`:
8
+
9
+ ```ruby
10
+ gem 'omniauth-deviantart', '~> 0.0.1'
11
+ ```
12
+
13
+ Then `bundle install`.
14
+
15
+ ## Basic Usage
16
+
17
+ use OmniAuth::Builder do
18
+ provider "deviantart", ENV['DEVIANTART_APP_ID'], ENV['DEVIANTART_SECRET']
19
+ end
20
+
21
+ ## DeviantART Docs
22
+
23
+ [DeviantART docs here!](http://www.deviantart.com/developers/oauth2).
24
+
25
+ ## Auth Hash
26
+
27
+ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
28
+ ```ruby
29
+ {
30
+ "provider" => "deviantart",
31
+ "uid" => deviantid,
32
+ "info" => {
33
+ "nickname" => "deviantid",
34
+ "image" => "http://a.deviantart.net/avatars/k/o/deviantid.png?15"
35
+ },
36
+ "credentials" => {
37
+ "token" => "123-321",
38
+ "expires" => true,
39
+ "expires_at" => "yyyy-mm-dd hh:mm:ss"
40
+ },
41
+ "extra" => {
42
+ "raw_info" => {
43
+ "username" => "deviantid",
44
+ "symbol" => "~",
45
+ "usericonurl" => "http://a.deviantart.net/avatars/k/o/deviantid.png?15"
46
+ }
47
+ }
48
+ }
49
+ ```
50
+
51
+ ## License
52
+
53
+ Copyright (c) 2012 by Philip Vieira and DeviantART
54
+
55
+ 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:
56
+
57
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
58
+
59
+ 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,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require "omniauth-deviantart/version"
2
+ require 'omniauth/strategies/deviantart'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module DeviantArt
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,34 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class DeviantArt < OmniAuth::Strategies::OAuth2
6
+
7
+ option :client_options, {
8
+ :site => 'https://www.deviantart.com/oauth2/draft15',
9
+ :authorize_url => 'https://www.deviantart.com/oauth2/draft15/authorize',
10
+ :token_url => 'https://www.deviantart.com/oauth2/draft15/token'
11
+ }
12
+
13
+ uid { raw_info['username'] }
14
+
15
+ info do
16
+ {
17
+ 'nickname' => raw_info['username'],
18
+ 'image' => raw_info['usericonurl']
19
+ }
20
+ end
21
+
22
+ extra do
23
+ { :raw_info => raw_info }
24
+ end
25
+
26
+ def raw_info
27
+ @raw_info ||= access_token.get('https://www.deviantart.com/api/draft15/user/whoami', params: { token: access_token.token }).parsed
28
+ end
29
+
30
+ end
31
+ end
32
+ end
33
+
34
+ OmniAuth.config.add_camelization 'deviantart', 'DeviantArt'
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-deviantart/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Philip Vieira"]
6
+ gem.email = ["philip@vallin.se"]
7
+ gem.description = %q{OmniAuth strategy for DeviantArt.}
8
+ gem.summary = %q{OmniAuth strategy for DeviantArt.}
9
+ gem.homepage = "https://github.com/Zeeraw/omniauth-deviantart"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "omniauth-deviantart"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = OmniAuth::DeviantArt::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.1'
20
+ gem.add_development_dependency 'rspec', '~> 2.7'
21
+ gem.add_development_dependency 'rack-test'
22
+ gem.add_development_dependency 'simplecov'
23
+ gem.add_development_dependency 'webmock'
24
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::DeviantArt do
4
+ subject do
5
+ OmniAuth::Strategies::DeviantArt.new({})
6
+ end
7
+
8
+ context "client options" do
9
+ it 'should have correct site' do
10
+ subject.options.client_options.site.should eq("https://www.deviantart.com/oauth2/draft15")
11
+ end
12
+
13
+ it 'should have correct authorize url' do
14
+ subject.options.client_options.authorize_url.should eq('https://www.deviantart.com/oauth2/draft15/authorize')
15
+ end
16
+
17
+ it 'should have correct token url' do
18
+ subject.options.client_options.token_url.should eq('https://www.deviantart.com/oauth2/draft15/token')
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
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-deviantart'
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
16
+
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-deviantart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Philip Vieira
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-31 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: omniauth-oauth2
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '1.1'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '1.1'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '2.7'
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: '2.7'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rack-test
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: simplecov
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
+ - !ruby/object:Gem::Dependency
95
+ name: webmock
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: OmniAuth strategy for DeviantArt.
111
+ email:
112
+ - philip@vallin.se
113
+ executables: []
114
+ extensions: []
115
+ extra_rdoc_files: []
116
+ files:
117
+ - .gitignore
118
+ - Gemfile
119
+ - README.md
120
+ - Rakefile
121
+ - lib/omniauth-deviantart.rb
122
+ - lib/omniauth-deviantart/version.rb
123
+ - lib/omniauth/strategies/deviantart.rb
124
+ - omniauth-deviantart.gemspec
125
+ - spec/omniauth/strategies/deviantart_spec.rb
126
+ - spec/spec_helper.rb
127
+ homepage: https://github.com/Zeeraw/omniauth-deviantart
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.24
148
+ signing_key:
149
+ specification_version: 3
150
+ summary: OmniAuth strategy for DeviantArt.
151
+ test_files:
152
+ - spec/omniauth/strategies/deviantart_spec.rb
153
+ - spec/spec_helper.rb