class EasyAppHelper::Processes::Base
Attributes
exit_status[RW]
last_pid[RW]
log_output[RW]
mode[R]
process_state[RW]
show_output[RW]
Public Class Methods
new(command = nil, mode = :synchronous)
click to toggle source
# File lib/easy_app_helper/processes/base.rb, line 14 def initialize(command = nil, mode = :synchronous) self.command = command self.process_state = :not_started self.mode = mode self.creation_time = Time.now end
Public Instance Methods
mode=(mode)
click to toggle source
# File lib/easy_app_helper/processes/base.rb, line 21 def mode=(mode) mode_processor = Object.const_get "EasyAppHelper::Processes::#{mode.to_s.capitalize}" self.extend mode_processor @mode = mode.to_sym rescue raise "Invalid process mode '#{mode}'" end
Private Instance Methods
report(message, to_stdout = true)
click to toggle source
# File lib/easy_app_helper/processes/base.rb, line 33 def report(message, to_stdout = true) if show_output to_stdout ? puts(message) : STDERR.puts(message) end if log_output log_line = "[subprocess #{last_pid}] - #{message}" if to_stdout EasyAppHelper.logger.debug log_line else EasyAppHelper.logger.warn log_line end end end