Class: Mutagem::Task
- Inherits:
-
Object
- Object
- Mutagem::Task
- Defined in:
- lib/mutagem/task.rb
Overview
A simple external process management wrapper
Instance Attribute Summary collapse
-
#cmd ⇒ String
readonly
Command to run.
Instance Method Summary collapse
-
#exception ⇒ Exception
Exception returned if one is thrown by Task.
-
#exitstatus ⇒ Object
Subprocess exit status.
-
#initialize(cmd) ⇒ Task
constructor
Create a new Task.
-
#output ⇒ Array
Array of strings from the subprocess output.
-
#pid ⇒ Object
Subprocess pid.
-
#run ⇒ Object
(also: #join)
run the cmd.
Constructor Details
#initialize(cmd) ⇒ Task
Create a new Task
23 24 25 26 |
# File 'lib/mutagem/task.rb', line 23 def initialize(cmd) $stdout.sync = true @cmd = cmd end |
Instance Attribute Details
#cmd ⇒ String (readonly)
Returns command to run.
18 19 20 |
# File 'lib/mutagem/task.rb', line 18 def cmd @cmd end |
Instance Method Details
#exception ⇒ Exception
Returns exception returned if one is thrown by Task.
44 45 46 |
# File 'lib/mutagem/task.rb', line 44 def exception @exception end |
#exitstatus ⇒ Object
Returns subprocess exit status.
34 35 36 |
# File 'lib/mutagem/task.rb', line 34 def exitstatus @exitstatus end |
#output ⇒ Array
Returns array of strings from the subprocess output.
29 30 31 |
# File 'lib/mutagem/task.rb', line 29 def output @output end |
#pid ⇒ Object
Returns subprocess pid.
39 40 41 |
# File 'lib/mutagem/task.rb', line 39 def pid @pid end |
#run ⇒ Object Also known as: join
run the cmd
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/mutagem/task.rb', line 49 def run pipe = IO.popen(@cmd + " 2>&1") @pid = pipe.pid begin @output = pipe.readlines pipe.close @exitstatus = $?.exitstatus rescue => e @exception = e end end |