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
27
28
29
# 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)

  template 'tasks/recreate.rake', 'lib/tasks/recreate.rake'
  puts 'Now you can easy rebase (clean up) your DB using rake db:recreate'.colorize(:light_green)

  # 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



32
33
34
# File 'lib/generators/socials/install_generator.rb', line 32

def update_files
  update_gemfile
end

#update_gemfileObject

Add dependency GEMs & run the bundle install



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
64
65
66
67
68
69
# File 'lib/generators/socials/install_generator.rb', line 37

def update_gemfile
  inject_into_file 'Gemfile', after: "source 'https://rubygems.org'\n" do "# Easier & faster then ERB\ngem 'slim-rails', '~> 2.1.5'\n\n# For easy user session management\ngem 'devise', '~> 3.4.1'\n\n# Gem to generate SocialShareURLs\ngem 'just_share', '~> 1.0.4'\n\n# Social network with PaymentMethod\ngem 'rents', '~> 1.0.0'\n\n# OAuth\ngem 'koala', '~> 1.11.1'\ngem 'omniauth', '~> 1.2.2'\ngem 'omniauth-oauth2', '~> 1.2.0'\ngem 'omniauth-facebook', '~> 2.0.0'\ngem 'omniauth-github', '~> 1.1.2'\ngem 'omniauth-google-oauth2', '~> 0.2.6'\ngem 'omniauth-linkedin', '~> 0.2.0'\ngem 'omniauth-twitter', '~> 1.1.0'\n\n# Social\ngem 'twitter', '~> 5.13.0'\ngem 'linkedin', '~> 1.0.0'\n    RUBY\n  end\n\n  puts 'Check out your Gemfile to know the GEMs which were added to run the Devise OAuth integration'.colorize(:light_green)\n  puts 'Run `bundle install` & then run `rake socials:devise`'.red\nend\n"