Class: Pipes::FakePipe
Constant Summary
Constants inherited
from SystemPipe
SystemPipe::NUMBER_ONLY_REGEX
Instance Attribute Summary collapse
Attributes inherited from SystemPipe
#abandoned_pipes_count, #initial_command, #pipe
Instance Method Summary
collapse
Methods inherited from SystemPipe
#backup_file, #backup_timestamp, #close_with_timeout, #cp, #current_time, #ensure_started, #extract_number_from_string, #flush_until, #follow_file, #follow_file_command, #make_path, #puts_command_read_number, #puts_limit_one_line, #puts_with_output_to_dev_null, #retry_after_timeout, #retry_pipe, #start_pipe, #write_file
Constructor Details
#initialize(outputs = []) ⇒ FakePipe
Returns a new instance of FakePipe.
5
6
7
8
|
# File 'lib/fake_pipe.rb', line 5
def initialize(outputs = [])
@inputs = []
@outputs = outputs
end
|
Instance Attribute Details
Returns the value of attribute inputs.
3
4
5
|
# File 'lib/fake_pipe.rb', line 3
def inputs
@inputs
end
|
#outputs ⇒ Object
Returns the value of attribute outputs.
3
4
5
|
# File 'lib/fake_pipe.rb', line 3
def outputs
@outputs
end
|
Instance Method Details
#close ⇒ Object
32
33
34
|
# File 'lib/fake_pipe.rb', line 32
def close
inputs << "close"
end
|
#each(&block) ⇒ Object
22
23
24
|
# File 'lib/fake_pipe.rb', line 22
def each(&block)
outputs.each(&block)
end
|
#fill(output_lines) ⇒ Object
26
27
28
29
30
|
# File 'lib/fake_pipe.rb', line 26
def fill(output_lines)
output_lines.each_line do |line|
outputs << line
end
end
|
#puts(input) ⇒ Object
10
11
12
|
# File 'lib/fake_pipe.rb', line 10
def puts(input)
inputs << input
end
|
#readline ⇒ Object
14
15
16
|
# File 'lib/fake_pipe.rb', line 14
def readline
outputs.shift
end
|
#readlines ⇒ Object
18
19
20
|
# File 'lib/fake_pipe.rb', line 18
def readlines
outputs
end
|
#run_command_and_ensure_return_code(command) ⇒ Object
40
41
42
43
|
# File 'lib/fake_pipe.rb', line 40
def run_command_and_ensure_return_code(command)
outputs.push "Return Code: 0"
super(command)
end
|
#write(string) ⇒ Object
36
37
38
|
# File 'lib/fake_pipe.rb', line 36
def write(string)
inputs << string
end
|