Module: Relevance::Tarantula::HtmlReportHelper

Includes:
ERB::Util, Relevance::Tarantula
Included in:
Result
Defined in:
lib/relevance/tarantula/html_report_helper.rb

Constant Summary

Constants included from Relevance::Tarantula

VERSION

Instance Method Summary collapse

Methods included from Relevance::Tarantula

#log, #rails_root, #tarantula_home, #verbose

Instance Method Details

#textmate_url(file, line_no) ⇒ Object



42
43
44
# File 'lib/relevance/tarantula/html_report_helper.rb', line 42

def textmate_url(file, line_no)
  "txmt://open?url=file://#{File.expand_path(File.join(rails_root,file))}&line_no=#{line_no}"
end

#wrap_in_line_number_table(text, &blk) ⇒ Object



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
36
37
38
39
40
# File 'lib/relevance/tarantula/html_report_helper.rb', line 5

def wrap_in_line_number_table(text, &blk)
  x = Builder::XmlMarkup.new
  x.table(:class => "grid tablesorter") do      
    x.thead do
      x.tr do
        x.th(:class => "sort asc") do
          x.span("Line \#")
          x.span(:class => "sort") do
            x.em do
              x << '&#8613;'
            end
          end
        end
        x.th(:class => "sort left") do
          x.span("Line")
          x.span(:class => "sort") do
            x.em do
              x << '&#8613;'
            end
          end               
        end
      end
    end
    text.split("\n").each_with_index do |line, index|
      x.tr do
        x.td(index+1)
        if block_given?
          x.td {x << yield(line)}
        else
          x.td(line)
        end
      end
    end   
  end
  x.target!
end

#wrap_stack_trace_line(text) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/relevance/tarantula/html_report_helper.rb', line 46

def wrap_stack_trace_line(text)
  if text =~ %r{^\s*(/[^:]+):(\d+):([^:]+)$}
    file = h($1) # .to_s_xss_protected
    line_number = $2
    message = h($3) # .to_s_xss_protected
    "<a href='#{textmate_url(file, line_number)}'>#{file}:#{line_number}</a>:#{message}" # .mark_as_xss_protected
  else
    h(text) # .to_s_xss_protected
  end
end