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.4.0"

Class Method Summary collapse

Class Method Details

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



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/async/process.rb', line 18

def self.capture(*arguments, **options)
	input, output = ::IO.pipe
	options[:out] = output
	
	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



14
15
16
# File 'lib/async/process.rb', line 14

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