Class: Cocaine::CommandLine::PosixRunner
- Inherits:
-
Object
- Object
- Cocaine::CommandLine::PosixRunner
- Defined in:
- lib/cocaine/command_line/runners/posix_runner.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.available? ⇒ Boolean
6 7 8 9 10 11 12 13 |
# File 'lib/cocaine/command_line/runners/posix_runner.rb', line 6 def self.available? begin require 'posix/spawn' true rescue LoadError => e false end end |
.supported? ⇒ Boolean
15 16 17 |
# File 'lib/cocaine/command_line/runners/posix_runner.rb', line 15 def self.supported? available? && !Cocaine::CommandLine.java? end |
Instance Method Details
#call(command, env = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/cocaine/command_line/runners/posix_runner.rb', line 23 def call(command, env = {}) input, output = IO.pipe pid = spawn(env, command, :out => output) output.close result = "" while partial_result = input.read(8192) result << partial_result end waitpid(pid) input.close result end |
#supported? ⇒ Boolean
19 20 21 |
# File 'lib/cocaine/command_line/runners/posix_runner.rb', line 19 def supported? self.class.supported? end |