Module: Async::Process

Defined in:
lib/async/process.rb,
lib/async/process/child.rb,
lib/async/process/version.rb

Defined Under Namespace

Classes: Child

Constant Summary collapse

VERSION =
"1.3.1"

Class Method Summary collapse

Class Method Details

.capture(*arguments, **options) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/async/process.rb', line 33

def self.capture(*arguments, **options)
  input, output = Async::IO.pipe
  options[:out] = output.io
  
  runner = Async do
    spawn(*arguments, **options)
  ensure
    output.close
  end
  
  Sync do
    input.read
  ensure
    runner.wait
    input.close
  end
end

.spawn(*arguments, **options) ⇒ Object



29
30
31
# File 'lib/async/process.rb', line 29

def self.spawn(*arguments, **options)
  Child.new(*arguments, **options).wait
end