Module: KafkaConsumer::Generators::Concerns::Configuration

Extended by:
ActiveSupport::Concern
Included in:
KafkaConsumer::Generators::ConsumerGenerator, InboxConsumerGenerator, InstallGenerator, RegexpConsumerGenerator
Defined in:
lib/generators/kafka_consumer/concerns/configuration.rb

Constant Summary collapse

CONFIG_PATH =
"config/kafka_consumer.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_consumer/concerns/configuration.rb', line 11

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

  generate = ask "The file #{config_path} does not appear to exist. " \
               "Would you like to generate it? [Yn]"

  generator_name = "kafka_consumer:install"
  if (generate.presence || "y").casecmp("y").zero?
    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