Module: FIR::Config
- Included in:
- Util::ClassMethods
- Defined in:
- lib/tail_f_rabbitmq/util/config.rb
Constant Summary collapse
- CONFIG_PATH =
"#{ENV['HOME']}/.tail_f_rabbitmq_config"
Instance Method Summary collapse
- #config ⇒ Object
- #default_config ⇒ Object
- #reload_config ⇒ Object
- #reset_config ⇒ Object
- #write_config(hash) ⇒ Object
Instance Method Details
#config ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/tail_f_rabbitmq/util/config.rb', line 15 def config unless File.exist?(CONFIG_PATH) @config = default_config write_config @config end @config ||= YAML.load_file(CONFIG_PATH).deep_symbolize_keys end |
#default_config ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/tail_f_rabbitmq/util/config.rb', line 6 def default_config config = { url: "amqp://guest:guest@localhost:5672", queue: "log_line", file_filter: ".log", eof: "END" } end |
#reload_config ⇒ Object
23 24 25 |
# File 'lib/tail_f_rabbitmq/util/config.rb', line 23 def reload_config @config = YAML.load_file(CONFIG_PATH).deep_symbolize_keys end |
#reset_config ⇒ Object
31 32 33 34 |
# File 'lib/tail_f_rabbitmq/util/config.rb', line 31 def reset_config @config = default_config write_config @config end |
#write_config(hash) ⇒ Object
27 28 29 |
# File 'lib/tail_f_rabbitmq/util/config.rb', line 27 def write_config(hash) File.open(CONFIG_PATH, 'w+') { |f| f << YAML.dump(hash) } end |