Module: KafkaProducer::Generators::Concerns::Configuration

Extended by:
ActiveSupport::Concern
Included in:
InstallGenerator
Defined in:
lib/generators/kafka_producer/concerns/configuration.rb

Constant Summary collapse

CONFIG_PATH =
"config/kafka_producer.yml"

Instance Method Summary collapse

Instance Method Details

#check_config_file!Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/generators/kafka_producer/concerns/configuration.rb', line 11

def check_config_file!
  config_path = File.expand_path(CONFIG_PATH)
  return if File.exist?(config_path)

  generator_name = "kafka_producer:install"
  if yes?(
    "The file #{config_path} does not appear to exist." \
    " Would you like to generate it?"
  )
    generate generator_name
  else
    raise Rails::Generators::Error, "Please generate #{config_path} " \
                   "by running `bin/rails g #{generator_name}` " \
                   "or add this file manually."
  end
end