On 6/10/05, Jim Weirich <jim / weirichhouse.org> wrote:
> On Thursday 09 June 2005 06:38 pm, Andrew Cox wrote:
> > def initialize(fileName, logsToKeep, maxLogSize, xmlFileName )
> > @logfile = File.new(xmlFileName, "w")
> > @xml = XmlMarkup.new(:target=>@logfile, :indent=>2)
> > @xml.instruct! #insert processing instruction
> > @results = XmlMarkup.new
> > end
> >
> > def log_results(name, input, expected, test_status)
> > r = XmlMarkup.new(:target=>@results, :indent=>2)
> > r.result(:testcase => name) do
> > r.status(test_status)
> > end #results tag
> > end #log_results
> >
> > def end_log
> > @xml.results do
> > @results
> > end
> > @logfile.close
> > end #end_log
> 
> The following should work for you:
> 
> class TestResultsLogger
>   def initialize(fileName, logsToKeep, maxLogSize, xmlFileName )
>     @logfile = File.new(xmlFileName, "w")
>     @xml = Builder::XmlMarkup.new(:target=>@logfile, :indent=>2)
>     @xml.instruct! #insert processing instruction
>     @results =
> Builder::XmlMarkup.new(:target=>@results, :indent=>2, :margin=>1)
>   end
> 
>   def log_results(name, input, expected, test_status)
>     @results.result(:testcase => name) do
>       @results.status(test_status)
>     end
>   end
> 
>   def end_log
>     @xml.results do
>       @xml << @results.target!
>     end
>     @logfile.close
>   end
> end
> 

Perfect!  Thank you very much.  I was about to e-mail you first, but
figured that others might benefit from the solution ;-)

Drew