Class: Socials::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/socials/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_templatesObject

Add the files on the templates folder to the Rails App



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/socials/install_generator.rb', line 14

def add_templates
  # Add the config YML (social_credentials)
  template "config/social_keys.yml", "config/social_keys.yml"
  template "config/social_keys.yml", "config/social_keys.example.yml"
  puts 'Update your social_keys.yml with your social credentials & add it to your IGNORE & just keep the .example versioned'.colorize(:light_yellow)

  template 'tasks/socials.rake', 'lib/tasks/socials.rake'
  puts 'Just created the socials rake tasks, check it on the GitHub README'.colorize(:light_blue)

  # Add the OAuth Controller
  template "controllers/omniauth_callbacks_controller.rb", "app/controllers/omniauth_callbacks_controller.rb"
  puts 'Check out you your app/controllers/omniauth_callbacks_controller.rb which persist the social user through devise'.colorize(:light_green)
end

#copy_initializerObject



8
9
10
11
# File 'lib/generators/socials/install_generator.rb', line 8

def copy_initializer
  update_files
  add_templates
end

#update_filesObject

Update files to let the Social working



29
30
31
# File 'lib/generators/socials/install_generator.rb', line 29

def update_files
  update_gemfile
end

#update_gemfileObject

Add dependency GEMs & run the bundle install



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/generators/socials/install_generator.rb', line 34

def update_gemfile
  inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do <<-'RUBY'
# For easy user session management
gem 'devise', '~> 3.4.1'

# Gem to generate SocialShareURLs
gem 'just_share', '~> 1.0.4'

# Social network with PaymentMethod
gem 'rents', '~> 1.0.0'

# OAuth
gem 'koala', '~> 1.11.1'
gem 'omniauth', '~> 1.2.2'
gem 'omniauth-oauth2', '~> 1.2.0'
gem 'omniauth-facebook', '~> 2.0.0'
gem 'omniauth-github', '~> 1.1.2'
gem 'omniauth-google-oauth2', '~> 0.2.6'
gem 'omniauth-linkedin', '~> 0.2.0'
gem 'omniauth-twitter', '~> 1.1.0'

# Social
gem 'twitter', '~> 5.13.0'
gem 'linkedin', '~> 1.0.0'
    RUBY
  end

  puts 'Check out your Gemfile to know the GEMs which were added to run the Devise OAuth integration'.colorize(:light_green)
  puts 'Run `bundle install` & then run `rake socials:devise`'.red
end