Sha256: 2280a743ce75e4ea3a26059ad57000ba963654ca1a9803c789b22e30507de29f
Contents?: true
Size: 1.18 KB
Versions: 14
Compression:
Stored size: 1.18 KB
Contents
require 'open3' module Climatic module Processes class Base include Climatic::Processes::Command include Climatic::Processes::TimeManagement attr_reader :process_state, :exit_status, :last_pid, :mode attr_accessor :show_output, :log_output def initialize(command = nil, mode = :synchronous) self.command = command self.process_state = :not_started self.mode = mode self.creation_time = Time.now end def mode=(mode) mode_processor = Object.const_get "Climatic::Processes::#{mode.to_s.capitalize}" self.extend mode_processor @mode = mode.to_sym rescue raise "Invalid process mode '#{mode}'" end private attr_writer :process_state, :exit_status, :last_pid 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 Climatic.logger.debug log_line else Climatic.logger.warn log_line end end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems