Class: Dk::Local::BaseCmd

Inherits:
Object
  • Object
show all
Defined in:
lib/dk/local.rb

Direct Known Subclasses

Cmd, CmdSpy

Defined Under Namespace

Classes: OutputLine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scmd_or_spy_klass, cmd_str, opts) ⇒ BaseCmd

Returns a new instance of BaseCmd.



10
11
12
13
14
15
# File 'lib/dk/local.rb', line 10

def initialize(scmd_or_spy_klass, cmd_str, opts)
  opts ||= {}

  @cmd_str = cmd_str
  @scmd    = scmd_or_spy_klass.new(@cmd_str, :env => opts[:env])
end

Instance Attribute Details

#cmd_strObject (readonly)

Returns the value of attribute cmd_str.



8
9
10
# File 'lib/dk/local.rb', line 8

def cmd_str
  @cmd_str
end

#scmdObject (readonly)

Returns the value of attribute scmd.



8
9
10
# File 'lib/dk/local.rb', line 8

def scmd
  @scmd
end

Instance Method Details

#output_linesObject



49
50
51
# File 'lib/dk/local.rb', line 49

def output_lines
  build_stdout_lines(self.stdout) + build_stderr_lines(self.stderr)
end

#pidObject



43
# File 'lib/dk/local.rb', line 43

def pid;      @scmd.pid;      end

#run(input = nil) ⇒ Object



38
39
40
41
# File 'lib/dk/local.rb', line 38

def run(input = nil)
  @scmd.run(input)
  self
end

#running?Boolean

Returns:

  • (Boolean)


46
# File 'lib/dk/local.rb', line 46

def running?; @scmd.running?; end

#start(input = nil) ⇒ Object



19
20
21
22
# File 'lib/dk/local.rb', line 19

def start(input = nil)
  @scmd.start(input)
  self
end

#stderrObject



45
# File 'lib/dk/local.rb', line 45

def stderr;   @scmd.stderr;   end

#stdoutObject



44
# File 'lib/dk/local.rb', line 44

def stdout;   @scmd.stdout;   end

#stop(timeout = nil) ⇒ Object



33
34
35
36
# File 'lib/dk/local.rb', line 33

def stop(timeout = nil)
  @scmd.stop(timeout)
  self
end

#success?Boolean

Returns:

  • (Boolean)


47
# File 'lib/dk/local.rb', line 47

def success?; @scmd.success?; end

#to_sObject



17
# File 'lib/dk/local.rb', line 17

def to_s; self.cmd_str; end

#wait(timeout = nil) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/dk/local.rb', line 24

def wait(timeout = nil)
  begin
    @scmd.wait(timeout)
  rescue Scmd::TimeoutError => e
    raise Dk::CmdTimeoutError, e.message
  end
  self
end