Sha256: adec70c28164288194f16eb72dd6b4af5d4f3e1c06d006a34c61f365331f352d

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require 'aruba/platform'
require 'shellwords'

module Aruba
  module Processes
    class BasicProcess
      attr_reader :exit_status, :environment

      def initialize(cmd, exit_timeout, io_wait, working_directory, environment = ENV.to_hash.dup, main_class = nil)
        @cmd               = cmd
        @working_directory = working_directory
        @environment       = environment
        @main_class        = main_class
        @exit_status       = nil
      end

      # Return command line
      def commandline
        @cmd
      end

      # Output stderr and stdout
      def output
        stdout + stderr
      end

      def write(*)
        NotImplementedError
      end

      def stdin(*)
        NotImplementedError
      end

      def stdout(*)
        NotImplementedError
      end

      def stderr(*)
        NotImplementedError
      end

      def close_io(*)
        NotImplementedError
      end

      # Was process already stopped
      def stopped?
        @stopped == true
      end

      # Does the process failed to stop in time
      def timed_out?
        @timed_out == true
      end

      # Hook which is run before command is run
      def before_run; end

      # Hook which is run after command is run
      def after_run; end

      private

      def which(program)
        Aruba.platform.which(program, environment['PATH'])
      end

      def command
        Shellwords.split(commandline).first
      end

      def arguments
        return Shellwords.split(commandline)[1..-1] if Shellwords.split(commandline).size > 1

        []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aruba-0.9.0.pre lib/aruba/processes/basic_process.rb