Class: MongodbGraphite::Configuration
- Inherits:
-
Object
- Object
- MongodbGraphite::Configuration
- Defined in:
- lib/mongodb-graphite/configuration.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(dir, yml) ⇒ Configuration
constructor
A new instance of Configuration.
- #reload(dir, yml) ⇒ Object
Constructor Details
#initialize(dir, yml) ⇒ Configuration
Returns a new instance of Configuration.
5 6 7 |
# File 'lib/mongodb-graphite/configuration.rb', line 5 def initialize(dir, yml) reload(dir, yml) end |
Instance Method Details
#[](key) ⇒ Object
36 37 38 |
# File 'lib/mongodb-graphite/configuration.rb', line 36 def [](key) @config[key] end |
#reload(dir, yml) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mongodb-graphite/configuration.rb', line 9 def reload(dir, yml) @config = { 'log_dir' => 'log', 'pid_dir' => 'pids', 'graphite' => 'localhost:3333', 'mongodb' => 'localhost:27017', 'interval' => 3, #in seconds 'instances_file' => nil, 'daemon_name' => 'mongodb-graphite' } config_file_path = File.join(dir, 'config', yml) if File.exist? config_file_path config_file = YAML.load_file(config_file_path) @config.keys.each do |key| value = config_file[key.to_s] @config[key] = value unless value.nil? end end @config[:mongodb_graphite_dir] = dir ['log_dir', 'pid_dir', 'instances_file'].each do |k| @config[k] = File.absolute_path(@config[k], dir) end end |