Module: Coque::Redirectable

Included in:
Cmd, Pipeline
Defined in:
lib/coque/redirectable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stderrObject

Returns the value of attribute stderr.



5
6
7
# File 'lib/coque/redirectable.rb', line 5

def stderr
  @stderr
end

#stdinObject

Returns the value of attribute stdin.



5
6
7
# File 'lib/coque/redirectable.rb', line 5

def stdin
  @stdin
end

#stdoutObject

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

Returns:

  • (Boolean)


60
61
62
# File 'lib/coque/redirectable.rb', line 60

def success?
  run.success?
end

#to_aObject



56
57
58
# File 'lib/coque/redirectable.rb', line 56

def to_a
  run.to_a
end