lib/riemann/babbler/options.rb in riemann-babbler-2.0.0pre7 vs lib/riemann/babbler/options.rb in riemann-babbler-2.0.0pre8

- old
+ new

@@ -22,15 +22,23 @@ config_default = opts.to_hash result_config = config_default.deep_merge(config_from_file) opts.configure_from_hash(result_config) end - def name_to_underscore(name = 'Riemann::Babbler::Plugin::TwCli') + # return string tw_cli_3 + def name_to_underscore(name = 'Riemann::Babbler::Plugin::TwCli_3') name.split('::').last.gsub(/(\p{Lower})(\p{Upper})/, "\\1_\\2").downcase end - def underscore_to_name(underscore = 'tw_cli') - underscore.split('_').map { |part| part.capitalize }.join('') + # return string Riemann::Babbler::Plugin::TwCli_3 + 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 def self.included(base) Configatron.log.level = Logger::FATAL base.extend(self)