Sha256: 781b086db6c0837f80ae185acc0b2c648a1e9a400ec15f6f04aae85b74f8720d

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 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, 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

      # 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, path = environment['PATH'])
        Aruba::Platform.which(program, 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

3 entries across 3 versions & 1 rubygems

Version Path
aruba-0.8.1 lib/aruba/processes/basic_process.rb
aruba-0.8.0 lib/aruba/processes/basic_process.rb
aruba-0.8.0.pre3 lib/aruba/processes/basic_process.rb