Class: Bookbinder::Sheller
- Inherits:
-
Object
- Object
- Bookbinder::Sheller
- Defined in:
- lib/bookbinder/sheller.rb
Defined Under Namespace
Classes: DevNull
Constant Summary collapse
- ShelloutFailure =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#view_updater ⇒ Object
readonly
Returns the value of attribute view_updater.
Instance Method Summary collapse
Instance Attribute Details
#view_updater ⇒ Object (readonly)
Returns the value of attribute view_updater.
46 47 48 |
# File 'lib/bookbinder/sheller.rb', line 46 def view_updater @view_updater end |
Instance Method Details
#run_command(*command) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/bookbinder/sheller.rb', line 15 def run_command(*command) out, err = if Hash === command.last command.last.values_at(:out, :err) else [DevNull.new, DevNull.new] end env_vars, executable = if Hash === command.first command[0..1] else [{}, command[0]] end exit_status = nil Open3.popen3(env_vars, executable) do |stdin, stdout, stderr, wait_thr| t = Thread.new do stdout.each do |line| out.puts(line) end end stderr.each do |line| err.puts(line) end t.join exit_status = wait_thr.value end exit_status end |