class DucksboardReporter::App
Attributes
config[R]
reporters[R]
widgets[R]
Public Class Methods
new(config)
click to toggle source
# File lib/ducksboard_reporter.rb, line 40 def initialize(config) @config = symbolize_keys(config) register_reporters register_widgets end
Public Instance Methods
register_reporters()
click to toggle source
# File lib/ducksboard_reporter.rb, line 70 def register_reporters @reporters = {} @config[:reporters].each do |config| reporter = Reporters.const_get(config[:type], false).new(config[:name], config[:options]) @reporters[reporter.name] = reporter end end
register_widgets()
click to toggle source
# File lib/ducksboard_reporter.rb, line 79 def register_widgets @widgets = [] @config[:widgets].each do |config| reporter = @reporters.fetch(config[:reporter]) unless reporter logger.error("Cannot find reporter #{config[:reporter]}") exit end widget = Widget.new(config[:type], config[:id], reporter, config) @widgets << widget end end
start()
click to toggle source
# File lib/ducksboard_reporter.rb, line 59 def start Signal.trap("INT") { exit } Ducksboard.api_key = config[:api_key] start_reporters start_widgets sleep # let the actors continue their work end
start_reporters()
click to toggle source
# File lib/ducksboard_reporter.rb, line 94 def start_reporters @reporters.each {|_, reporter| reporter.start } end
start_widgets()
click to toggle source
# File lib/ducksboard_reporter.rb, line 98 def start_widgets @widgets.each(&:start) end
symbolize_keys(hash)
click to toggle source
# File lib/ducksboard_reporter.rb, line 46 def symbolize_keys(hash) hash.inject({}) do |result, (key, value)| new_key = key.is_a?(String) ? key.to_sym : key new_value = case value when Hash then symbolize_keys(value) when Array then value.map {|v| symbolize_keys(v) } else value end result[new_key] = new_value result end end
Private Instance Methods
logger()
click to toggle source
# File lib/ducksboard_reporter.rb, line 104 def logger DucksboardReporter.logger end