Class: Warren::App::Config
- Inherits:
-
Object
- Object
- Warren::App::Config
- Defined in:
- lib/warren/app/config.rb
Overview
Handles the initial creation of the configuration object
Constant Summary collapse
- TEMPLATE =
We keep the template as plain text as it allows us to add comments
<<~TEMPLATE # By default the development environment just logs the message and # payload. If you wish to enable broadcasting in development mode, # the easiest way to do so is to set the ENV WARREN_TYPE. # For example # `WARREN_TYPE=broadcast bundle exec rails s` # This will override the setting in warren.yml development: type: log # Log mode does not actually use this configuration, but # it is provided for convenience when broadcast mode is enabled. # The provided settings are the default options of RabbitMQ # DO NOT commit sensitive information in this file. Instead you may # use the WARREN_CONNECTION_URI environmental variable config: server: host: localhost port: 5672 username: guest password: guest vhost: %<vhost>s frame_max: 0 heartbeat: 30 exchange: %<exchange>s routing_key_prefix: development # The test environment sets up a test message handler, which lets # you make assertions about which messages have been sent. # See: https://rubydoc.info/gems/sanger_warren/Warren/Handler/Test test: type: test config: routing_key_prefix: test # You are encouraged to use the WARREN_CONNECTION_URI environmental # variable to configure your production environment. Under no # circumstances should you commit sensitive information in the file. TEMPLATE
Class Method Summary collapse
-
.invoke(shell, path:, exchange: nil) ⇒ Void
Triggers the configuration task.
Instance Method Summary collapse
-
#initialize(shell, path:, exchange: nil) ⇒ Config
constructor
Generates a new warren.yml file at #path.
-
#invoke ⇒ Void
Create a new configuration yaml file at #path using sensible defaults and the provided #exchange.
Constructor Details
#initialize(shell, path:, exchange: nil) ⇒ Config
Generates a new warren.yml file at #path. Usually invoked via the ‘warren config` cli command
67 68 69 70 71 |
# File 'lib/warren/app/config.rb', line 67 def initialize(shell, path:, exchange: nil) @shell = shell @path = path @exchange = exchange end |
Class Method Details
.invoke(shell, path:, exchange: nil) ⇒ Void
Triggers the configuration task. Primarily called by the Thor CLI. Will either use arguments passed in from the command line, or prompt the user for them if missing.
55 56 57 |
# File 'lib/warren/app/config.rb', line 55 def self.invoke(shell, path:, exchange: nil) new(shell, path: path, exchange: exchange).invoke end |
Instance Method Details
#invoke ⇒ Void
Create a new configuration yaml file at #path using sensible defaults and the provided #exchange. If #exchange is nil, prompts the user
79 80 81 82 83 84 85 86 |
# File 'lib/warren/app/config.rb', line 79 def invoke return unless check_file? @exchange ||= ask_exchange # Update our exchange before we do anything File.open(@path, 'w') do |file| file.write payload end end |