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

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

Instance Method Summary collapse

Constructor Details

#initialize(powershell_cmd = 'powershell') ⇒ WindowsPipeRunner

Returns a new instance of WindowsPipeRunner.



143
144
145
146
147
# File 'lib/train/transports/local.rb', line 143

def initialize(powershell_cmd = 'powershell')
  @powershell_cmd = powershell_cmd
  @pipe = acquire_pipe
  fail PipeError if @pipe.nil?
end

Instance Method Details

#run_command(cmd) ⇒ Object



149
150
151
152
153
154
155
156
# File 'lib/train/transports/local.rb', line 149

def run_command(cmd)
  script = "$ProgressPreference='SilentlyContinue';" + cmd
  encoded_script = Base64.strict_encode64(script)
  @pipe.puts(encoded_script)
  @pipe.flush
  res = OpenStruct.new(JSON.parse(Base64.decode64(@pipe.readline)))
  Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
end