Class: Ape::AtomReporter

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

Instance Attribute Summary

Attributes inherited from Reporter

#debug, #dialogs, #dianum, #diarefs, #footer, #header, #options, #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

extended, included

Instance Method Details

#content(step, dialog = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ape/reporters/atom_reporter.rb', line 22

def content(step, dialog = nil)
  xml = "<div xmlns=\"http://www.w3.org/1999/xhtml\">"
  lines = step.split("\n")
  lines[0 .. -2].each do |line|
    xml += "#{line} <br/>"
  end
  xml += escape(lines[-1]) if lines[-1]
  if dialog && dialogs[dialog]        
    xml += '<div>'
        xml += 'To server:'
        dialogs[dialog].grep(/^>/).each do |crumb|
          xml += show_message(crumb, :to)
        end
    xml += '</div>'
    xml += '<div>'
        xml += 'From server:'
        dialogs[dialog].grep(/^</).each do |crumb|
          xml += show_message(crumb, :from)
        end
    xml += '</div>'
  end
  xml += '</div>'
  xml
end

#escape(text) ⇒ Object



8
9
10
# File 'lib/ape/reporters/atom_reporter.rb', line 8

def escape(text)
  Escaper.escape(text)
end

#idObject



16
17
18
19
20
# File 'lib/ape/reporters/atom_reporter.rb', line 16

def id
  id = ''
  5.times { id += rand(1000000).to_s }
  "tag:tbray.org,2005:#{id}"
end

#nowObject



12
13
14
# File 'lib/ape/reporters/atom_reporter.rb', line 12

def now
  DateTime::now.strftime("%Y-%m-%dT%H:%M:%S%z").sub(/(..)$/, ':\1')
end

#report(output = STDOUT) ⇒ Object



47
48
49
# File 'lib/ape/reporters/atom_reporter.rb', line 47

def report(output = STDOUT)      
  output.puts evaluate_template("reporters/atom_template.eruby")
end