socials 0.0.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +0 -21
- data/lib/generators/socials/devise_generator.rb +64 -0
- data/lib/generators/socials/install_generator.rb +36 -18
- data/lib/generators/templates/tasks/socials.rake +11 -0
- data/lib/socials/devise.rb +21 -0
- data/lib/socials/version.rb +2 -2
- data/lib/socials.rb +1 -1
- metadata +5 -6
- data/lib/socials/connector.rb +0 -47
- data/lib/socials/facebook.rb +0 -26
- data/lib/socials/google_plus.rb +0 -20
- data/lib/socials/twitter.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad16af9e8eed83d4464b5fae9e7a9c9a7297a9ad
|
4
|
+
data.tar.gz: a5684782c57c151f76b8d7ccf800a185c3acb150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 077ede3910da24f3e09f123dff2a1c4427fc2073a0e02deebaec96cc93a23e39b8c41ce660139e827720d3a0c9ab1059d99ab6cf0650c710025266be63545883
|
7
|
+
data.tar.gz: 454eca3ad67fcf47110064e92289529fa639fec08c3bfcf1ab0b510435d2a74b1cb289c3b1991498969dfdcf959951b2f19466c41694910d1a180856e0fa987c
|
data/Gemfile
CHANGED
@@ -7,24 +7,3 @@ gemspec
|
|
7
7
|
|
8
8
|
# Gems for the social LogIn based on:
|
9
9
|
# https://github.com/mohitjain/social-login-in-rails
|
10
|
-
|
11
|
-
# LogIn
|
12
|
-
gem 'devise'
|
13
|
-
|
14
|
-
# Helpers
|
15
|
-
gem 'json'
|
16
|
-
gem 'airbrake'
|
17
|
-
|
18
|
-
# OAuth
|
19
|
-
gem 'koala'
|
20
|
-
gem 'omniauth'
|
21
|
-
gem 'omniauth-oauth2'
|
22
|
-
gem 'omniauth-facebook'
|
23
|
-
gem 'omniauth-github'
|
24
|
-
gem 'omniauth-google-oauth2'
|
25
|
-
gem 'omniauth-linkedin'
|
26
|
-
gem 'omniauth-twitter'
|
27
|
-
|
28
|
-
# Social
|
29
|
-
gem 'twitter'
|
30
|
-
gem 'linkedin'
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
module Socials
|
3
|
+
module Generators
|
4
|
+
class DeviseGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
|
+
|
7
|
+
desc 'It automatically update devise files'
|
8
|
+
def copy_initializer
|
9
|
+
update_routes
|
10
|
+
update_devise_rb
|
11
|
+
update_application_rb
|
12
|
+
end
|
13
|
+
|
14
|
+
# Add the Devise+OAuth Routes
|
15
|
+
def update_routes
|
16
|
+
inject_into_file 'config/routes.rb', after: "application.routes.draw do\n" do <<-'RUBY'
|
17
|
+
devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks" }
|
18
|
+
RUBY
|
19
|
+
end
|
20
|
+
|
21
|
+
puts 'Check out your config/routes.rb where the devise OAuth route was created'.colorize(:light_green)
|
22
|
+
end
|
23
|
+
|
24
|
+
# Update the application.rb to load the socials_keys on initialize
|
25
|
+
def update_application_rb
|
26
|
+
inject_into_file 'config/application.rb', after: "class Application < Rails::Application\n" do <<-'RUBY'
|
27
|
+
|
28
|
+
# It setup your social apps
|
29
|
+
social_keys = File.join(Rails.root, 'config', 'social_keys.yml')
|
30
|
+
CONFIG = HashWithIndifferentAccess.new(YAML::load(IO.read(social_keys)))[Rails.env]
|
31
|
+
|
32
|
+
unless CONFIG.nil?
|
33
|
+
CONFIG.each do |k,v|
|
34
|
+
ENV[k.upcase] ||= v
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
RUBY
|
39
|
+
end
|
40
|
+
|
41
|
+
puts 'Just updated your config/initializers/application.rb to config the environment'.colorize(:light_blue)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add the ENV KEYs based on the social_keys.YML
|
45
|
+
def update_devise_rb
|
46
|
+
inject_into_file 'config/initializers/devise.rb', after: "config.sign_out_via = :delete\n" do <<-'RUBY'
|
47
|
+
|
48
|
+
# Config Social Keys to create the SignUps
|
49
|
+
config.sign_out_via = :get
|
50
|
+
config.omniauth :facebook, ENV["FACEBOOK_KEY"], ENV["FACEBOOK_SECRET"], { :scope => 'email, offline_access', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
|
51
|
+
config.omniauth :twitter, ENV["TWITTER_KEY"], ENV["TWITTER_SECRET"], { :scope => 'r_fullprofile, r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
|
52
|
+
config.omniauth :linkedin, ENV["LINKEDIN_KEY"], ENV["LINKEDIN_SECRET"], { :scope => 'r_fullprofile r_emailaddress', :client_options => {:ssl => {:ca_file => '/usr/lib/ssl/certs/ca-certificates.crt'}}}
|
53
|
+
config.omniauth :github, ENV['GITHUB_KEY'], ENV['GITHUB_SECRET'], scope: "user, public_repo"
|
54
|
+
config.omniauth :google_oauth2, ENV['GOOGLE_KEY'], ENV['GOOGLE_SECRET'], {}
|
55
|
+
|
56
|
+
RUBY
|
57
|
+
end
|
58
|
+
|
59
|
+
puts 'Check your config/initializers/devise.rb which was updated to have the Social Keys used (OmniAuth linked to devise)'.colorize(:light_green)
|
60
|
+
puts 'UPDATE your config/initializers/devise.rb if you need more data from the user, CHANGING the: SCOPE'.colorize(:light_yellow)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -6,8 +6,8 @@ module Socials
|
|
6
6
|
|
7
7
|
desc "It automatically create it SOCIALS initializer on the rails app"
|
8
8
|
def copy_initializer
|
9
|
-
add_templates
|
10
9
|
update_files
|
10
|
+
add_templates
|
11
11
|
end
|
12
12
|
|
13
13
|
# Add the files on the templates folder to the Rails App
|
@@ -15,7 +15,10 @@ module Socials
|
|
15
15
|
# Add the config YML (social_credentials)
|
16
16
|
template "config/social_keys.yml", "config/social_keys.yml"
|
17
17
|
template "config/social_keys.yml", "config/social_keys.example.yml"
|
18
|
-
puts 'Update your social_keys.yml with your social credentials & add it to your IGNORE & just keep the .example'.colorize(:light_yellow)
|
18
|
+
puts 'Update your social_keys.yml with your social credentials & add it to your IGNORE & just keep the .example versioned'.colorize(:light_yellow)
|
19
|
+
|
20
|
+
template 'tasks/socials.rake', 'lib/tasks/socials.rake'
|
21
|
+
puts 'Just created the socials rake tasks, check it on the GitHub README'.colorize(:light_blue)
|
19
22
|
|
20
23
|
# Add the OAuth Controller
|
21
24
|
template "controllers/omniauth_callbacks_controller.rb", "app/controllers/omniauth_callbacks_controller.rb"
|
@@ -24,24 +27,39 @@ module Socials
|
|
24
27
|
|
25
28
|
# Update files to let the Social working
|
26
29
|
def update_files
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
+
update_gemfile
|
31
|
+
end
|
32
|
+
|
33
|
+
# Add dependency GEMs & run the bundle install
|
34
|
+
def update_gemfile
|
35
|
+
inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do <<-'RUBY'
|
36
|
+
# For easy user session management
|
37
|
+
gem 'devise', '~> 3.4.1'
|
38
|
+
|
39
|
+
# Gem to generate SocialShareURLs
|
40
|
+
gem 'just_share', '~> 1.0.4'
|
41
|
+
|
42
|
+
# Social network with PaymentMethod
|
43
|
+
gem 'rents', '~> 1.0.0'
|
44
|
+
|
45
|
+
# OAuth
|
46
|
+
gem 'koala', '~> 1.11.1'
|
47
|
+
gem 'omniauth', '~> 1.2.2'
|
48
|
+
gem 'omniauth-oauth2', '~> 1.2.0'
|
49
|
+
gem 'omniauth-facebook', '~> 2.0.0'
|
50
|
+
gem 'omniauth-github', '~> 1.1.2'
|
51
|
+
gem 'omniauth-google-oauth2', '~> 0.2.6'
|
52
|
+
gem 'omniauth-linkedin', '~> 0.2.0'
|
53
|
+
gem 'omniauth-twitter', '~> 1.1.0'
|
54
|
+
|
55
|
+
# Social
|
56
|
+
gem 'twitter', '~> 5.13.0'
|
57
|
+
gem 'linkedin', '~> 1.0.0'
|
30
58
|
RUBY
|
31
59
|
end
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
application do
|
36
|
-
social_keys = File.join(Rails.root, 'config', 'social_keys.yml')
|
37
|
-
yml = YAML::load(IO.read(social_keys))
|
38
|
-
hash = HashWithIndifferentAccess.new(yml)
|
39
|
-
config = hash[Rails.env] # it is calling as error because it is a Rails CONSTANT
|
40
|
-
config.each do |k,v|
|
41
|
-
ENV[k.upcase] ||= v
|
42
|
-
end
|
43
|
-
end
|
44
|
-
puts 'UPDATE your config/initializers/application.rb and UPCASE the \'config\' to \'CONFIG\''.colorize(:light_yellow)
|
60
|
+
|
61
|
+
puts 'Check out your Gemfile to know the GEMs which were added to run the Devise OAuth integration'.colorize(:light_green)
|
62
|
+
puts 'Run `bundle install` & then run `rake socials:devise`'.red
|
45
63
|
end
|
46
64
|
end
|
47
65
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Socials
|
2
|
+
class Devise
|
3
|
+
# Generate DEVISE install & Model
|
4
|
+
def self.setup_devise
|
5
|
+
puts 'Running `rails g devise:install`'.light_blue
|
6
|
+
system 'rails g devise:install'
|
7
|
+
|
8
|
+
puts 'Running `rails g devise User`'.light_green
|
9
|
+
system 'rails g devise User'
|
10
|
+
|
11
|
+
puts 'Running `rake db:migrate` for the devise User created'.light_blue
|
12
|
+
system 'rake db:migrate'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Update the devise to load the OmNiAuth gem
|
16
|
+
def self.update_devise_rb
|
17
|
+
puts 'Running `rails g socials:devise` for the devise User created'.light_green
|
18
|
+
system 'rails g socials:devise'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/socials/version.rb
CHANGED
data/lib/socials.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: socials
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilton Garcia dos Santos Silveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -228,14 +228,13 @@ files:
|
|
228
228
|
- Rakefile
|
229
229
|
- bin/console
|
230
230
|
- bin/setup
|
231
|
+
- lib/generators/socials/devise_generator.rb
|
231
232
|
- lib/generators/socials/install_generator.rb
|
232
233
|
- lib/generators/templates/config/social_keys.yml
|
233
234
|
- lib/generators/templates/controllers/omniauth_callbacks_controller.rb
|
235
|
+
- lib/generators/templates/tasks/socials.rake
|
234
236
|
- lib/socials.rb
|
235
|
-
- lib/socials/
|
236
|
-
- lib/socials/facebook.rb
|
237
|
-
- lib/socials/google_plus.rb
|
238
|
-
- lib/socials/twitter.rb
|
237
|
+
- lib/socials/devise.rb
|
239
238
|
- lib/socials/version.rb
|
240
239
|
- socials.gemspec
|
241
240
|
homepage: http://tonfw.github.io/socials
|
data/lib/socials/connector.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'cgi'
|
2
|
-
|
3
|
-
# ParentClass which have the attrs to create the links
|
4
|
-
class Socials::Connector
|
5
|
-
# base attrs to create the links
|
6
|
-
attr_accessor :protocol # http OR https
|
7
|
-
attr_accessor :domain # api.facebook.com OR api.twitter.com OR api.google.com
|
8
|
-
attr_accessor :scope # api/v2.2 OR api OR /+/
|
9
|
-
attr_accessor :action # auth
|
10
|
-
attr_accessor :path # more paths like auth/action_auth/action_auth_param
|
11
|
-
|
12
|
-
# It constructor must be reused by it children
|
13
|
-
def initialize(params={})
|
14
|
-
# SetUp, dynamically, the attrs
|
15
|
-
setup_attrs(params)
|
16
|
-
end
|
17
|
-
|
18
|
-
# Config the app for the connection
|
19
|
-
def setup() end
|
20
|
-
# Redirect the user to the SocialNetwork SignUp page
|
21
|
-
def sign_up() end
|
22
|
-
# Return a base user to sig in it out of it lib
|
23
|
-
def get_base_user() end
|
24
|
-
# Get the user Logged hash & accesses (OAuth)
|
25
|
-
def get_current_user() end
|
26
|
-
# Get the Multi logins from the user (Pages, in Facebook case)
|
27
|
-
def get_user_admin_logins() end
|
28
|
-
# Retrieve the user accepted permissions on the SocialNetwork
|
29
|
-
def get_active_permission() end
|
30
|
-
# Share in Facebook OR tweet on Twitter
|
31
|
-
def send_msg(msg, link) end
|
32
|
-
# The current user avatar link
|
33
|
-
def get_user_avatar() end
|
34
|
-
# Post on the social
|
35
|
-
def post(message, link, img) end
|
36
|
-
|
37
|
-
protected
|
38
|
-
# SetUp all attrs
|
39
|
-
def setup_attrs(params)
|
40
|
-
# Dynamic part
|
41
|
-
params.each do |key, value|
|
42
|
-
next unless key.to_s.index('[]').nil?
|
43
|
-
self.class.__send__(:attr_accessor, :"#{key}")
|
44
|
-
self.__send__("#{key}=", value)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
data/lib/socials/facebook.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
class Socials::Facebook < Socials::Connector
|
2
|
-
# Config the app for the connection
|
3
|
-
def setup
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
# Redirect the user to the SocialNetwork SignUp page
|
8
|
-
def sign_up
|
9
|
-
|
10
|
-
end
|
11
|
-
|
12
|
-
# Return a base user to sig in it out of it lib
|
13
|
-
def get_base_user() end
|
14
|
-
# Get the user Logged hash & accesses (OAuth)
|
15
|
-
def get_current_user() end
|
16
|
-
# Get the Multi logins from the user (Pages, in Facebook case)
|
17
|
-
def get_user_admin_logins() end
|
18
|
-
# Retrieve the user accepted permissions on the SocialNetwork
|
19
|
-
def get_active_permission() end
|
20
|
-
# Share in Facebook OR tweet on Twitter
|
21
|
-
def send_msg(msg, link) end
|
22
|
-
# The current user avatar link
|
23
|
-
def get_user_avatar() end
|
24
|
-
# Post on the social
|
25
|
-
def post(message, link, img) end
|
26
|
-
end
|
data/lib/socials/google_plus.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class Socials::GooglePlus < Socials::Connector
|
2
|
-
# Config the app for the connection
|
3
|
-
def setup() end
|
4
|
-
# Redirect the user to the SocialNetwork SignUp page
|
5
|
-
def sign_up() end
|
6
|
-
# Return a base user to sig in it out of it lib
|
7
|
-
def get_base_user() end
|
8
|
-
# Get the user Logged hash & accesses (OAuth)
|
9
|
-
def get_current_user() end
|
10
|
-
# Get the Multi logins from the user (Pages, in Facebook case)
|
11
|
-
def get_user_admin_logins() end
|
12
|
-
# Retrieve the user accepted permissions on the SocialNetwork
|
13
|
-
def get_active_permission() end
|
14
|
-
# Share in Facebook OR tweet on Twitter
|
15
|
-
def send_msg(msg, link) end
|
16
|
-
# The current user avatar link
|
17
|
-
def get_user_avatar() end
|
18
|
-
# Post on the social
|
19
|
-
def post(message, link, img) end
|
20
|
-
end
|
data/lib/socials/twitter.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
class Socials::Twitter < Socials::Connector
|
2
|
-
# Config the app for the connection
|
3
|
-
def setup() end
|
4
|
-
# Redirect the user to the SocialNetwork SignUp page
|
5
|
-
def sign_up() end
|
6
|
-
# Return a base user to sig in it out of it lib
|
7
|
-
def get_base_user() end
|
8
|
-
# Get the user Logged hash & accesses (OAuth)
|
9
|
-
def get_current_user() end
|
10
|
-
# Get the Multi logins from the user (Pages, in Facebook case)
|
11
|
-
def get_user_admin_logins() end
|
12
|
-
# Retrieve the user accepted permissions on the SocialNetwork
|
13
|
-
def get_active_permission() end
|
14
|
-
# Share in Facebook OR tweet on Twitter
|
15
|
-
def send_msg(msg, link) end
|
16
|
-
# The current user avatar link
|
17
|
-
def get_user_avatar() end
|
18
|
-
# Post on the social
|
19
|
-
def post(message, link, img) end
|
20
|
-
end
|