Module: Restflow::Report

Defined in:
lib/restflow/report.rb

Class Method Summary collapse

Class Method Details

.run(sequences) ⇒ Object



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
# File 'lib/restflow/report.rb', line 7

def self.run(sequences)
  report = File.new("sequences-report.html", "w")
  b = Builder::XmlMarkup.new :target => report, :indent => 2
  b.instruct!
  b.html {
    b.head { b.title("Sequences")}
    b.style(self.css_content)
    b.body {
      sequences.each { |sequence|
        b.section(:class => "sequence") {
          b.h2(sequence.description)
          sequence.responses.each { |response|
            b.p(:class => "request"){
              b.span(response.request.http_method.to_s.split("::").last, :class => "verb")
              b.span(response.request.path, :class => "original-request")
              b.span(response.code, :class => "status")
            }
            b.code(response.body)           
          }
        }

      }
    }
  }
  report.close
end