Class: StandardCircuit::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- StandardCircuit::Generators::InstallGenerator
- Defined in:
- lib/generators/standard_circuit/install/install_generator.rb
Overview
Installs StandardCircuit in a host Rails application.
By default, writes config/initializers/standard_circuit.rb with commented-out examples covering the public Config DSL.
When --with-health-endpoint is passed, also writes config/initializers/standard_circuit_health.rb (which requires the opt-in HealthController) and prints the route line the host should add to config/routes.rb to expose the endpoint.
Idempotent: re-running on an existing initializer logs and skips. Pass --force to overwrite.
Instance Method Summary collapse
- #create_health_initializer_file ⇒ Object
- #create_initializer_file ⇒ Object
- #print_health_route_hint ⇒ Object
Instance Method Details
#create_health_initializer_file ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/standard_circuit/install/install_generator.rb', line 48 def create_health_initializer_file return unless [:with_health_endpoint] path = "config/initializers/standard_circuit_health.rb" if File.exist?(File.join(destination_root, path)) && ![:force] say_status("skip", "#{path} already present, skipping (use --force to overwrite)", :yellow) else template "health_initializer.rb.tt", path end end |
#create_initializer_file ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/standard_circuit/install/install_generator.rb', line 38 def create_initializer_file path = "config/initializers/standard_circuit.rb" if File.exist?(File.join(destination_root, path)) && ![:force] say_status("skip", "#{path} already present, skipping (use --force to overwrite)", :yellow) return end template "initializer.rb.tt", path end |
#print_health_route_hint ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/generators/standard_circuit/install/install_generator.rb', line 59 def print_health_route_hint return unless [:with_health_endpoint] say "" say "=" * 79 say "StandardCircuit health endpoint installed." say "" say "Add the following to config/routes.rb to expose the endpoint:" say "" say ' get "/health", to: "standard_circuit/health#show"' say "" say "The controller returns 503 when the rolled-up circuit health is" say ":critical and 200 otherwise — wire it up to your load balancer." say "=" * 79 say "" end |