Class: Coque::Cmd

Inherits:
Object
  • Object
show all
Includes:
Redirectable, Runnable
Defined in:
lib/coque/cmd.rb

Direct Known Subclasses

Rb, Sh

Instance Attribute Summary collapse

Attributes included from Redirectable

#stderr, #stdin, #stdout

Instance Method Summary collapse

Methods included from Runnable

#log_start, #run, #run!, #success?, #to_a, #to_a!

Methods included from Redirectable

#<, #>, #>=, #err, #getio, #in, #out

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



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

def context
  @context
end

Instance Method Details

#cloneObject



20
21
22
# File 'lib/coque/cmd.rb', line 20

def clone
  raise "Not Implemented - Override"
end

#get_default_fdsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/coque/cmd.rb', line 24

def get_default_fds
  stdin = if self.stdin
            self.stdin
          else
            inr, inw = IO.pipe
            inw.close
            inr
          end

  stdoutr, stdoutw = if self.stdout
                       [self.stdout, self.stdout]
                     else
                       IO.pipe
                     end

  [stdin, stdoutr, stdoutw]
end

#pipe(other) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/coque/cmd.rb', line 7

def pipe(other)
  case other
  when Cmd
    Pipeline.new([self.clone, other.clone])
  when Pipeline
    Pipeline.new([self.clone] + other.commands)
  end
end

#|(other) ⇒ Object



16
17
18
# File 'lib/coque/cmd.rb', line 16

def |(other)
  pipe(other)
end