omniauth-wrapper 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +1 -0
- data/lib/omniauth/wrapper.rb +17 -0
- data/lib/omniauth/wrapper/provider/facebook.rb +41 -0
- data/lib/omniauth/wrapper/version.rb +7 -0
- data/omniauth-wrapper.gemspec +26 -0
- data/spec/fixtures/facebook_data.json +54 -0
- data/spec/provider/facebook.rb +28 -0
- data/spec/spec_helper.rb +16 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5823d0023441d94bd22b3639f87ddb4969d78325
|
4
|
+
data.tar.gz: 0f78e176725433c22c3196fd37f54c0da306c0d9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f7f1c21c482b754e0dc53e622f0e14942f1c032922544a73cc5e23262857d5473cec52ecfddf1b7f1db7b19ad988b5f6c5d2f13e245ef2bae985a8a4d314999
|
7
|
+
data.tar.gz: 51806c4cd52fbd28e72a8966c74734d814f07f2b27e82ea4cdd683a9d7c60db5d656c180658abcf03d38a24ee38826ac134e6e98d9462e5d7ca729e3f37dd363
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Zoloo
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Omniauth::Wrapper
|
2
|
+
|
3
|
+
Simple Omniauth hash wrapper for Facebook.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'omniauth-wrapper'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install omniauth-wrapper
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
``` ruby
|
22
|
+
@wrapper = Omniauth::Wrapper.init(auth_hash)
|
23
|
+
@wrapper.provider # returns provider
|
24
|
+
@wrapper.access_token # returns access token
|
25
|
+
@wrapper.uid # returns uid
|
26
|
+
@wrapper.token_expires_at # returns expires ad
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require "omniauth/wrapper/version"
|
4
|
+
|
5
|
+
module Omniauth
|
6
|
+
module Wrapper
|
7
|
+
|
8
|
+
module Provider
|
9
|
+
autoload :Facebook, 'omniauth/wrapper/provider/facebook'
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.init(auth_hash)
|
13
|
+
klass = Provider::Facebook.new(auth_hash)
|
14
|
+
klass
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Omniauth
|
4
|
+
module Wrapper
|
5
|
+
module Provider
|
6
|
+
class Facebook
|
7
|
+
attr_reader :auth_hash
|
8
|
+
|
9
|
+
def initialize(auth_hash)
|
10
|
+
@auth_hash = auth_hash
|
11
|
+
end
|
12
|
+
|
13
|
+
def uid
|
14
|
+
@uid ||= auth_hash['uid']
|
15
|
+
end
|
16
|
+
|
17
|
+
def provider
|
18
|
+
@provider ||= auth_hash['provider'].to_s.downcase
|
19
|
+
end
|
20
|
+
|
21
|
+
def credentials
|
22
|
+
@credentials ||= (auth_hash['credentials'] || {})
|
23
|
+
end
|
24
|
+
|
25
|
+
def access_token
|
26
|
+
@access_token ||= credentials['token']
|
27
|
+
end
|
28
|
+
|
29
|
+
def token_expires_at
|
30
|
+
@token_expires_at ||= parse_datetime(credentials['expires_at'])
|
31
|
+
end
|
32
|
+
|
33
|
+
protected
|
34
|
+
def parse_datetime(value)
|
35
|
+
return nil if value.nil? || value.to_i.zero?
|
36
|
+
Time.at(value.to_i).to_datetime
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'omniauth/wrapper/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "omniauth-wrapper"
|
10
|
+
spec.version = Omniauth::Wrapper::VERSION
|
11
|
+
spec.authors = ["Zolzaya E."]
|
12
|
+
spec.email = ["zolzaya.erdenebaatar@gmail.com"]
|
13
|
+
spec.description = %q{Omniauth wrapper}
|
14
|
+
spec.summary = %q{Omniauth wrapper}
|
15
|
+
spec.homepage = "https://github.com/zolzaya/omniauth-wrapper"
|
16
|
+
spec.license = "MIT"
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split($/)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(spec)/})
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.13.0"
|
26
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"provider": "facebook",
|
3
|
+
"uid": "100000730417342",
|
4
|
+
"info": {
|
5
|
+
"nickname": "foo.bar",
|
6
|
+
"email": "email@gmail.com",
|
7
|
+
"name": "Foo Bar",
|
8
|
+
"first_name": "Foo",
|
9
|
+
"last_name": "Bar",
|
10
|
+
"image": "http://graph.facebook.com/100000730417342/picture?type=square",
|
11
|
+
"description": "Lorem lorem lorem",
|
12
|
+
"urls": {
|
13
|
+
"Facebook": "http://www.facebook.com/foo.bar"
|
14
|
+
},
|
15
|
+
"location": "Kyiv, Ukraine",
|
16
|
+
"verified": true
|
17
|
+
},
|
18
|
+
"credentials": {
|
19
|
+
"token": "AAAC1N4JHfIcBAIDYp0QLdyCMX9LenAS6KNDrGNZAOQ8bOYObHSg3tgxzvEVNLOTCZBOHDUCcHDxINgluKw52CLxMMZAxHaPXqAwZABMqhgZDZD",
|
20
|
+
"expires_at": 1369429974,
|
21
|
+
"expires": true
|
22
|
+
},
|
23
|
+
"extra": {
|
24
|
+
"raw_info": {
|
25
|
+
"id": "100000730417342",
|
26
|
+
"name": "Foo Bar",
|
27
|
+
"first_name": "Foo",
|
28
|
+
"last_name": "Bar",
|
29
|
+
"link": "http://www.facebook.com/foo.bar",
|
30
|
+
"username": "foo.bar",
|
31
|
+
"hometown": {
|
32
|
+
"id": "108505112504762",
|
33
|
+
"name": "Myronivka"
|
34
|
+
},
|
35
|
+
"location": {
|
36
|
+
"id": "111227078906045",
|
37
|
+
"name": "Kyiv, Ukraine"
|
38
|
+
},
|
39
|
+
"bio": "Lorem lorem lorem",
|
40
|
+
"quotes": "Lorem lorem lorem lorem ...",
|
41
|
+
"work": [],
|
42
|
+
"favorite_teams": [],
|
43
|
+
"favorite_athletes": [],
|
44
|
+
"education": [],
|
45
|
+
"gender": "male",
|
46
|
+
"email": "mail@gmail.com",
|
47
|
+
"timezone": 2,
|
48
|
+
"locale": "en_US",
|
49
|
+
"languages": [],
|
50
|
+
"verified": true,
|
51
|
+
"updated_time": "2013-03-24T21:02:30+0000"
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
describe Omniauth::Wrapper::Provider::Facebook do
|
7
|
+
|
8
|
+
let!(:auth_hash) {
|
9
|
+
File.open(File.join(File.dirname(__FILE__), "../fixtures/facebook_data.json")) do |f|
|
10
|
+
JSON.load(f)
|
11
|
+
end
|
12
|
+
}
|
13
|
+
|
14
|
+
it "should be a Module" do
|
15
|
+
Omniauth::Wrapper::Provider.should be_a(Module)
|
16
|
+
end
|
17
|
+
|
18
|
+
context "facebook" do
|
19
|
+
subject { Omniauth::Wrapper.init(auth_hash) }
|
20
|
+
|
21
|
+
it { should be_a(Omniauth::Wrapper::Provider::Facebook) }
|
22
|
+
its(:auth_hash) { should eq auth_hash }
|
23
|
+
its(:uid) { should eq "100000730417342" }
|
24
|
+
its(:provider) { should eq "facebook" }
|
25
|
+
its(:access_token) { should eq "AAAC1N4JHfIcBAIDYp0QLdyCMX9LenAS6KNDrGNZAOQ8bOYObHSg3tgxzvEVNLOTCZBOHDUCcHDxINgluKw52CLxMMZAxHaPXqAwZABMqhgZDZD" }
|
26
|
+
its(:token_expires_at) { should eq Time.at("1369429974".to_i).to_datetime }
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rspec'
|
4
|
+
require 'omniauth/wrapper'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
config.run_all_when_everything_filtered = true
|
9
|
+
config.filter_run :focus
|
10
|
+
|
11
|
+
# Run specs in random order to surface order dependencies. If you find an
|
12
|
+
# order dependency and want to debug it, you can fix the order by providing
|
13
|
+
# the seed, which is printed after each run.
|
14
|
+
# --seed 1234
|
15
|
+
config.order = 'random'
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-wrapper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Zolzaya E.
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.13.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.13.0
|
55
|
+
description: Omniauth wrapper
|
56
|
+
email:
|
57
|
+
- zolzaya.erdenebaatar@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- .rspec
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/omniauth/wrapper.rb
|
69
|
+
- lib/omniauth/wrapper/provider/facebook.rb
|
70
|
+
- lib/omniauth/wrapper/version.rb
|
71
|
+
- omniauth-wrapper.gemspec
|
72
|
+
- spec/fixtures/facebook_data.json
|
73
|
+
- spec/provider/facebook.rb
|
74
|
+
- spec/spec_helper.rb
|
75
|
+
homepage: https://github.com/zolzaya/omniauth-wrapper
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.0.3
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: Omniauth wrapper
|
99
|
+
test_files:
|
100
|
+
- spec/fixtures/facebook_data.json
|
101
|
+
- spec/provider/facebook.rb
|
102
|
+
- spec/spec_helper.rb
|