Class: Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/hiptest-publisher/formatters/reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(listeners = nil) ⇒ Reporter

Returns a new instance of Reporter.



2
3
4
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 2

def initialize(listeners = nil)
  @listeners = listeners || []
end

Instance Method Details

#add_listener(listener) ⇒ Object



6
7
8
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 6

def add_listener(listener)
  @listeners << listener
end

#dump_error(error, message = nil) ⇒ Object



10
11
12
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 10

def dump_error(error, message = nil)
  notify(:dump_error, error, message)
end

#notify(message, *args) ⇒ Object



33
34
35
36
37
38
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 33

def notify(message, *args)
  @listeners.each do |listener|
    listener.send(message, *args)
  end
  nil
end

#show_options(options, message = nil) ⇒ Object



14
15
16
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 14

def show_options(options, message = nil)
  notify(:show_options, options, message)
end

#show_verbose_message(message) ⇒ Object



18
19
20
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 18

def show_verbose_message(message)
  notify(:show_verbose_message, message)
end

#with_status_message(message, &blk) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 22

def with_status_message(message, &blk)
  notify(:show_status_message, message)
  status = :success
  yield
rescue
  status = :failure
  raise
ensure
  notify(:show_status_message, message, status)
end