Class: Methadone::ExecutionStrategy::JVM

Inherits:
Base
  • Object
show all
Defined in:
lib/methadone/execution_strategy/jvm.rb

Overview

Methadone Internal - treat as private

Methadone::ExecutionStrategy for the JVM that uses JVM classes to run the command and get its results.

Instance Method Summary collapse

Instance Method Details

#exception_meaning_command_not_foundObject



21
22
23
# File 'lib/methadone/execution_strategy/jvm.rb', line 21

def exception_meaning_command_not_found
  NativeException
end

#run_command(command) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/methadone/execution_strategy/jvm.rb', line 7

def run_command(command)
  process = case command
            when String then
              java.lang.Runtime.get_runtime.exec(command)
            else
              java.lang.Runtime.get_runtime.exec(*command)
            end
  process.get_output_stream.close
  stdout = input_stream_to_string(process.get_input_stream)
  stderr = input_stream_to_string(process.get_error_stream)
  exitstatus = process.wait_for
  [stdout.chomp,stderr.chomp,OpenStruct.new(:exitstatus => exitstatus)]
end