Class: Tracing::HtmlTemplate

Inherits:
BaseTemplate show all
Defined in:
lib/templates/html_template.rb

Instance Method Summary collapse

Methods inherited from BaseTemplate

#handle_after_call

Methods included from OutputHandler

#indentation, #method_stack, #output, #output_handler, #space_count

Instance Method Details

#before_block_templateObject



20
21
22
23
24
# File 'lib/templates/html_template.rb', line 20

def before_block_template 
  template = <<-EOF
<div class="method block-arg">(and a block)</div>
EOF
end

#before_template(context) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/templates/html_template.rb', line 4

def before_template(context)
  # method_name = context[:method_full_name]
  # args = context[:args].inspect
  template = <<-EOF
  <div class="method-title"><%= context[:method_full_name] %></div>
  <div class="method-body">
    <div class="begin">
      <div class="method-name"><%= context[:method_full_name] %> :: BEGIN</div>
      <div class="args">
        <div class="method-args"><%= context[:args] %> </div>
        #block#
      </div>
    </div>
EOF
end

#end_template(context) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/templates/html_template.rb', line 26

def end_template(context) 
  # method_name = context[:method_full_name]
  # result = context[:result].inspect
  template = <<-EOF
    <div class="end">
      <div class="method-name"><%= context[:method_full_name] %> :: END</div>
      <div class="method-result"><%= context[:result] %></div>
    </div>
  </div>
EOF
end

#handle_before_call(context) ⇒ Object

override



39
40
41
42
43
44
# File 'lib/templates/html_template.rb', line 39

def handle_before_call(context)
  template = before_template(context)
  block_replace = context[:block] ? before_block_template : ""
  template.gsub!(/#block#/, block_replace)
  output(template, context)
end