Class: Pu::Rodauth::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/pu/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

#add_rodauthObject



22
23
24
25
26
27
28
# File 'lib/generators/pu/rodauth/install_generator.rb', line 22

def add_rodauth
  Bundler.with_unbundled_env do
    %w[bcrypt sequel-activerecord_connection tilt rodauth-rails].each do |gem|
      run "bundle add #{gem}"
    end
  end
end

#create_install_migrationObject



47
48
49
50
51
# File 'lib/generators/pu/rodauth/install_generator.rb', line 47

def create_install_migration
  return unless activerecord_adapter == "postgresql"

  migration_template "db/migrate/install_rodauth.rb", "db/migrate/install_rodauth.rb" # , File.join(db_migrate_path, "#{migration_name}.rb")
end

#create_rodauth_appObject



38
39
40
41
# File 'lib/generators/pu/rodauth/install_generator.rb', line 38

def create_rodauth_app
  template "app/rodauth/rodauth_app.rb"
  template "app/rodauth/rodauth_plugin.rb"
end

#create_rodauth_controllerObject



34
35
36
# File 'lib/generators/pu/rodauth/install_generator.rb', line 34

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

#create_rodauth_initializerObject



30
31
32
# File 'lib/generators/pu/rodauth/install_generator.rb', line 30

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

#create_url_options_initializerObject



43
44
45
# File 'lib/generators/pu/rodauth/install_generator.rb', line 43

def create_url_options_initializer
  template "config/initializers/url_options.rb"
end

#eject_layoutObject



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

def eject_layout
  file = "app/views/layouts/rodauth.html.erb"
  FileUtils.cp Plutonium.root.join(file), Rails.root.join(file)
end

#show_instructionsObject



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

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