Class: Faultline::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Faultline::Generators::InstallGenerator
- Includes:
- ActiveRecord::Generators::Migration, Rails::Generators::Migration
- Defined in:
- lib/generators/faultline/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_initializer ⇒ Object
- #create_migration ⇒ Object
- #display_post_install ⇒ Object
- #generate_modern_views ⇒ Object
- #include_loggable ⇒ Object
- #mount_routes ⇒ Object
Class Method Details
.next_migration_number(path) ⇒ Object
19 20 21 22 |
# File 'lib/generators/faultline/install_generator.rb', line 19 def self.next_migration_number(path) # Generate timestamp-based migration number for Rails 8.1+ compatibility Time.now.utc.strftime("%Y%m%d%H%M%S") end |
Instance Method Details
#create_initializer ⇒ Object
30 31 32 |
# File 'lib/generators/faultline/install_generator.rb', line 30 def create_initializer template "faultline.rb", "config/initializers/faultline.rb" end |
#create_migration ⇒ Object
24 25 26 27 28 |
# File 'lib/generators/faultline/install_generator.rb', line 24 def create_migration migration_template "migration.rb", "db/migrate/create_faultline_logged_exceptions.rb", migration_version: migration_version end |
#display_post_install ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/generators/faultline/install_generator.rb', line 53 def display_post_install say "" say "Faultline has been installed!", :green say "" say "Next steps:" say " 1. Run: bin/rails db:migrate" say " 2. Visit: /faultline" say "" say "Protect the dashboard by editing config/initializers/faultline.rb" say "" if [:modern] say "Modern views generated! Edit app/views/layouts/faultline/application.html.erb", :green say "to match your host app's navigation." say "" end end |
#generate_modern_views ⇒ Object
47 48 49 50 51 |
# File 'lib/generators/faultline/install_generator.rb', line 47 def generate_modern_views return unless [:modern] generate "faultline:customize" end |
#include_loggable ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/generators/faultline/install_generator.rb', line 38 def include_loggable inject_into_class "app/controllers/application_controller.rb", "ActionController::Base" do " include Faultline::ExceptionLoggable\n" end rescue StandardError say "Could not auto-inject ExceptionLoggable into ApplicationController.", :yellow say "Add the following to your ApplicationController:\n\n include Faultline::ExceptionLoggable\n" end |
#mount_routes ⇒ Object
34 35 36 |
# File 'lib/generators/faultline/install_generator.rb', line 34 def mount_routes route "mount Faultline::Engine => \"/faultline\"" end |