omniauth-instapaper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/.gitignore +40 -0
- data/.rspec +3 -0
- data/.simplecov +1 -0
- data/.yardopts +3 -0
- data/Gemfile +3 -0
- data/LICENSE.md +20 -0
- data/README.md +58 -0
- data/Rakefile +18 -0
- data/example/Gemfile +4 -0
- data/example/config.ru +27 -0
- data/lib/omniauth-instapaper.rb +1 -0
- data/lib/omniauth/instapaper.rb +1 -0
- data/lib/omniauth/instapaper/version.rb +5 -0
- data/lib/omniauth/strategies/instapaper.rb +28 -0
- data/omniauth-instapaper.gemspec +29 -0
- data/spec/integration_spec.rb +5 -0
- data/spec/omniauth/strategies/instapaper_spec.rb +51 -0
- data/spec/spec_helper.rb +6 -0
- metadata +155 -0
data/.gemtest
ADDED
File without changes
|
data/.gitignore
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
*.sw[a-p]
|
4
|
+
*.tmproj
|
5
|
+
*.tmproject
|
6
|
+
*.un~
|
7
|
+
*~
|
8
|
+
.DS_Store
|
9
|
+
.Spotlight-V100
|
10
|
+
.Trashes
|
11
|
+
._*
|
12
|
+
.bundle
|
13
|
+
.config
|
14
|
+
.directory
|
15
|
+
.elc
|
16
|
+
.emacs.desktop
|
17
|
+
.emacs.desktop.lock
|
18
|
+
.redcar
|
19
|
+
.yardoc
|
20
|
+
Desktop.ini
|
21
|
+
Gemfile.lock
|
22
|
+
Icon?
|
23
|
+
InstalledFiles
|
24
|
+
Session.vim
|
25
|
+
Thumbs.db
|
26
|
+
\#*\#
|
27
|
+
_yardoc
|
28
|
+
auto-save-list
|
29
|
+
coverage
|
30
|
+
doc
|
31
|
+
lib/bundler/man
|
32
|
+
pkg
|
33
|
+
pkg/*
|
34
|
+
rdoc
|
35
|
+
spec/reports
|
36
|
+
test/tmp
|
37
|
+
test/version_tmp
|
38
|
+
tmp
|
39
|
+
tmtags
|
40
|
+
tramp
|
data/.rspec
ADDED
data/.simplecov
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
SimpleCov.start
|
data/.yardopts
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Steve Agalloco
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# OmniAuth Instapaper
|
2
|
+
|
3
|
+
This gem is an OmniAuth 1.0 Strategy for the [Instapaper Full API](http://www.instapaper.com/api/full)
|
4
|
+
|
5
|
+
It supports the Instapaper Full API which uses OAuth 1.0a and authenticates via XAuth.
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
Add the strategy to your `Gemfile` alongside OmniAuth:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth'
|
13
|
+
gem 'omniauth-instapaper'
|
14
|
+
```
|
15
|
+
|
16
|
+
Then integrate the strategy into your middleware:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
use OmniAuth::Builder do
|
20
|
+
provider :instapaper, ENV['INSTAPAPER_CONSUMER_KEY'], ENV['INSTAPAPER_CONSUMER_SECRET']
|
21
|
+
end
|
22
|
+
```
|
23
|
+
|
24
|
+
In Rails, you'll want to add to the middleware stack:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :instapaper, ENV['INSTAPAPER_CONSUMER_KEY'], ENV['INSTAPAPER_CONSUMER_SECRET']
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
You will have to put in your consumer key and secret.
|
33
|
+
|
34
|
+
For additional information, refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
|
35
|
+
|
36
|
+
## <a name="build"></a>Build Status
|
37
|
+
[![Build Status](https://secure.travis-ci.org/spagalloco/omniauth-instapaper.png?branch=master)][travis]
|
38
|
+
|
39
|
+
[travis]: http://travis-ci.org/spagalloco/omniauth-instapaper
|
40
|
+
|
41
|
+
## <a name="dependencies"></a>Dependency Status
|
42
|
+
[![Dependency Status](https://gemnasium.com/spagalloco/omniauth-instapaper.png?travis)][gemnasium]
|
43
|
+
|
44
|
+
[gemnasium]: https://gemnasium.com/spagalloco/omniauth-instapaper
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
* Fork the project.
|
49
|
+
* Make your feature addition or bug fix.
|
50
|
+
* Add tests for it. This is important so I don't break it in a
|
51
|
+
future version unintentionally.
|
52
|
+
* Commit, do not mess with rakefile, version, or history.
|
53
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
54
|
+
* Send me a pull request. Bonus points for topic branches.
|
55
|
+
|
56
|
+
## Copyright
|
57
|
+
|
58
|
+
Copyright (c) 2012 Steve Agalloco. See [LICENSE](https://github.com/spagalloco/omniauth-instapaper/blob/master/LICENSE.md) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'bundler'
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
|
+
|
9
|
+
task :default => :spec
|
10
|
+
task :test => :spec
|
11
|
+
|
12
|
+
require 'yard'
|
13
|
+
namespace :doc do
|
14
|
+
YARD::Rake::YardocTask.new do |task|
|
15
|
+
task.files = ['LICENSE.md', 'lib/**/*.rb']
|
16
|
+
task.options = ['--markup', 'markdown']
|
17
|
+
end
|
18
|
+
end
|
data/example/Gemfile
ADDED
data/example/config.ru
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'omniauth-instapaper'
|
4
|
+
|
5
|
+
class App < Sinatra::Base
|
6
|
+
get '/' do
|
7
|
+
redirect '/auth/instapaper'
|
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 :instapaper, ENV['INSTAPAPER_CONSUMER_KEY'], ENV['INSTAPAPER_CONSUMER_SECRET']
|
25
|
+
end
|
26
|
+
|
27
|
+
run App.new
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/instapaper'
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'omniauth/strategies/instapaper'
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'omniauth-xauth'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class Instapaper < OmniAuth::Strategies::XAuth
|
6
|
+
option :client_options, {
|
7
|
+
:site => 'http://www.instapaper.com/',
|
8
|
+
:access_token_url => 'https://www.instapaper.com/api/1/oauth/access_token'
|
9
|
+
}
|
10
|
+
option :xauth_options, { :title => 'OmniAuth Instapaper'}
|
11
|
+
|
12
|
+
uid { raw_info['user_id'] }
|
13
|
+
|
14
|
+
info do
|
15
|
+
{ 'name' => raw_info['username'] }
|
16
|
+
end
|
17
|
+
|
18
|
+
extra do
|
19
|
+
{'raw_info' => raw_info }
|
20
|
+
end
|
21
|
+
|
22
|
+
def raw_info
|
23
|
+
@raw_info ||= MultiJson.decode(access_token.get("https://www.instapaper.com/api/1/account/verify_credentials").body).first
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../lib/omniauth/instapaper/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'omniauth-instapaper'
|
6
|
+
gem.version = OmniAuth::Instapaper::VERSION
|
7
|
+
gem.homepage = 'https://github.com/spagalloco/omniauth-instapaper'
|
8
|
+
|
9
|
+
gem.author = "Steve Agalloco"
|
10
|
+
gem.email = 'steve.agalloco@gmail.com'
|
11
|
+
gem.description = 'Instapaper strategy for OmniAuth 1.0'
|
12
|
+
gem.summary = gem.description
|
13
|
+
|
14
|
+
gem.add_dependency "omniauth-xauth", '~> 0.0.2'
|
15
|
+
gem.add_dependency 'multi_json'
|
16
|
+
|
17
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
18
|
+
gem.add_development_dependency 'rdiscount', '~> 1.6'
|
19
|
+
gem.add_development_dependency 'rspec', '~> 2.7'
|
20
|
+
gem.add_development_dependency 'simplecov', '~> 0.5'
|
21
|
+
gem.add_development_dependency 'yard', '~> 0.7'
|
22
|
+
gem.add_development_dependency 'webmock', '~> 1.7'
|
23
|
+
|
24
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{|f| File.basename(f)}
|
25
|
+
gem.files = `git ls-files`.split("\n")
|
26
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
27
|
+
|
28
|
+
gem.require_paths = ['lib']
|
29
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Instapaper do
|
4
|
+
before :each do
|
5
|
+
@request = double('Request')
|
6
|
+
@request.stub(:params) { {} }
|
7
|
+
end
|
8
|
+
|
9
|
+
subject do
|
10
|
+
OmniAuth::Strategies::Instapaper.new(nil, @options || {}).tap do |strategy|
|
11
|
+
strategy.stub(:request) { @request }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#client_options' do
|
16
|
+
it 'has correct Instapaper site' do
|
17
|
+
subject.options.client_options.site.should eq('http://www.instapaper.com/')
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'has correct access token url' do
|
21
|
+
subject.options.client_options.access_token_url.should eq('https://www.instapaper.com/api/1/oauth/access_token')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#uid' do
|
26
|
+
it 'returns the uid from raw_info' do
|
27
|
+
subject.stub(:raw_info) { { "type" => "user", "user_id" => 54321, "username" => "TestUserOMGLOL" } }
|
28
|
+
subject.uid.should eq(54321)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#info' do
|
33
|
+
context 'when data is present in raw info' do
|
34
|
+
it 'returns the name' do
|
35
|
+
subject.stub(:raw_info) { { "type" => "user", "user_id" => 54321, "username" => "TestUserOMGLOL" } }
|
36
|
+
subject.info['name'].should eq('TestUserOMGLOL')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#extra' do
|
42
|
+
before :each do
|
43
|
+
@raw_info_hash = { "misc" => [:something => "else in the hash"] }
|
44
|
+
subject.stub(:raw_info) { @raw_info_hash }
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns a Hash' do
|
48
|
+
subject.extra.should be_a(Hash)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-instapaper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Steve Agalloco
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-23 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: omniauth-xauth
|
16
|
+
requirement: &70203934702580 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.0.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70203934702580
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: multi_json
|
27
|
+
requirement: &70203934702040 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70203934702040
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70203934701400 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.9'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70203934701400
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rdiscount
|
49
|
+
requirement: &70203934700800 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70203934700800
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: &70203934700240 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '2.7'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70203934700240
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: &70203934699680 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ~>
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0.5'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70203934699680
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: yard
|
82
|
+
requirement: &70203934699160 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0.7'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70203934699160
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: webmock
|
93
|
+
requirement: &70203934698700 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ~>
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '1.7'
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *70203934698700
|
102
|
+
description: Instapaper strategy for OmniAuth 1.0
|
103
|
+
email: steve.agalloco@gmail.com
|
104
|
+
executables: []
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- .gemtest
|
109
|
+
- .gitignore
|
110
|
+
- .rspec
|
111
|
+
- .simplecov
|
112
|
+
- .yardopts
|
113
|
+
- Gemfile
|
114
|
+
- LICENSE.md
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- example/Gemfile
|
118
|
+
- example/config.ru
|
119
|
+
- lib/omniauth-instapaper.rb
|
120
|
+
- lib/omniauth/instapaper.rb
|
121
|
+
- lib/omniauth/instapaper/version.rb
|
122
|
+
- lib/omniauth/strategies/instapaper.rb
|
123
|
+
- omniauth-instapaper.gemspec
|
124
|
+
- spec/integration_spec.rb
|
125
|
+
- spec/omniauth/strategies/instapaper_spec.rb
|
126
|
+
- spec/spec_helper.rb
|
127
|
+
homepage: https://github.com/spagalloco/omniauth-instapaper
|
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.10
|
148
|
+
signing_key:
|
149
|
+
specification_version: 3
|
150
|
+
summary: Instapaper strategy for OmniAuth 1.0
|
151
|
+
test_files:
|
152
|
+
- spec/integration_spec.rb
|
153
|
+
- spec/omniauth/strategies/instapaper_spec.rb
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
has_rdoc:
|