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

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

Defined Under Namespace

Classes: File

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Connection

Returns a new instance of Connection.



23
24
25
26
27
28
# File 'lib/train/transports/local.rb', line 23

def initialize(options)
  super(options)
  @files = {}
  @cmd_wrapper = nil
  @cmd_wrapper = CommandWrapper.load(self, options)
end

Instance Method Details

#file(path) ⇒ Object



43
44
45
# File 'lib/train/transports/local.rb', line 43

def file(path)
  @files[path] ||= File.new(self, path)
end

#login_commandObject



47
48
49
# File 'lib/train/transports/local.rb', line 47

def 
  nil # none, open your shell
end

#osObject



39
40
41
# File 'lib/train/transports/local.rb', line 39

def os
  @os ||= OS.new(self)
end

#run_command(cmd) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/train/transports/local.rb', line 30

def run_command(cmd)
  cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil?
  res = Mixlib::ShellOut.new(cmd)
  res.run_command
  CommandResult.new(res.stdout, res.stderr, res.exitstatus)
rescue Errno::ENOENT => _
  CommandResult.new('', '', 1)
end