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

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

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Connection

Returns a new instance of Connection.



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

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

Instance Method Details

#file(path) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/train/transports/local.rb', line 41

def file(path)
  @files[path] ||= \
    if os.windows?
      Train::File::Local::Windows.new(self, path)
    else
      Train::File::Local::Unix.new(self, path)
    end
end

#login_commandObject



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

def 
  nil # none, open your shell
end

#osObject



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

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

#run_command(cmd) ⇒ Object



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

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



54
55
56
# File 'lib/train/transports/local.rb', line 54

def uri
  'local://'
end