32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/coque/pipeline.rb', line 32
def stitch
if commands.first.stdin.nil?
start_r, start_w = IO.pipe
start_w.close
commands.first.stdin = start_r
end
commands.each_cons(2) do |left, right|
read, write = IO.pipe
left.stdout = write
right.stdin = read
end
if self.stdout
commands.last.stdout = stdout
stdout
elsif commands.last.stdout
commands.last.stdout
else
next_r, next_w = IO.pipe
commands.last.stdout = next_w
next_r
end
end
|