Sha256: ae12024e849b423a13db19671756e328c112ff4b185721bcc412ef0d697779a9

Contents?: true

Size: 1.08 KB

Versions: 26

Compression:

Stored size: 1.08 KB

Contents

module Methadone
  module ExecutionStrategy
    # <b>Methadone Internal - treat as private</b>
    #
    # Methadone::ExecutionStrategy for the JVM that uses JVM classes to run the command and get its results.
    class JVM < Base
      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

      def exception_meaning_command_not_found
        NativeException
      end

    private
      def input_stream_to_string(is)
        ''.tap do |string|
          ch = is.read
          while ch != -1
            string << ch
            ch = is.read
          end
        end
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 2 rubygems

Version Path
methadone-2.0.2 lib/methadone/execution_strategy/jvm.rb
methadone-2.0.1 lib/methadone/execution_strategy/jvm.rb
methadone-2.0.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.5 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.4 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.3 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.2 lib/methadone/execution_strategy/jvm.rb
methadone-rehab-1.9.2 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.1 lib/methadone/execution_strategy/jvm.rb
methadone-1.9.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.8.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.7.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.6.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.5.1 lib/methadone/execution_strategy/jvm.rb
methadone-1.5.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.4.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.3.2 lib/methadone/execution_strategy/jvm.rb
methadone-1.3.1 lib/methadone/execution_strategy/jvm.rb
methadone-1.3.0 lib/methadone/execution_strategy/jvm.rb
methadone-1.2.6 lib/methadone/execution_strategy/jvm.rb