Class: Fuey::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/fuey_client/fuey/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_to_config_dir = "", notifications = nil) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
# File 'lib/fuey_client/fuey/client.rb', line 13

def initialize(path_to_config_dir="", notifications=nil)
  Configurethis.root_path = path_to_config_dir

  notifications = Config::Fuey.notifications if notifications.nil?
  setup_notifications notifications
end

Instance Method Details

#reporterObject



20
21
22
# File 'lib/fuey_client/fuey/client.rb', line 20

def reporter
  @_reporter ||= Reporters::NotificationQueue.new(Fuey::Redis.instance)
end

#runObject



24
25
26
27
28
29
30
# File 'lib/fuey_client/fuey/client.rb', line 24

def run
  TraceRepository.new.all.each do |trace|
    trace.receiver = reporter
    output = trace.run
    Log.write %([#{trace.name}] #{output})
  end
end

#setup_notifications(notifications) ⇒ Object



32
33
34
35
36
# File 'lib/fuey_client/fuey/client.rb', line 32

def setup_notifications(notifications)
  notifications.each do |name, subscriber|
    ActiveSupport::Notifications.subscribe name, ActiveSupport::Inflector.constantize(subscriber).new
  end
end