Class: PVC::ResultPiece::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pvc/result_piece.rb

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/pvc/result_piece.rb', line 5

def initialize
  @stdread, @stdwrite = IO.pipe
  @errread, @errwrite = IO.pipe
  @stdread.close_on_exec = true
  @stdwrite.close_on_exec = true
  @errread.close_on_exec = true
  @errwrite.close_on_exec = true
  @stdout = []
  @stderr = []
  @stdboth = []
end

Instance Method Details

#errinObject



21
22
23
# File 'lib/pvc/result_piece.rb', line 21

def errin
  @errwrite
end

#finishObject



40
41
42
43
44
45
46
47
# File 'lib/pvc/result_piece.rb', line 40

def finish
  @stdwrite.close
  @errwrite.close
  @stdthread.join
  @errthread.join
  @stdread.close
  @errread.close
end

#start(following = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pvc/result_piece.rb', line 25

def start(following=nil)
  @stdthread = Thread.new do
    @stdread.each_line do |line|
      @stdout << line
      @stdboth << line
    end
  end
  @errthread = Thread.new do
    @errread.each_line do |line|
      @stderr << line
      @stdboth << line
    end
  end
end

#stdbothObject



57
58
59
# File 'lib/pvc/result_piece.rb', line 57

def stdboth
  @stdboth.join("")
end

#stderrObject



53
54
55
# File 'lib/pvc/result_piece.rb', line 53

def stderr
  @stderr.join("")
end

#stdinObject



17
18
19
# File 'lib/pvc/result_piece.rb', line 17

def stdin
  @stdwrite
end

#stdoutObject



49
50
51
# File 'lib/pvc/result_piece.rb', line 49

def stdout
  @stdout.join("")
end