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.



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

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

Instance Method Details

#closeObject



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

def close
  # nothing to do at the moment
end

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



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

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