# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL # $Id: Saver.rb 567 2005-04-13 08:00:06Z polrop $ module TTK module Filters # # This very basic filter, observe a logger, and # save all received messages, without any formatting. # # With this observer you save a sort of execution trace. # After that you can apply to another logger the same # message sequence. # # You can also simply check that two results are equal, # for that, just compare the sequence message. # class Saver < Filter include Concrete def initialize @out = [] end def update ( *args ) msg, path, node, type = args a = [msg] a << path.last.first if msg == :new_node a << node unless node.nil? a << type unless type.nil? @out << a end def get @out.dup end def repeat ( log ) if !@out.empty? and @out[0][1] == 'root' @out[0][1] = 'sub root' end @out.each do |a| a[2] = a[2].to_sym if a[2].is_a? String log.send(*a) end end def each ( &block ) @out.each(&block) end end # class Saver end # module Filters end # TTK