Class: Pu::Rodauth::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Pu::Rodauth::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration, PlutoniumGenerators::Concerns::Actions
- Defined in:
- lib/generators/pu/rodauth/install_generator.rb
Instance Method Summary collapse
- #add_rodauth ⇒ Object
- #create_install_migration ⇒ Object
- #create_rodauth_app ⇒ Object
- #create_rodauth_controller ⇒ Object
- #create_rodauth_initializer ⇒ Object
- #create_url_options_initializer ⇒ Object
- #eject_layout ⇒ Object
- #show_instructions ⇒ Object
Instance Method Details
#add_rodauth ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 17 def add_rodauth gems = %w[bcrypt sequel-activerecord_connection tilt rodauth-rails].reject { |g| gem_in_bundle?(g) } return if gems.empty? Bundler.with_unbundled_env do gems.each { |gem| run "bundle add #{gem}" } end end |
#create_install_migration ⇒ Object
43 44 45 46 47 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 43 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_app ⇒ Object
34 35 36 37 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 34 def create_rodauth_app template "app/rodauth/rodauth_app.rb" template "app/rodauth/rodauth_plugin.rb" end |
#create_rodauth_controller ⇒ Object
30 31 32 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 30 def create_rodauth_controller template "app/controllers/rodauth_controller.rb" end |
#create_rodauth_initializer ⇒ Object
26 27 28 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 26 def create_rodauth_initializer template "config/initializers/rodauth.rb" end |
#create_url_options_initializer ⇒ Object
39 40 41 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 39 def template "config/initializers/url_options.rb" end |
#eject_layout ⇒ Object
49 50 51 52 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 49 def eject_layout file = "app/views/layouts/rodauth.html.erb" FileUtils.cp Plutonium.root.join(file), Rails.root.join(file) end |
#show_instructions ⇒ Object
54 55 56 |
# File 'lib/generators/pu/rodauth/install_generator.rb', line 54 def show_instructions readme "INSTRUCTIONS" if behavior == :invoke end |