Module: Coque::Redirectable
Instance Attribute Summary collapse
-
#stderr ⇒ Object
Returns the value of attribute stderr.
-
#stdin ⇒ Object
Returns the value of attribute stdin.
-
#stdout ⇒ Object
Returns the value of attribute stdout.
Instance Method Summary collapse
- #<(io) ⇒ Object
- #>(io) ⇒ Object
- #>=(io) ⇒ Object
- #getio(io, mode = "r") ⇒ Object
- #run! ⇒ Object
- #success? ⇒ Boolean
- #to_a ⇒ Object
Instance Attribute Details
#stderr ⇒ Object
Returns the value of attribute stderr.
5 6 7 |
# File 'lib/coque/redirectable.rb', line 5 def stderr @stderr end |
#stdin ⇒ Object
Returns the value of attribute stdin.
5 6 7 |
# File 'lib/coque/redirectable.rb', line 5 def stdin @stdin end |
#stdout ⇒ Object
Returns the value of attribute stdout.
5 6 7 |
# File 'lib/coque/redirectable.rb', line 5 def stdout @stdout end |
Instance Method Details
#<(io) ⇒ Object
13 14 15 16 17 |
# File 'lib/coque/redirectable.rb', line 13 def <(io) clone.tap do |c| c.stdin = io end end |
#>(io) ⇒ Object
7 8 9 10 11 |
# File 'lib/coque/redirectable.rb', line 7 def >(io) clone.tap do |c| c.stdout = io end end |
#>=(io) ⇒ Object
19 20 21 22 23 |
# File 'lib/coque/redirectable.rb', line 19 def >=(io) clone.tap do |c| c.stderr = io end end |
#getio(io, mode = "r") ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/coque/redirectable.rb', line 25 def getio(io, mode = "r") case io when STDERR io.dup when STDOUT io.dup when String File.open(io, mode) when Pathname File.open(io, mode) when IO io when Tempfile io else raise ArgumentError.new("Can't redirect stream to #{io}, must be String, Pathname, or IO") end end |
#run! ⇒ Object
64 65 66 67 68 |
# File 'lib/coque/redirectable.rb', line 64 def run! if !success? raise "Coque Command Failed: #{self}" end end |
#success? ⇒ Boolean
60 61 62 |
# File 'lib/coque/redirectable.rb', line 60 def success? run.success? end |
#to_a ⇒ Object
56 57 58 |
# File 'lib/coque/redirectable.rb', line 56 def to_a run.to_a end |