lib/screwcap/task.rb in screwcap-0.7.4 vs lib/screwcap/task.rb in screwcap-0.8
- old
+ new
@@ -45,15 +45,15 @@
#
# task_for :item, :servers => :server do
# run "ls -l", :onfailure => :rollback
# end
- def run arg, options = {}
+ def run arg, options = {}, &block
if arg.class == Symbol
- self.__commands << options.merge({:command => self.send(arg), :type => :remote, :from => self.__name})
+ self.__commands << options.merge({:command => self.send(arg), :type => :remote, :from => self.__name, :block => block})
else
- self.__commands << options.merge({:command => arg, :type => :remote, :from => self.__name})
+ self.__commands << options.merge({:command => arg, :type => :remote, :from => self.__name, :block => block})
end
end
# execute a ruby command.
# command_set :test do
@@ -217,9 +217,22 @@
end
def validate(servers)
self.__servers = [self.__options.delete(:server)] if self.__options[:server]
self.__servers = [self.__servers] if self.__servers.class != Array
+ end
+
+ # convenience function to look at the exit status of a parent task
+ def exit_code
+ self.__options[:exit_code]
+ end
+
+ def stdout
+ self.__options[:stdout]
+ end
+
+ def stderr
+ self.__options[:stderr]
end
private
def method_missing(m, *args) # :nodoc