Class: GenSpec::Shell
- Inherits:
-
Thor::Shell::Basic
- Object
- Thor::Shell::Basic
- GenSpec::Shell
- Defined in:
- lib/genspec/shell.rb
Overview
Just like a Thor::Shell::Basic except that input and output are both redirected to the specified streams. By default, these are initialized to instances of StringIO.
Instance Attribute Summary collapse
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
(also: #input)
Returns the value of attribute stdin.
-
#stdout ⇒ Object
(also: #output)
Returns the value of attribute stdout.
Instance Method Summary collapse
- #ask(statement, color = nil) ⇒ Object
-
#initialize(output = "", input = "") ⇒ Shell
constructor
A new instance of Shell.
-
#new(output = "", input = "") ⇒ Object
Reinitializes this Shell with the given input and output streams.
Constructor Details
#initialize(output = "", input = "") ⇒ Shell
Returns a new instance of Shell.
23 24 25 26 |
# File 'lib/genspec/shell.rb', line 23 def initialize(output = "", input = "") super() new(output, input) end |
Instance Attribute Details
#stderr ⇒ Object
Returns the value of attribute stderr.
7 8 9 |
# File 'lib/genspec/shell.rb', line 7 def stderr @stderr end |
#stdin ⇒ Object Also known as: input
Returns the value of attribute stdin.
7 8 9 |
# File 'lib/genspec/shell.rb', line 7 def stdin @stdin end |
#stdout ⇒ Object Also known as: output
Returns the value of attribute stdout.
7 8 9 |
# File 'lib/genspec/shell.rb', line 7 def stdout @stdout end |
Instance Method Details
#ask(statement, color = nil) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/genspec/shell.rb', line 13 def ask(statement, color = nil) say "#{statement} ", color response = stdin.gets if response response.strip else raise "Asked '#{statement}', but input.gets returned nil!" end end |
#new(output = "", input = "") ⇒ Object
Reinitializes this Shell with the given input and output streams.
29 30 31 32 33 34 |
# File 'lib/genspec/shell.rb', line 29 def new(output="", input="") init_stream(:output, output) init_stream(:input, input) @stderr = @stdout self end |