class Reporter

Public Class Methods

new(listeners = nil) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 2
def initialize(listeners = nil)
  @listeners = listeners || []
end

Public Instance Methods

add_listener(listener) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 6
def add_listener(listener)
  @listeners << listener
end
ask(question) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 60
def ask(question)
  askable_listener = @listeners.find { |l| l.respond_to?(:ask) }
  return nil if askable_listener.nil?
  return askable_listener.ask(question)
end
dump_error(error, message = nil) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 10
def dump_error(error, message = nil)
  notify(:dump_error, error, message)
end
failure_message(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 49
def failure_message(message)
  notify(:show_status_message, message, :failure)
end
notify(message, *args) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 53
def notify(message, *args)
  @listeners.each do |listener|
    listener.send(message, *args)
  end
  nil
end
show_error(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 14
def show_error(message)
  notify(:show_error, message)
end
show_failure(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 18
def show_failure(message)
  notify(:show_failure, message)
end
show_options(options, message = nil) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 22
def show_options(options, message = nil)
  notify(:show_options, options, message)
end
show_verbose_message(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 26
def show_verbose_message(message)
  notify(:show_verbose_message, message)
end
success_message(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 41
def success_message(message)
  notify(:show_status_message, message, :success)
end
warning_message(message) click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 45
def warning_message(message)
  notify(:show_status_message, message, :warning)
end
with_status_message(message) { || ... } click to toggle source
# File lib/hiptest-publisher/formatters/reporter.rb, line 30
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