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
# File 'lib/train/transports/local.rb', line 23

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

Instance Method Details

#file(path) ⇒ Object



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

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

#login_commandObject



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

def 
  nil # none, open your shell
end

#osObject



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

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

#run_command(cmd) ⇒ Object



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

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

#uriObject



50
51
52
# File 'lib/train/transports/local.rb', line 50

def uri
  'local://'
end