Class: CfScript::Executor::Simple

Inherits:
Object
  • Object
show all
Defined in:
lib/cf_script/executor/simple.rb

Instance Method Summary collapse

Instance Method Details

#echo(line) ⇒ Object



27
28
29
# File 'lib/cf_script/executor/simple.rb', line 27

def echo(line)
  STDOUT.print line if CfScript.config.runtime.echo_output
end

#execute(env, command_line) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/cf_script/executor/simple.rb', line 5

def execute(env, command_line)
out = ''

PTY.spawn(command_line.to_s)do |i, o, pid|
	begin
		i.sync
      i.raw!

		i.each_line do |line|
        echo(line)
			out << line
		end
	rescue Errno::EIO
		# Ignored
	ensure
		::Process.wait pid
	end
end

  [out, '', $?]
end