class RemoteExec::Fake
Class to fake running commands and transfering files.
Attributes
story[RW]
The story to tell in execute
, take an array
@example usage
[1, [[nil,"error\n"]]
@return [Array] story to run in execute, format: [ return_status, [[ stdout, stderr],…] ]
Public Class Methods
new()
click to toggle source
Constructs a new Fake
object.
@yield [self] if a block is given then the constructed object
yields itself and calls `#shutdown` at the end, closing the remote connection
Calls superclass method
RemoteExec::Base::new
# File lib/remote-exec/fake.rb, line 29 def initialize after_connect.changed_and_notify(self) super end
Public Instance Methods
execute(command) { |out, err| ... }
click to toggle source
Execute fake command
@param command [String] command string to execute @return [Integer] exit status of the command
# File lib/remote-exec/fake.rb, line 40 def execute(command) before_execute.changed_and_notify(self, command) last_status, outputs = @story outputs.each do |out, err| on_execute_data.changed_and_notify(self, out, err) yield(out, err) if block_given? end after_execute.changed_and_notify(self, command, last_status) last_status end