Class: DRbQS::CommandTask::CommandExecute
- Inherits:
-
Object
- Object
- DRbQS::CommandTask::CommandExecute
- Defined in:
- lib/drbqs/ext/task/command_task.rb
Overview
Execute a command and transfer files if needed.
Instance Method Summary collapse
- #exec ⇒ Object
-
#initialize(cmds, opts = {}) ⇒ CommandExecute
constructor
A new instance of CommandExecute.
Constructor Details
#initialize(cmds, opts = {}) ⇒ CommandExecute
Returns a new instance of CommandExecute.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/drbqs/ext/task/command_task.rb', line 7 def initialize(cmds, opts = {}) opts.assert_valid_keys(:transfer, :compress) @cmds = cmds if String === @cmds @cmds = [@cmds] elsif !(Array === @cmds) raise ArgumentError, "Invalid command: #{@cmds.inspect}" end @transfer = opts[:transfer] @compress = opts[:compress] end |
Instance Method Details
#exec ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/drbqs/ext/task/command_task.rb', line 19 def exec exit_status_ary = @cmds.map do |cmd| system(cmd) $?.exitstatus end if @transfer if @transfer.respond_to?(:each) @transfer.each { |path| DRbQS::Transfer.enqueue(path, :compress => @compress) } else DRbQS::Transfer.enqueue(@transfer, :compress => @compress) end end exit_status_ary end |