Class: Ape::TextReporter

Inherits:
Reporter
  • Object
show all
Defined in:
lib/ape/reporters/text_reporter.rb

Instance Attribute Summary

Attributes inherited from Reporter

#debug, #dialogs, #dianum, #diarefs, #footer, #header, #server

Instance Method Summary collapse

Methods inherited from Reporter

#add, #error, #errors, #info, #infos, instance, #line, #list_item, #save_dialog, #security_warning, #show_crumbs, #show_message, #start_list, #steps, #success, #successes, supported_outputs, #warning, #warnings

Methods included from Util

included

Instance Method Details

#report(output = STDOUT) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ape/reporters/text_reporter.rb', line 3

def report(output = STDOUT)
  if @header
    output.puts @header 
    output.puts errors.length == 1?"1 error":"#{errors.length} errors"
    output.puts warnings.length == 1?"1 warning":"#{warnings.length} warnings"
  end
  steps.each do |step|
    if step.class == Crumbs
      output.puts "   Dialog:"
      step.each { |crumb| output.puts "     #{crumb}" }
    else
      line
      if (step.kind_of?Array)
        output.puts "INFO: #{step[0]}"
        step[1..-1].each do |li|
          lines = li[:message].split("\n")
          lines[0..-2].each do |line|
            output.puts("\t #{line} \n")
          end
          output.puts("\t #{lines[-1]}") if lines[-1]
        end
      else          
        case step[:severity]
        when :warning, :error            
          output.puts "#{step[:severity].to_s.upcase}: #{step[:message]}"
        else            
          output.puts step[:message]
        end
      end
    end
    output.puts @footer if @footer
  end
end