omniauth-readmill 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ coverage
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'rake'
7
+ gem 'guard'
8
+ gem 'guard-rspec'
9
+ gem 'guard-bundler'
10
+ gem 'rb-fsevent'
11
+ gem 'growl'
12
+ end
data/Guardfile ADDED
@@ -0,0 +1,10 @@
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
+ guard 'bundler' do
8
+ watch('Gemfile')
9
+ watch('omniauth-github.gemspec')
10
+ end
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # OmniAuth Readmill
2
+
3
+ This is an unofficial OmniAuth strategy for authenticating to [Readmill](http://readmill.com). You will need to [register an app](http://readmill.com/you/apps/new) to get your developer keys.
4
+
5
+ # Usage
6
+
7
+ ```ruby
8
+ use OmniAuth::Builder do
9
+ provider :readmill, ENV['READMILL_KEY'], ENV['READMILL_SECRET']
10
+ end
11
+ ```
12
+
13
+ # License (MIT)
14
+
15
+ Copyright (c) 2011 Christof Dorner
16
+
17
+ 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:
18
+
19
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
20
+
21
+ 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,12 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ desc "Default: run specs."
6
+ task :default => :spec
7
+
8
+ desc "Run specs"
9
+ RSpec::Core::RakeTask.new
10
+
11
+ desc "Run specs"
12
+ task :default => :spec
@@ -0,0 +1,2 @@
1
+ require 'omniauth-readmill/version'
2
+ require 'omniauth/strategies/readmill'
@@ -0,0 +1,5 @@
1
+ module OmniAuth
2
+ module Readmill
3
+ VERSION = '0.1.1'
4
+ end
5
+ end
@@ -0,0 +1,48 @@
1
+ require 'omniauth-oauth2'
2
+
3
+ module OmniAuth
4
+ module Strategies
5
+ class Readmill < OmniAuth::Strategies::OAuth2
6
+ option :client_options, {
7
+ :site => 'http://api.readmill.com',
8
+ :authorize_url => 'http://readmill.com/oauth/authorize',
9
+ :token_url => 'http://readmill.com/oauth/token'
10
+ }
11
+
12
+ uid { raw_info['id'] }
13
+
14
+ info do
15
+ {
16
+ 'name' => raw_info['fullname'],
17
+ 'email' => raw_info['email'],
18
+ 'nickname' => raw_info['username'],
19
+ 'first_name' => raw_info['firstname'],
20
+ 'last_name' => raw_info['lastname'],
21
+ 'location' => raw_info['city'],
22
+ 'description' => raw_info['description'],
23
+ 'image' => raw_info['avatar_url'],
24
+ 'urls' => {
25
+ 'Readmill' => raw_info['permalink_url'],
26
+ 'Website' => raw_info['website']
27
+ },
28
+ }
29
+ end
30
+
31
+ extra do
32
+ {
33
+ 'books_interesting' => raw_info['books_interesting'],
34
+ 'books_open' => raw_info['books_open'],
35
+ 'books_finished' => raw_info['books_finished'],
36
+ 'books_abandoned' => raw_info['books_abandoned'],
37
+ 'followers' => raw_info['followers'],
38
+ 'followings' => raw_info['followings']
39
+ }
40
+ end
41
+
42
+ def raw_info
43
+ access_token.options[:mode] = :query
44
+ @raw_info ||= access_token.get("/me?access_token=#{access_token.token}").parsed
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/omniauth-readmill/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Christof Dorner"]
6
+ gem.email = ["christof@chdorner.com"]
7
+ gem.description = %q{Unofficial OmniAuth strategy for Readmill.}
8
+ gem.summary = %q{Unofficial OmniAuth strategy for Readmill.}
9
+ gem.homepage = "https://github.com/chdorner/omniauth-readmill"
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-readmill'
15
+ gem.require_paths = ['lib']
16
+ gem.version = OmniAuth::Readmill::VERSION
17
+
18
+ gem.add_dependency 'omniauth', '~> 1.0'
19
+ gem.add_dependency 'omniauth-oauth2', '~> 1.0'
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,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe OmniAuth::Strategies::Readmill do
4
+ def app; lambda{|env| [200, {}, ["Hello."]]} end
5
+ let(:fresh_strategy){ Class.new(OmniAuth::Strategies::Readmill) }
6
+
7
+ describe '#client' do
8
+ subject{ fresh_strategy }
9
+
10
+ it 'should have the correct authorize url' do
11
+ instance = subject.new(app)
12
+ instance.client.options[:authorize_url].should == 'http://readmill.com/oauth/authorize'
13
+ end
14
+
15
+ it 'should have the correct token url' do
16
+ instance = subject.new(app)
17
+ instance.client.options[:token_url].should == 'http://readmill.com/oauth/token'
18
+ end
19
+ end
20
+ 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-readmill'
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,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-readmill
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Christof Dorner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-17 00:00:00.000000000 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: omniauth
17
+ requirement: &2152510880 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2152510880
26
+ - !ruby/object:Gem::Dependency
27
+ name: omniauth-oauth2
28
+ requirement: &2152510380 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2152510380
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &2152509920 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: '2.7'
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2152509920
48
+ - !ruby/object:Gem::Dependency
49
+ name: rack-test
50
+ requirement: &2152509540 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *2152509540
59
+ - !ruby/object:Gem::Dependency
60
+ name: simplecov
61
+ requirement: &2152509080 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *2152509080
70
+ - !ruby/object:Gem::Dependency
71
+ name: webmock
72
+ requirement: &2152508660 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *2152508660
81
+ description: Unofficial OmniAuth strategy for Readmill.
82
+ email:
83
+ - christof@chdorner.com
84
+ executables: []
85
+ extensions: []
86
+ extra_rdoc_files: []
87
+ files:
88
+ - .gitignore
89
+ - Gemfile
90
+ - Guardfile
91
+ - README.md
92
+ - Rakefile
93
+ - lib/omniauth-readmill.rb
94
+ - lib/omniauth-readmill/version.rb
95
+ - lib/omniauth/strategies/readmill.rb
96
+ - omniauth-readmill.gemspec
97
+ - spec/omniauth/strategies/readmill_spec.rb
98
+ - spec/spec_helper.rb
99
+ has_rdoc: true
100
+ homepage: https://github.com/chdorner/omniauth-readmill
101
+ licenses: []
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ! '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 1.6.2
121
+ signing_key:
122
+ specification_version: 3
123
+ summary: Unofficial OmniAuth strategy for Readmill.
124
+ test_files:
125
+ - spec/omniauth/strategies/readmill_spec.rb
126
+ - spec/spec_helper.rb