Module: Lbrt::Utils::CLIHelper

Included in:
CLI::Alert, CLI::Metric, CLI::Service, CLI::Space
Defined in:
lib/lbrt/utils.rb

Constant Summary collapse

REGEXP_OPTIONS =
[
  :target
]

Instance Method Summary collapse

Instance Method Details

#client(klass) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/lbrt/utils.rb', line 62

def client(klass)
  librato = Librato::Client.new(
    :user => options.delete(:user),
    :token => options.delete(:token),
    :debug => options[:debug]
  )

  String.colorize = options[:color]


  options.keys.each do |key|
    if key.to_s =~ /-/
      value = options.delete(key)
      key = key.to_s.gsub('-', '_').to_sym
      options[key] = value
    end
  end

  REGEXP_OPTIONS.each do |key|
    if options[key]
      options[key] = Regexp.new(options[key])
    end
  end

  klass.new(librato, options)
end