class GitCommander::System::Command

@abstract Wraps a system command with logging, stderr, and stdout capture

Attributes

command_with_arguments[R]
error[RW]
name[R]
options[R]
output[RW]
status[RW]

Public Class Methods

new(command_with_arguments, options = {}) click to toggle source
# File lib/git_commander/system.rb, line 17
def initialize(command_with_arguments, options = {})
  @command_with_arguments = command_with_arguments
  @name = command_with_arguments.split(/\w/i).first
  @options = DEFAULT_RUN_OPTIONS.merge(options)
end

Public Instance Methods

run() click to toggle source
# File lib/git_commander/system.rb, line 23
def run
  log_command_initiated
  @output, @error, @status = Open3.capture3(command_with_arguments)
  log_command_completed
end

Private Instance Methods

log_command_completed() click to toggle source
# File lib/git_commander/system.rb, line 37
      def log_command_completed
        GitCommander.logger.debug <<~COMMAND_LOG
          [system] Ran '#{command_with_arguments}' with options #{options.inspect}.
          \tStatus: #{status}
          \tOutput: #{output.inspect}
          \tError: #{error.inspect}
        COMMAND_LOG
      end
log_command_initiated() click to toggle source
# File lib/git_commander/system.rb, line 31
      def log_command_initiated
        GitCommander.logger.debug <<~COMMAND_LOG
          [system] Running '#{command_with_arguments}' with options #{options.inspect} ...
        COMMAND_LOG
      end