Class: Frame::Generators::DeviseOmniauthGenerator

Inherits:
Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb

Instance Method Summary collapse

Methods inherited from Base

banner, source_root

Instance Method Details

#add_callback_controllerObject



27
28
29
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 27

def add_callback_controller
  template('app/controllers/omniauth_callbacks_controller.rb')
end

#add_default_layoutObject



46
47
48
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 46

def add_default_layout
  template('app/views/layouts/defaults.html.erb')
end

#add_do_routesObject



35
36
37
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 35

def add_do_routes
  template('config/routes.rb')
end

#add_omni_servicesObject



39
40
41
42
43
44
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 39

def add_omni_services
  add_if_missing('config/initializers/devise.rb', "\n  config.omniauth :twitter, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
  add_if_missing('config/initializers/devise.rb', "\n  config.omniauth :google_oauth2, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
  add_if_missing('config/initializers/devise.rb', "\n  config.omniauth :facebook, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
  uncomment_lines('config/initializers/devise.rb', "config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
end

#add_omniauth_to_usersObject



75
76
77
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 75

def add_omniauth_to_users
  generate("migration AddOmniauthToUsers provider:string uid:string")
end

#add_username_to_usersObject



79
80
81
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 79

def add_username_to_users
  generate("migration AddUsernameToUsers username:string")
end

#install_deviseObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 11

def install_devise
  gem("rspec-rails", :group => "test, development")
  gem("cucumber-rails", :group => "test, development")
  gem("devise")
  gem("omniauth-twitter")
  gem("omniauth-facebook")
  gem("omniauth-github")
  gem("omniauth-google-oauth2")
  Bundler.with_clean_env do
    run "bundle"
  end
  generate("devise:install")
  generate("devise", "User")
  generate("devise:views")
end

#make_omniauthableObject



31
32
33
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 31

def make_omniauthable
  template('app/models/user.rb')
end

#replace_email_usernameObject



69
70
71
72
73
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 69

def replace_email_username
  template("app/views/devise/sessions/new.html.erb")
  template("app/views/devise/registrations/new.html.erb")
  template("app/views/devise/registrations/edit.html.erb")
end

#update_dbObject



83
84
85
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 83

def update_db
  rake("db:migrate")
end

#update_environmentsObject



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 56

def update_environments
  application(nil, :env => "production") do "
  config.action_mailer.default_url_options = { :host => \"econtriver.com\" }
  config.action_mailer.smtp_settings = { :openssl_verify_mode  => 'none' }"
  end
  application(nil, :env => "test") do
    "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
  end
  application(nil, :env => "development") do
    "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
  end
end

#update_initializersObject



50
51
52
53
54
# File 'lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb', line 50

def update_initializers
  gsub_file 'config/initializers/devise.rb', /config.mailer_sender = "[email protected]"/ do
    "config.mailer_sender = \"[email protected]\""
  end
end