Class: Rodauth::Rails::Generators::InstallGenerator

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

Constant Summary collapse

SEQUEL_ADAPTERS =
{
  "postgresql"      => RUBY_ENGINE == "jruby" ? "postgresql" : "postgres",
  "mysql2"          => RUBY_ENGINE == "jruby" ? "mysql" : "mysql2",
  "sqlite3"         => "sqlite",
  "oracle_enhanced" => "oracle",
  "sqlserver"       => RUBY_ENGINE == "jruby" ? "mssql" : "tinytds",
}
MAILER_VIEWS =
%w[
  email_auth
  password_changed
  reset_password
  unlock_account
  verify_account
  verify_login_change
]

Instance Method Summary collapse

Instance Method Details

#create_account_modelObject



54
55
56
# File 'lib/generators/rodauth/install_generator.rb', line 54

def 
  template "app/models/account.rb", "app/models/#{table_prefix}.rb"
end

#create_fixturesObject



68
69
70
71
72
73
74
# File 'lib/generators/rodauth/install_generator.rb', line 68

def create_fixtures
  generator_options = ::Rails.configuration.generators.options
  if generator_options[:test_unit][:fixture] && generator_options[:test_unit][:fixture_replacement].nil?
    test_dir = generator_options[:rails][:test_framework] == :rspec ? "spec" : "test"
    template "test/fixtures/accounts.yml", "#{test_dir}/fixtures/#{table_prefix.pluralize}.yml"
  end
end

#create_mailerObject



58
59
60
61
62
63
64
65
66
# File 'lib/generators/rodauth/install_generator.rb', line 58

def create_mailer
  return unless defined?(ActionMailer)

  template "app/mailers/rodauth_mailer.rb"

  MAILER_VIEWS.each do |view|
    copy_file "app/views/rodauth_mailer/#{view}.text.erb"
  end
end

#create_rodauth_appObject



45
46
47
48
# File 'lib/generators/rodauth/install_generator.rb', line 45

def create_rodauth_app
  template "app/misc/rodauth_app.rb"
  template "app/misc/rodauth_main.rb"
end

#create_rodauth_controllerObject



50
51
52
# File 'lib/generators/rodauth/install_generator.rb', line 50

def create_rodauth_controller
  template "app/controllers/rodauth_controller.rb"
end

#create_rodauth_initializerObject



41
42
43
# File 'lib/generators/rodauth/install_generator.rb', line 41

def create_rodauth_initializer
  template "config/initializers/rodauth.rb"
end

#generate_rodauth_migrationObject



35
36
37
38
39
# File 'lib/generators/rodauth/install_generator.rb', line 35

def generate_rodauth_migration
  invoke "rodauth:migration", migration_features,
    name: "create_rodauth",
    prefix: table_prefix
end

#show_instructionsObject



76
77
78
# File 'lib/generators/rodauth/install_generator.rb', line 76

def show_instructions
  readme "INSTRUCTIONS" if behavior == :invoke
end