Class: Terrapin::CommandLine::ProcessRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/terrapin/command_line/runners/process_runner.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/terrapin/command_line/runners/process_runner.rb', line 6

def self.available?
  Process.respond_to?(:spawn)
end

.supported?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/terrapin/command_line/runners/process_runner.rb', line 10

def self.supported?
  available? && !OS.java?
end

Instance Method Details

#call(command, env = {}, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/terrapin/command_line/runners/process_runner.rb', line 18

def call(command, env = {}, options = {})
  pipe = MultiPipe.new
  pid = spawn(env, command, options.merge(pipe.pipe_options))
  pipe.read_and_then do
    waitpid(pid)
  end
  pipe.output
end

#supported?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/terrapin/command_line/runners/process_runner.rb', line 14

def supported?
  self.class.supported?
end