Class: RShade::Formatter::Trace::Html

Inherits:
Object
  • Object
show all
Defined in:
lib/rshade/formatter/trace/html.rb

Constant Summary collapse

FILE_NAME =
'stacktrace.html'
TEMPLATE =
'html/template.html.erb'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Html

Returns a new instance of Html.



14
15
16
# File 'lib/rshade/formatter/trace/html.rb', line 14

def initialize(args = {})
  @formatter = args.fetch(:formatter, Json)
end

Instance Attribute Details

#formatterObject (readonly)

Returns the value of attribute formatter.



9
10
11
# File 'lib/rshade/formatter/trace/html.rb', line 9

def formatter
  @formatter
end

Instance Method Details

#call(event_store) ⇒ Object

Parameters:



19
20
21
22
23
24
# File 'lib/rshade/formatter/trace/html.rb', line 19

def call(event_store)
  data = formatter.call(event_store)
  erb_template = ERB.new(template)
  content = erb_template.result_with_hash({ json: data.to_json })
  write_to_file(content)
end

#templateObject



30
31
32
# File 'lib/rshade/formatter/trace/html.rb', line 30

def template
  @template ||= ::File.read(::File.join(::RShade::Utils.root_dir, TEMPLATE))
end

#write_to_file(data) ⇒ Object



26
27
28
# File 'lib/rshade/formatter/trace/html.rb', line 26

def write_to_file(data)
  ::File.write(::File.join(RShade::Utils.store_dir, FILE_NAME), data)
end