Class: Rodauth::Rails::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Rodauth::Rails::Generators::InstallGenerator
- 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
- #add_gems ⇒ Object
- #create_account_model ⇒ Object
- #create_fixtures ⇒ Object
- #create_rodauth_app ⇒ Object
- #create_rodauth_controller ⇒ Object
- #create_rodauth_initializer ⇒ Object
- #generate_rodauth_migration ⇒ Object
- #show_instructions ⇒ Object
Instance Method Details
#add_gems ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/generators/rodauth/install_generator.rb', line 41 def add_gems if activerecord? && !sequel? gem "sequel-activerecord_connection", "~> 2.0", comment: "Enables Sequel to use Active Record's database connection" gem "after_commit_everywhere", "~> 1.1", comment: "Required for Sequel's transaction hooks to work in all cases (on Active Record < 7.2)" if ActiveRecord.version < Gem::Version.new("7.2") end if argon2? gem "argon2", "~> 2.3", comment: "Used by Rodauth for password hashing" else gem "bcrypt", "~> 3.1", comment: "Used by Rodauth for password hashing" end if jwt? gem "jwt", "~> 2.9", comment: "Used by Rodauth for JWT support" end gem "tilt", "~> 2.4", comment: "Used by Rodauth for rendering built-in view and email templates" end |
#create_account_model ⇒ Object
61 62 63 |
# File 'lib/generators/rodauth/install_generator.rb', line 61 def create_account_model template "app/models/account.rb", "app/models/#{table_prefix}.rb" end |
#create_fixtures ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/generators/rodauth/install_generator.rb', line 65 def create_fixtures = ::Rails.configuration.generators. if [:test_unit][:fixture] && [:test_unit][:fixture_replacement].nil? test_dir = [:rails][:test_framework] == :rspec ? "spec" : "test" template "test/fixtures/accounts.yml", "#{test_dir}/fixtures/#{table_prefix.pluralize}.yml" end end |
#create_rodauth_app ⇒ Object
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_controller ⇒ Object
57 58 59 |
# File 'lib/generators/rodauth/install_generator.rb', line 57 def create_rodauth_controller template "app/controllers/rodauth_controller.rb" end |
#create_rodauth_initializer ⇒ Object
32 33 34 |
# File 'lib/generators/rodauth/install_generator.rb', line 32 def create_rodauth_initializer template "config/initializers/rodauth.rb" end |
#generate_rodauth_migration ⇒ Object
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_instructions ⇒ Object
73 74 75 |
# File 'lib/generators/rodauth/install_generator.rb', line 73 def show_instructions readme "INSTRUCTIONS" if behavior == :invoke && !json? && !jwt? end |