Class: Opstat::Config
- Inherits:
-
Object
- Object
- Opstat::Config
- Includes:
- Singleton
- Defined in:
- lib/opstat-master/config.rb
Overview
A pretty sucky config class, ripe for refactoring/improving
Instance Method Summary collapse
- #get(key) ⇒ Object
- #get_influx_config ⇒ Object
- #get_mongo_config_file_path ⇒ Object
- #get_mq_config ⇒ Object
- #init_config(options) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #load_config(config_file) ⇒ Object
- #set_defaults ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 |
# File 'lib/opstat-master/config.rb', line 6 def initialize @configured = false @config = '' @config_file = '' #TODO set defaults end |
Instance Method Details
#get(key) ⇒ Object
37 38 39 |
# File 'lib/opstat-master/config.rb', line 37 def get(key) @config[key] end |
#get_influx_config ⇒ Object
29 30 31 |
# File 'lib/opstat-master/config.rb', line 29 def get_influx_config get('influxdb') end |
#get_mongo_config_file_path ⇒ Object
25 26 27 |
# File 'lib/opstat-master/config.rb', line 25 def get_mongo_config_file_path "#{File.dirname(@config_file)}/mongoid.yml" end |
#get_mq_config ⇒ Object
33 34 35 |
# File 'lib/opstat-master/config.rb', line 33 def get_mq_config get('mq') end |
#init_config(options) ⇒ Object
41 42 43 44 45 |
# File 'lib/opstat-master/config.rb', line 41 def init_config() load_config([:config_file]) set_defaults @config[:config_file] = [:config_file] end |
#load_config(config_file) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/opstat-master/config.rb', line 13 def load_config(config_file) #set_config_defaults(configfile) @config_file = config_file @config = YAML.load_file(config_file) self.set_defaults end |
#set_defaults ⇒ Object
20 21 22 23 |
# File 'lib/opstat-master/config.rb', line 20 def set_defaults @config['client']['send_data_interval'] ||= 30 @config['client']['log_level'] ||= "WARN" end |