Class: Train::Transports::Local::Connection::GenericRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/train/transports/local.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection, options) ⇒ GenericRunner

Returns a new instance of GenericRunner.



114
115
116
# File 'lib/train/transports/local.rb', line 114

def initialize(connection, options)
  @cmd_wrapper = Local::CommandWrapper.load(connection, options)
end

Instance Method Details

#closeObject



133
134
135
# File 'lib/train/transports/local.rb', line 133

def close
  # nothing to do at the moment
end

#run_command(cmd, opts = {}) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/train/transports/local.rb', line 118

def run_command(cmd, opts = {})
  if defined?(@cmd_wrapper) && !@cmd_wrapper.nil?
    cmd = @cmd_wrapper.run(cmd)
  end

  res = Mixlib::ShellOut.new(cmd)
  res.timeout = opts[:timeout]
  begin
    res.run_command
  rescue Mixlib::ShellOut::CommandTimeout
    raise Train::CommandTimeoutReached
  end
  Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
end