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
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/rodauth/install_generator.rb', line 43 def add_gems if activerecord? && !sequel? gem "sequel-activerecord_connection", "~> 2.0", require: false, comment: "Enables Sequel to use Active Record's database connection" gem "after_commit_everywhere", "~> 1.1", require: false, 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", require: false, comment: "Used by Rodauth for password hashing" else gem "bcrypt", "~> 3.1", require: false, comment: "Used by Rodauth for password hashing" end if jwt? gem "jwt", "~> 2.9", require: false, comment: "Used by Rodauth for JWT support" end gem "tilt", "~> 2.4", require: false, comment: "Used by Rodauth for rendering built-in view and email templates" end |
#create_account_model ⇒ Object
63 64 65 |
# File 'lib/generators/rodauth/install_generator.rb', line 63 def create_account_model template "app/models/account.rb", "app/models/#{table_prefix}.rb" end |
#create_fixtures ⇒ Object
67 68 69 70 71 72 73 |
# File 'lib/generators/rodauth/install_generator.rb', line 67 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
38 39 40 41 |
# File 'lib/generators/rodauth/install_generator.rb', line 38 def create_rodauth_app template "app/misc/rodauth_app.rb" template "app/misc/rodauth_main.rb" end |
#create_rodauth_controller ⇒ Object
59 60 61 |
# File 'lib/generators/rodauth/install_generator.rb', line 59 def create_rodauth_controller template "app/controllers/rodauth_controller.rb" end |
#create_rodauth_initializer ⇒ Object
34 35 36 |
# File 'lib/generators/rodauth/install_generator.rb', line 34 def create_rodauth_initializer template "config/initializers/rodauth.rb" end |
#generate_rodauth_migration ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/generators/rodauth/install_generator.rb', line 26 def generate_rodauth_migration invoke "rodauth:migration", migration_features, name: "create_rodauth", prefix: table_prefix, force: [:force], skip: [:skip] end |
#show_instructions ⇒ Object
75 76 77 |
# File 'lib/generators/rodauth/install_generator.rb', line 75 def show_instructions readme "INSTRUCTIONS" if behavior == :invoke && !json? && !jwt? end |