Class: Formatter::HtmlFormatter

Inherits:
Cucumber::Formatter::Html
  • Object
show all
Defined in:
lib/friendly/cukes/framework/support/html_formatter.rb

Overview

for uaing @builder object

Instance Method Summary collapse

Instance Method Details

#embed(str_src, str_mime_type, str_label) ⇒ Object

Description : embeds the given input file type to cucumber report Author : Chandra sekaran Arguments :

str_src         : relative path of the file
str_mime_type   : type of file
str_label       : link text on click of click of which shows the embedded file


21
22
23
24
25
26
27
28
# File 'lib/friendly/cukes/framework/support/html_formatter.rb', line 21

def embed(str_src, str_mime_type, str_label)
  case str_mime_type
    when /^image\/(png|gif|jpg|jpeg)/
      embed_image(str_src, str_label)
    when /^text\/plain/
      embed_file(str_src, str_label)
  end
end

#embed_file(str_src, str_label = "Click to view embedded file") ⇒ Object

Description : embeds the given input file type to cucumber report Author : Chandra sekaran Arguments :

str_src         : relative path of the file
str_label       : link text on click of click of which shows the embedded file


48
49
50
51
52
53
54
# File 'lib/friendly/cukes/framework/support/html_formatter.rb', line 48

def embed_file(str_src, str_label = "Click to view embedded file")
    id = "object_#{Time.now.strftime("%y%m%d%H%M%S")}"
    @builder.span(:class => 'embed') do |pre|
      pre << %{<a href="" onclick="o=document.getElementById('#{id}'); o.style.display = (o.style.display == 'none' ? 'block' : 'none');return false">#{str_label}</a><br>&nbsp;
     <object id="#{id}" data="#{str_src}" type="text/plain" width="100%" style="height: 10em;display: none"></object>}
    end
end

Description : embeds a link with the given input string Author : Chandra sekaran Arguments :

str_src         : relative path of the file
str_label       : link text


36
37
38
39
40
# File 'lib/friendly/cukes/framework/support/html_formatter.rb', line 36

def embed_link(str_src, str_label)
  @builder.span(:class => 'embed') do |pre|
    pre << %{<a href="#{str_src}" target="_blank">"#{str_label}"</a> }
  end
end