class DataCollector::ConfigFile
Public Class Methods
[](key)
click to toggle source
# File lib/data_collector/config_file.rb, line 22 def self.[](key) init @config[key] end
[]=(key, value)
click to toggle source
# File lib/data_collector/config_file.rb, line 27 def self.[]=(key, value) init @config[key] = value File.open("#{path}/config.yml", 'w') do |f| f.puts @config.to_yaml end end
include?(key)
click to toggle source
# File lib/data_collector/config_file.rb, line 35 def self.include?(key) init @config.include?(key) end
path()
click to toggle source
# File lib/data_collector/config_file.rb, line 14 def self.path @config_file_path end
path=(config_file_path)
click to toggle source
# File lib/data_collector/config_file.rb, line 18 def self.path=(config_file_path) @config_file_path = config_file_path end
version()
click to toggle source
# File lib/data_collector/config_file.rb, line 10 def self.version '0.0.1' end
Private Class Methods
discover_config_file_path()
click to toggle source
# File lib/data_collector/config_file.rb, line 50 def self.discover_config_file_path if @config_file_path.nil? || @config_file_path.empty? if File.exist?('config.yml') @config_file_path = '.' elsif File.exist?("config/config.yml") @config_file_path = 'config' end end end
init()
click to toggle source
# File lib/data_collector/config_file.rb, line 41 def self.init discover_config_file_path if @config.empty? config = YAML::load_file("#{path}/config.yml") @config = process(config) end end
process(config)
click to toggle source
# File lib/data_collector/config_file.rb, line 60 def self.process(config) new_config = {} config.each do |k, v| if config[k].is_a?(Hash) v = process(v) end new_config.store(k.to_sym, v) end new_config end