# encoding: UTF-8 module QED module Reporter require 'qed/reporter/abstract' # = Html Reporter # # NOTE: This must be completely redesigned since we moved back # to text based evaluation --which makes generting HTML with # modifications from the evaluation tricky. But I've come up # with a farily clever way to handle this. Take the original # and use Tilt to translate it into HTML, then take the # evaluation results for code steps and use it to search # the HTML for "the closest match". Find the \
 tag
  # associated with the text and add class and color style.
  # Of course the tricky part is the matching, but if we
  # run the text snippet through Tilt as well we should be
  # able to get an exact match. It won't be fast, but it should
  # work.

  class Html < Abstract

    #
    def initialize(*args)
      require 'erb'

      begin
        require 'rubygems'
        gem 'rdoc'
        require 'rdoc'
      rescue
      end

      super(*args)
    end

    #
    def before_session(session)
      io.puts <<-END
        
        
           
          QED Report
          
        
        
      END
    end

    #
    def before_demo(demo)
      io.puts <<-END
        

#{localize_file(demo.file)}

END end def step(step) @_explain = step.explain.dup end # def match(step, md) #@match = md unless md[0].empty? @_explain.sub!(md[0], "#{md[0]}") end end # def pass(step) io.puts <<-END
#{render(@_explain)}
#{step.example}
END end # def fail(step, assertion) io.puts ERB.new(<<-END).result(binding)
#{render(@_explain)}
#{step.example}

#{assertion.class} - #{assertion.message}

    <% assertion.backtrace.each do |bt| %>
  1. <%= bt %>
  2. <% end %>
END end # def error(step, exception) io.puts ERB.new(<<-END).result(binding)
#{render(@_explain)}
#{step.example}

#{exception.class} - #{exception.message}

    <% exception.backtrace.each do |bt| %>
  1. <%= bt %>
  2. <% end %>
END end # def after_demo(demo) end # def after_session(session) io.puts <<-END END end private def render(str) rdoc.convert(str.strip) end def rdoc @rdoc ||= RDoc::Markup::ToHtml.new end #def h(str) # ERB::Util.html_escape(str) #end end end#module Reporter end#module QED