Class: Aruba::Processes::BasicProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/processes/basic_process.rb

Overview

Basic Process

`BasicProcess` is not meant for direct use - `BasicProcess.new` - by users.

Direct Known Subclasses

DebugProcess, InProcess, SpawnProcess

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0) ⇒ BasicProcess

Returns a new instance of BasicProcess.


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aruba/processes/basic_process.rb', line 16

def initialize(cmd, exit_timeout, io_wait_timeout, working_directory, environment = ENV.to_hash.dup, main_class = nil, stop_signal = nil, startup_wait_time = 0)
  @cmd               = cmd
  @working_directory = working_directory
  @environment       = environment
  @main_class        = main_class
  @exit_status       = nil
  @stop_signal       = stop_signal
  @startup_wait_time = startup_wait_time

  @exit_timeout    = exit_timeout
  @io_wait_timeout = io_wait_timeout

  @started         = false
  @timed_out       = false
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def environment
  @environment
end

#exit_statusObject (readonly)

Returns the value of attribute exit_status


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def exit_status
  @exit_status
end

#exit_timeoutObject (readonly)

Returns the value of attribute exit_timeout


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def exit_timeout
  @exit_timeout
end

#io_wait_timeoutObject (readonly)

Returns the value of attribute io_wait_timeout


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def io_wait_timeout
  @io_wait_timeout
end

#main_classObject (readonly)

Returns the value of attribute main_class


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def main_class
  @main_class
end

#startup_wait_timeObject (readonly)

Returns the value of attribute startup_wait_time


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def startup_wait_time
  @startup_wait_time
end

#working_directoryObject (readonly)

Returns the value of attribute working_directory


14
15
16
# File 'lib/aruba/processes/basic_process.rb', line 14

def working_directory
  @working_directory
end

Instance Method Details

#after_runObject

Hook which is run after command is run


108
# File 'lib/aruba/processes/basic_process.rb', line 108

def after_run; end

#before_runObject

Hook which is run before command is run


105
# File 'lib/aruba/processes/basic_process.rb', line 105

def before_run; end

#close_ioObject


63
64
65
# File 'lib/aruba/processes/basic_process.rb', line 63

def close_io(*)
  NotImplementedError
end

#commandlineObject

Return command line


33
34
35
# File 'lib/aruba/processes/basic_process.rb', line 33

def commandline
  @cmd
end

#contentObject


75
76
77
# File 'lib/aruba/processes/basic_process.rb', line 75

def content
  NotImplementedError
end

#filesystem_statusObject


71
72
73
# File 'lib/aruba/processes/basic_process.rb', line 71

def filesystem_status
  NotImplementedError
end

#inspectObject Also known as: to_s


110
111
112
113
114
115
116
117
118
# File 'lib/aruba/processes/basic_process.rb', line 110

def inspect
  # rubocop:disable Style/UnneededInterpolation
  out = truncate("#{stdout(wait_for_io: 0).inspect}", 35)
  err = truncate("#{stderr(wait_for_io: 0).inspect}", 35)
  # rubocop:enable Style/UnneededInterpolation

  fmt = '#<%s:%s commandline="%s": stdout=%s stderr=%s>'
  format fmt, self.class, self.object_id, commandline, out, err
end

#output(opts = {}) ⇒ Object

Output stderr and stdout


43
44
45
# File 'lib/aruba/processes/basic_process.rb', line 43

def output(opts = {})
  stdout(opts) + stderr(opts)
end

#pidObject

Output pid of process


38
39
40
# File 'lib/aruba/processes/basic_process.rb', line 38

def pid
  'No implemented'
end

#restartObject

Restart a command


84
85
86
87
# File 'lib/aruba/processes/basic_process.rb', line 84

def restart
  stop
  start
end

#send_signalObject


67
68
69
# File 'lib/aruba/processes/basic_process.rb', line 67

def send_signal(*)
  NotImplementedError
end

#started?Boolean

Was process already started

Returns:

  • (Boolean)

95
96
97
# File 'lib/aruba/processes/basic_process.rb', line 95

def started?
  @started == true
end

#stderrObject


59
60
61
# File 'lib/aruba/processes/basic_process.rb', line 59

def stderr(*)
  NotImplementedError
end

#stdinObject


51
52
53
# File 'lib/aruba/processes/basic_process.rb', line 51

def stdin(*)
  NotImplementedError
end

#stdoutObject


55
56
57
# File 'lib/aruba/processes/basic_process.rb', line 55

def stdout(*)
  NotImplementedError
end

#stopped?Boolean

Was process already stopped

Returns:

  • (Boolean)

90
91
92
# File 'lib/aruba/processes/basic_process.rb', line 90

def stopped?
  @started == false
end

#timed_out?Boolean

Does the process failed to stop in time

Returns:

  • (Boolean)

100
101
102
# File 'lib/aruba/processes/basic_process.rb', line 100

def timed_out?
  @timed_out == true
end

#waitObject


79
80
81
# File 'lib/aruba/processes/basic_process.rb', line 79

def wait
  NotImplementedError
end

#writeObject


47
48
49
# File 'lib/aruba/processes/basic_process.rb', line 47

def write(*)
  NotImplementedError
end