Class: Reporter
- Inherits:
-
Object
- Object
- Reporter
- Defined in:
- lib/hiptest-publisher/formatters/reporter.rb
Instance Method Summary collapse
- #add_listener(listener) ⇒ Object
- #ask(question) ⇒ Object
- #dump_error(error, message = nil) ⇒ Object
- #failure_message(message) ⇒ Object
-
#initialize(listeners = nil) ⇒ Reporter
constructor
A new instance of Reporter.
- #notify(message, *args) ⇒ Object
- #show_error(message) ⇒ Object
- #show_failure(message) ⇒ Object
- #show_options(options, message = nil) ⇒ Object
- #show_verbose_message(message) ⇒ Object
- #success_message(message) ⇒ Object
- #warning_message(message) ⇒ Object
- #with_status_message(message, &blk) ⇒ Object
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 |
#ask(question) ⇒ Object
60 61 62 63 64 |
# 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) ⇒ Object
10 11 12 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 10 def dump_error(error, = nil) notify(:dump_error, error, ) end |
#failure_message(message) ⇒ Object
49 50 51 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 49 def () notify(:show_status_message, , :failure) end |
#notify(message, *args) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 53 def notify(, *args) @listeners.each do |listener| listener.send(, *args) end nil end |
#show_error(message) ⇒ Object
14 15 16 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 14 def show_error() notify(:show_error, ) end |
#show_failure(message) ⇒ Object
18 19 20 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 18 def show_failure() notify(:show_failure, ) end |
#show_options(options, message = nil) ⇒ Object
22 23 24 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 22 def (, = nil) notify(:show_options, , ) end |
#show_verbose_message(message) ⇒ Object
26 27 28 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 26 def () notify(:show_verbose_message, ) end |
#success_message(message) ⇒ Object
41 42 43 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 41 def () notify(:show_status_message, , :success) end |
#warning_message(message) ⇒ Object
45 46 47 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 45 def () notify(:show_status_message, , :warning) end |
#with_status_message(message, &blk) ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/hiptest-publisher/formatters/reporter.rb', line 30 def (, &blk) notify(:show_status_message, ) status = :success yield rescue status = :failure raise ensure notify(:show_status_message, , status) end |