module Riemann::Babbler::Options

Public Class Methods

included(base) click to toggle source
# File lib/riemann/babbler/options.rb, line 49
def self.included(base)
  Configatron.log.level = Logger::FATAL
  base.extend(self)
end

Public Instance Methods

merge_config(file) click to toggle source

@return

# File lib/riemann/babbler/options.rb, line 15
def merge_config(file)
  config_from_file = if File.exist?(file)
                       YAML.load_file(file).to_hash
                     else
                       log :error, "Can't load config file #{file}"
                       Hash.new
                     end
  config_default   = opts.to_hash
  result_config    = config_default.deep_merge(config_from_file)
  opts.configure_from_hash(result_config)
end
name_to_underscore(name = 'Riemann::Babbler::Plugin::TwCli_3') click to toggle source

return string tw_cli_3

# File lib/riemann/babbler/options.rb, line 34
def name_to_underscore(name = 'Riemann::Babbler::Plugin::TwCli_3')
  name.split('::').last.gsub(/(\p{Lower})(\p{Upper})/, "\\1_\\2").downcase
end
opts() click to toggle source
# File lib/riemann/babbler/options.rb, line 10
def opts
  @@configatron
end
opts_reset!(hash) click to toggle source

return configatron from hash

# File lib/riemann/babbler/options.rb, line 28
def opts_reset!(hash)
  opts.reset!
  opts.configure_from_hash(hash)
end
underscore_to_name(name = 'tw_cli_3', parent = 'Riemann::Babbler::Plugin') click to toggle source

return string Riemann::Babbler::Plugin::TwCli_3

# File lib/riemann/babbler/options.rb, line 39
def underscore_to_name(name = 'tw_cli_3', parent = 'Riemann::Babbler::Plugin')
  parent + '::' + name.to_s.split('_').map { |part|
    if part.to_i != 0
      "_#{part}"
    else
      part.capitalize
    end
  }.join('')
end