Class: DeepTest::ProxyIO
- Inherits:
-
StringIO
- Object
- StringIO
- DeepTest::ProxyIO
show all
- Defined in:
- lib/deep_test/proxy_io.rb
Defined Under Namespace
Modules: Stderr, Stdout
Classes: AbstractOutput
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(output_module, wire) ⇒ ProxyIO
Returns a new instance of ProxyIO.
3
4
5
6
7
|
# File 'lib/deep_test/proxy_io.rb', line 3
def initialize(output_module, wire)
@output_module = output_module
@wire = wire
super("")
end
|
Class Method Details
.replace_stdout_stderr!(wire) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/deep_test/proxy_io.rb', line 19
def self.replace_stdout_stderr!(wire)
old_stdout_const, old_stdout_global = STDOUT, $stdout
old_stderr_const, old_stderr_global = STDERR, $stderr
supress_warnings { Object.const_set :STDOUT, ProxyIO.new(Stdout, wire) }
$stdout = STDOUT
supress_warnings { Object.const_set :STDERR, ProxyIO.new(Stderr, wire) }
$stderr = STDERR
DeepTest.logger = nil
yield
ensure
$stdout = old_stdout_global
supress_warnings { Object.const_set :STDOUT, old_stdout_const }
$stderr = old_stderr_global
supress_warnings { Object.const_set :STDERR, old_stderr_const }
end
|
.supress_warnings ⇒ Object
40
41
42
43
44
45
|
# File 'lib/deep_test/proxy_io.rb', line 40
def self.supress_warnings
old_verbose, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = old_verbose
end
|
Instance Method Details
#flush ⇒ Object
15
16
17
|
# File 'lib/deep_test/proxy_io.rb', line 15
def flush
@wire.send_message @output_module::Flush.new
end
|
#write(*args) ⇒ Object
9
10
11
12
13
|
# File 'lib/deep_test/proxy_io.rb', line 9
def write(*args)
super
@wire.send_message @output_module::Output.new(string)
self.string = ""
end
|