Class: Matcher::HtmlFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/matcher/html_formatter.rb

Constant Summary collapse

TEMPLATE =
File.dirname(__FILE__) + '/xmatch.html.erb'

Instance Method Summary collapse

Constructor Details

#initialize(matcher, args = {}) ⇒ HtmlFormatter

Returns a new instance of HtmlFormatter.



11
12
13
14
15
16
# File 'lib/matcher/html_formatter.rb', line 11

def initialize(matcher, args = {})
  @matcher = matcher
  @report_dir = args[:report_dir] || '/tmp/xmatch'
  @generated_xml_dir = File.join(@report_dir, "generated_xml")
  @prefix = args[:prefix]
end

Instance Method Details

#formatObject



18
19
20
21
22
23
24
25
26
# File 'lib/matcher/html_formatter.rb', line 18

def format
  match_data = []
  @matcher.lhs.traverse do |elem|
    next if elem.xml?
    match_data << match_info_for(elem)
    elem.attributes.values.each { | attr | match_data << match_info_for(attr) }
  end
  create_report(match_data.sort {|a, b| a.line <=> b.line})
end