# Author:: Nicolas Pouillard . # Copyright:: Copyright (c) 2004, 2005 TTK team. All rights reserved. # License:: LGPL # $Id: SubCmd.rb 607 2005-06-05 17:02:43Z ertai $ module TTK module Strategies class SubCmd < CmdBase include Concrete def prologue @command = @symtbl[:ttk] @dir = @symtbl[:pwd] super end protected :prologue def run_impl super raise_error 'no ttk output' unless @output.my.exist? status = nil @output.my.open do |out| YAML::each_document(out) do |notification| case notification when Array @log.send(*notification) when Status status = notification else raise_error 'bad sub commad output' if stream.nil? end end end raise_error 'bad status output' unless status.is_a? Status raise_error 'ttk stderr not empty' unless @error.my.zero? @status = status raise_status @status end protected :run_impl def assertion raise_error "bad exit status #@my_exit" unless [0, 2].include? @my_exit super end protected :assertion def error_hook @log.my_stdout = @output.my.read if @output and @output.my.exist? @log.my_stderr = @error.my.read if @error and @error.my.exist? super end protected :error_hook def mk_command @args = "#@args -P Notif --dump-status" super end protected :mk_command end # class SubCmd end # module Strategies end # module TTK