Class: LogRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/clarity/renderers/log_renderer.rb

Constant Summary collapse

UrlParser =
%r{\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))}
Prefix =
""
Suffix =
"<br/>\n"

Instance Method Summary collapse

Instance Method Details

#finalizeObject



25
26
27
# File 'lib/clarity/renderers/log_renderer.rb', line 25

def finalize
  '</div><hr><p id="done">Done</p></body></html>'
end

#render(line = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/clarity/renderers/log_renderer.rb', line 12

def render(line = {})
  # Escape
  output = ERB::Util.h(line)
  
  # Transform urls into html links
  output.gsub!(UrlParser) do |match|
    html_link(match)
  end
      
  # Return with formatting
  "#{Prefix}#{output}#{Suffix}"
end