face_recognition 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +21 -0
- data/lib/face_recognition.rb +20 -0
- data/lib/face_recognition/engine.rb +12 -0
- data/lib/face_recognition/models/anonymous.rb +29 -0
- data/lib/face_recognition/models/base.rb +15 -0
- data/lib/face_recognition/models/omni_auth.rb +79 -0
- data/lib/face_recognition/railtie.rb +7 -0
- data/lib/face_recognition/version.rb +3 -0
- data/lib/tasks/face_recognition_tasks.rake +4 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8572aecc927d91572193b97c3d7dad2240ad2628
|
4
|
+
data.tar.gz: 9236ddf431e2d0be2ab0d16acce05385e70c53e0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 736ec9626a9189e65eded215ef3892d4cb9c862d53aac9ff1e58d1b3a733956cd80dbec66dc051edb38e7460fcf9410c9b6151b818fefc216aaec5c986ff3889
|
7
|
+
data.tar.gz: 02bcf70377ad6d5bc2a76d74beb4d81065be2d31fb9f9e826c187838e9adfce148a70fcc2d026586b0e1d989f29c9c280761094e0ad1a98689021ce70b6bc3fc
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
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.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'FaceRecognition'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "face_recognition/engine"
|
2
|
+
|
3
|
+
module FaceRecognition
|
4
|
+
end
|
5
|
+
|
6
|
+
# load Rails/Railtie
|
7
|
+
begin
|
8
|
+
require 'rails'
|
9
|
+
rescue LoadError
|
10
|
+
#do nothing
|
11
|
+
end
|
12
|
+
|
13
|
+
# Load All the stuff we need
|
14
|
+
require 'face_recognition/models/base'
|
15
|
+
require 'face_recognition/models/omni_auth'
|
16
|
+
require 'face_recognition/models/anonymous'
|
17
|
+
|
18
|
+
if defined? Rails
|
19
|
+
require 'face_recognition/railtie'
|
20
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module FaceRecognition
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace FaceRecognition
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, :fixture => false
|
7
|
+
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
8
|
+
g.assets false
|
9
|
+
g.helper false
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module FaceRecognition
|
2
|
+
module Anonymous
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
before_create :generate_password
|
7
|
+
|
8
|
+
def self.link_to_fb(id, auth)
|
9
|
+
user = nil
|
10
|
+
if FacebookUser.exists?(User.facebook_id_column.to_sym => auth.id)
|
11
|
+
user = FacebookUser.where(User.facebook_id_column.to_sym => auth.id).first
|
12
|
+
else
|
13
|
+
user = find(id)
|
14
|
+
user[facebook_id_column.to_sym] = auth.id
|
15
|
+
user.type = "FacebookUser"
|
16
|
+
# We don't validate here because we are about to update all the details
|
17
|
+
user.save(validate: false)
|
18
|
+
FacebookUser.from_omniauth(auth)
|
19
|
+
end
|
20
|
+
|
21
|
+
return user
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_password
|
25
|
+
self.password = Devise.friendly_token[0,20]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module FaceRecognition
|
2
|
+
module Base
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
|
7
|
+
def self.facebook_id_column
|
8
|
+
# Work out what sort of UID the user model is using
|
9
|
+
return "uid" if ActiveRecord::Base.connection.column_exists?("#{self.table_name}", "uid")
|
10
|
+
return "facebook_id" if ActiveRecord::Base.connection.column_exists?("#{self.table_name}", "facebook_id")
|
11
|
+
return "fb_uid" if ActiveRecord::Base.connection.column_exists?("#{self.table_name}", "fb_uid")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
module FaceRecognition
|
2
|
+
module OmniAuth
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
|
7
|
+
# Take the auth hash from the Omniauth callback and create / update the user
|
8
|
+
def self.from_omniauth(auth)
|
9
|
+
# Find or create the user
|
10
|
+
user = nil
|
11
|
+
if FacebookUser.exists?("#{self.table_name}.#{self.facebook_id_column}" => auth.id)
|
12
|
+
user = FacebookUser.where("#{self.table_name}.#{self.facebook_id_column} =?", auth.id).first
|
13
|
+
else
|
14
|
+
user = FacebookUser.new
|
15
|
+
end
|
16
|
+
|
17
|
+
# Assign the Facebook ID. because we are calling the SQL in the first_or_create it doesn't update that column
|
18
|
+
user[self.facebook_id_column.to_sym] = auth.id
|
19
|
+
|
20
|
+
# Dynamically try and set the users name, no matter how they have it set up
|
21
|
+
user.first_name = auth.first_name if user.respond_to? :first_name=
|
22
|
+
user.last_name = auth.last_name if user.respond_to? :last_name=
|
23
|
+
user.name = auth.name if user.respond_to? :name=
|
24
|
+
user.full_name = auth.name if user.respond_to? :full_name=
|
25
|
+
user.display_name = auth.name if user.respond_to? :display_name=
|
26
|
+
|
27
|
+
# Set their token and provider
|
28
|
+
user.oauth_token = auth.access_token if user.respond_to? :oauth_token=
|
29
|
+
user.omniauth_token = auth.access_token if user.respond_to? :omniauth_token=
|
30
|
+
user.facebook_token = auth.access_token if user.respond_to? :facebook_token=
|
31
|
+
user.fb_access_token = auth.access_token if user.respond_to? :fb_access_token=
|
32
|
+
user.provider = 'facebook' if user.respond_to? :provider=
|
33
|
+
|
34
|
+
# User images
|
35
|
+
user.profile_image_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :profile_image_url=
|
36
|
+
user.profile_photo_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :profile_photo_url=
|
37
|
+
user.cover_image_url = auth.try(:cover) if user.respond_to? :cover_image_url=
|
38
|
+
user.cover_photo_url = auth.try(:cover) if user.respond_to? :cover_photo_url=
|
39
|
+
user.image_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :image_url=
|
40
|
+
user.photo_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :photo_url=
|
41
|
+
user.avatar_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :avatar_url=
|
42
|
+
user.remote_image_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :remote_image_url=
|
43
|
+
user.remote_avatar_url = "http://graph.facebook.com/#{auth.id}/picture?type=large" if user.respond_to? :remote_avatar_url=
|
44
|
+
|
45
|
+
# Regular Devise columns set
|
46
|
+
user.email = auth.email || ''
|
47
|
+
user.password = Devise.friendly_token[0, 20]
|
48
|
+
|
49
|
+
# Extra Info that we can grab
|
50
|
+
user.birthday = auth.raw_attributes.birthday if user.respond_to? :birthday=
|
51
|
+
user.date_of_birth = auth.raw_attributes.birthday if user.respond_to? :date_of_birth=
|
52
|
+
user.dob = auth.raw_attributes.birthday if user.respond_to? :dob=
|
53
|
+
user.d_o_b = auth.raw_attributes.try(:birthday) if user.respond_to? :d_o_b=
|
54
|
+
user.gender = auth.try(:gender) if user.respond_to? :gender=
|
55
|
+
|
56
|
+
user.save
|
57
|
+
# Extend the Users facebook token so that it does not expire
|
58
|
+
user.extend_fb_token(facebook_id_column)
|
59
|
+
|
60
|
+
user
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.extend_fb_token(id, column_name)
|
64
|
+
user = FacebookUser.where(id: id).first
|
65
|
+
return unless user
|
66
|
+
fb_auth = FbGraph2::Auth.new(ENV['FB_APP_ID'], ENV['FB_SECRET_KEY'])
|
67
|
+
fb_auth.fb_exchange_token=(user.fb_access_token)
|
68
|
+
user.fb_access_token = fb_auth.access_token!.access_token
|
69
|
+
user.save
|
70
|
+
end
|
71
|
+
|
72
|
+
def extend_fb_token(column_name)
|
73
|
+
self.class.delay.extend_fb_token(self.id, column_name)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: face_recognition
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Isaac Norman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-01-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: fb_graph2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.1.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.1.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sqlite3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.14.2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.14.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: capybara
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.2.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.2.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: factory_girl_rails
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.4.1
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.4.1
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: database_cleaner
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.2.0
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.2.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: awesome_print
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.2.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.2.0
|
125
|
+
description: Allows registration of anon and Facebook users in your rails app
|
126
|
+
email:
|
127
|
+
- idn@papercloud.com.au
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- MIT-LICENSE
|
133
|
+
- README.rdoc
|
134
|
+
- Rakefile
|
135
|
+
- lib/face_recognition.rb
|
136
|
+
- lib/face_recognition/engine.rb
|
137
|
+
- lib/face_recognition/models/anonymous.rb
|
138
|
+
- lib/face_recognition/models/base.rb
|
139
|
+
- lib/face_recognition/models/omni_auth.rb
|
140
|
+
- lib/face_recognition/railtie.rb
|
141
|
+
- lib/face_recognition/version.rb
|
142
|
+
- lib/tasks/face_recognition_tasks.rake
|
143
|
+
homepage: http://github.com/Papercloud/face_recognition
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.2.2
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Anon and Facebook User Auth
|
167
|
+
test_files: []
|