Class: MissionControl::Web::Install::MiddlewareGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- MissionControl::Web::Install::MiddlewareGenerator
- Defined in:
- lib/generators/mission_control/web/install/middleware_generator.rb
Constant Summary collapse
- INITIALIZER_FILE_PATH =
"config/initializers/mission_control_web.rb"
Instance Method Summary collapse
- #create_initializer_file ⇒ Object
- #insert_middleware_configuration ⇒ Object
- #toggle_middleware_enabled ⇒ Object
Instance Method Details
#create_initializer_file ⇒ Object
5 6 7 8 9 10 |
# File 'lib/generators/mission_control/web/install/middleware_generator.rb', line 5 def create_initializer_file create_file INITIALIZER_FILE_PATH, <<~RUBY, skip: true Rails.application.configure do end RUBY end |
#insert_middleware_configuration ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/mission_control/web/install/middleware_generator.rb', line 12 def insert_middleware_configuration initializer = <<~RUBY # Middleware config.mission_control.web.host_application_name = "My App" config.mission_control.web.redis = Redis.new(url: ENV.fetch("REDIS_URL", "redis://localhost:6379/0")) RUBY insert_into_file INITIALIZER_FILE_PATH, indent(initializer), after: "Rails.application.configure do\n" end |
#toggle_middleware_enabled ⇒ Object
22 23 24 |
# File 'lib/generators/mission_control/web/install/middleware_generator.rb', line 22 def toggle_middleware_enabled gsub_file INITIALIZER_FILE_PATH, "middleware_enabled = false", "middleware_enabled = true" end |