Skip to content

Commit

Permalink
Make changes to integrate @jquick's cacheing magic
Browse files Browse the repository at this point in the history
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
  • Loading branch information
jerryaldrichiii committed Nov 27, 2017
1 parent bd2c7c3 commit e7d7d32
Showing 1 changed file with 16 additions and 38 deletions.
54 changes: 16 additions & 38 deletions lib/train/transports/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,10 @@ def initialize(options)
end
end

def run_command(cmd)
@runner.run_command(cmd)
rescue Errno::ENOENT => _
CommandResult.new('', '', 1)
end

def local?
true
end

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

def login_command
nil # none, open your shell
end
Expand All @@ -63,6 +48,22 @@ def uri
'local://'
end

private

def run_command_via_connection(cmd)
@runner.run_command(cmd)
rescue Errno::ENOENT => _
CommandResult.new('', '', 1)
end

def file_via_connection(path)
if os.windows?
Train::File::Local::Windows.new(self, path)
else
Train::File::Local::Unix.new(self, path)
end
end

class GenericRunner
attr_writer :cmd_wrapper

Expand Down Expand Up @@ -203,29 +204,6 @@ def start_pipe_server(pipe_name)
at_exit { Process.kill('KILL', server_pid) }
end
end

def run_command_via_connection(cmd)
if defined?(@platform) && @platform.windows?
start_named_pipe_server unless File.exist?('//localhost/pipe/InSpec')
res = run_powershell_using_named_pipe(cmd)
CommandResult.new(res['stdout'], res['stderr'], res['exitstatus'])
else
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)
end
rescue Errno::ENOENT => _
CommandResult.new('', '', 1)
end

def file_via_connection(path)
if os.windows?
Train::File::Local::Windows.new(self, path)
else
Train::File::Local::Unix.new(self, path)
end
end
end
end
end

0 comments on commit e7d7d32

Please sign in to comment.