class Fudge::Tasks::Shell
Allow use of shell commands as tasks
Attributes
arguments[RW]
check_for[RW]
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/fudge/tasks/shell.rb, line 7 def initialize(*args) self.arguments = super.join(' ') end
Public Instance Methods
run(options={})
click to toggle source
Execute the shell command
@param [Hash] options Any options to pass to the shell
# File lib/fudge/tasks/shell.rb, line 14 def run(options={}) formatter = get_formatter(options) @output, success = run_command(cmd(options), formatter) return false unless success return check_for_output(formatter) end
Private Instance Methods
check_for_output(formatter)
click to toggle source
# File lib/fudge/tasks/shell.rb, line 37 def check_for_output(formatter) checker = OutputChecker.new(check_for, formatter) checker.check(@output) end
cmd(options={})
click to toggle source
Defines the command to run
# File lib/fudge/tasks/shell.rb, line 43 def cmd(options={}) arguments end
run_command(cmd, formatter)
click to toggle source
# File lib/fudge/tasks/shell.rb, line 24 def run_command(cmd, formatter) output = '' IO.popen(cmd) do |f| until f.eof? bit = f.getc output << bit formatter.putc bit end end [output, $?.success?] end