Sha256: 6ce6637fe301166f1fa05970ecfc6fcfbd0bba8ff60859371dc1b7c0efd71724

Contents?: true

Size: 1.23 KB

Versions: 2

Compression:

Stored size: 1.23 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)
        @cmd               = cmd
        @working_directory = working_directory
        @environment       = environment
        @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

2 entries across 2 versions & 1 rubygems

Version Path
aruba-0.8.0.pre2 lib/aruba/processes/basic_process.rb
aruba-0.8.0.pre lib/aruba/processes/basic_process.rb