Class: Pu::Rodauth::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_rodauthObject



15
16
17
18
19
20
21
# File 'lib/generators/pu/rodauth/install_generator.rb', line 15

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



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

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



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

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

#create_rodauth_controllerObject



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

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

#create_rodauth_initializerObject



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

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

#create_url_options_initializerObject



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

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

#eject_layoutObject



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

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

#show_instructionsObject



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

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