Class: Dk::Local::BaseCmd
- Inherits:
-
Object
- Object
- Dk::Local::BaseCmd
- Defined in:
- lib/dk/local.rb
Defined Under Namespace
Classes: OutputLine
Instance Attribute Summary collapse
-
#cmd_str ⇒ Object
readonly
Returns the value of attribute cmd_str.
-
#scmd ⇒ Object
readonly
Returns the value of attribute scmd.
Instance Method Summary collapse
-
#initialize(scmd_or_spy_klass, cmd_str, opts) ⇒ BaseCmd
constructor
A new instance of BaseCmd.
- #output_lines ⇒ Object
- #pid ⇒ Object
- #run(input = nil) ⇒ Object
- #running? ⇒ Boolean
- #start(input = nil) ⇒ Object
- #stderr ⇒ Object
- #stdout ⇒ Object
- #stop(timeout = nil) ⇒ Object
- #success? ⇒ Boolean
- #to_s ⇒ Object
- #wait(timeout = nil) ⇒ Object
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_str ⇒ Object (readonly)
Returns the value of attribute cmd_str.
8 9 10 |
# File 'lib/dk/local.rb', line 8 def cmd_str @cmd_str end |
#scmd ⇒ Object (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_lines ⇒ Object
49 50 51 |
# File 'lib/dk/local.rb', line 49 def output_lines build_stdout_lines(self.stdout) + build_stderr_lines(self.stderr) end |
#pid ⇒ Object
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
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 |
#stderr ⇒ Object
45 |
# File 'lib/dk/local.rb', line 45 def stderr; @scmd.stderr; end |
#stdout ⇒ Object
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
47 |
# File 'lib/dk/local.rb', line 47 def success?; @scmd.success?; end |
#to_s ⇒ Object
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. end self end |