Class: TestOwl::Teeio

Inherits:
Object
  • Object
show all
Defined in:
lib/testowl/teeio.rb

Instance Method Summary collapse

Constructor Details

#initializeTeeio



17
18
19
20
# File 'lib/testowl/teeio.rb', line 17

def initialize
  @results = []
  @file = Tempfile.new('testowl')
end

Instance Method Details

#flushObject



36
37
38
# File 'lib/testowl/teeio.rb', line 36

def flush
  $stdout.flush
end

#outputObject



40
41
42
43
44
45
46
# File 'lib/testowl/teeio.rb', line 40

def output
  if @results.size == 0
    IO.read(@file.path)
  else
    @results.join
  end
end

#puts(buf) ⇒ Object



31
32
33
34
# File 'lib/testowl/teeio.rb', line 31

def puts(buf)
  @results << buf
  $stdout.puts buf
end

#run(command) ⇒ Object



22
23
24
# File 'lib/testowl/teeio.rb', line 22

def run(command)
  system("#{command} | tee #{@file.path}")
end

#write(buf) ⇒ Object



26
27
28
29
# File 'lib/testowl/teeio.rb', line 26

def write(buf)
  @results << buf
  $stdout.write buf
end