]>
Commit | Line | Data |
---|---|---|
0d23b6e5 BB |
1 | require "rubygems" |
2 | require "hpricot" | |
3 | ||
4 | doc = Hpricot(STDIN.read) | |
5 | h1 = (doc/"h1") | |
6 | classes = {"spec passed"=>"+","spec failed"=>"-","spec not_implemented"=>"#"} | |
7 | ||
8 | puts "* #{h1.inner_html}" | |
9 | ||
10 | stats = (doc/"script").select {|script| script.innerHTML =~ /duration|totals/ }.map {|script| script.inner_html.scan(/".*"/).first.gsub(/<\/?strong>/,"") } | |
11 | stats.each do |stat| | |
12 | puts "* #{stat.gsub(/\"/,'')}" | |
13 | end | |
14 | puts "* Parsed with Hpricot (http://wiki.github.com/why/hpricot)" | |
15 | puts " " | |
16 | ||
17 | (doc/"div[@class='example_group']").each do |example| | |
18 | puts "[#{(example/"dl/dt").inner_html}]" | |
19 | (example/"dd").each do |dd| | |
20 | txt = (dd/"span:first").inner_html | |
21 | puts "#{classes[dd[:class]]} #{txt}" | |
22 | next if dd[:class]!="spec failed" | |
23 | failure = (dd/"div[@class='failure']") | |
24 | msg = (failure/"div[@class='message']/pre").inner_html | |
25 | back = (failure/"div[@class='backtrace']/pre").inner_html | |
26 | ruby = (failure/"pre[@class='ruby']/code").inner_html.scan(/(<span class="linenum">)(\d+)(<\/span>)([^<]+)/).map {|elem| " "+elem[1]+": "+elem[3].chomp+"\n"}.join | |
27 | puts " #{msg}" | |
28 | puts " #{back}" | |
29 | puts ruby | |
30 | end | |
31 | puts " " | |
32 | end |