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",
}

Instance Method Summary collapse

Instance Method Details

#create_account_modelObject



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

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

#create_fixturesObject



49
50
51
52
53
54
55
# File 'lib/generators/rodauth/install_generator.rb', line 49

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_rodauth_appObject



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

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

#create_rodauth_controllerObject



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

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

#create_rodauth_initializerObject



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

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

#generate_rodauth_migrationObject



26
27
28
29
30
# File 'lib/generators/rodauth/install_generator.rb', line 26

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

#show_instructionsObject



57
58
59
# File 'lib/generators/rodauth/install_generator.rb', line 57

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