Class: GitCommander::System Abstract

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/git_commander/system.rb

Overview

This class is abstract.

A wrapper for system calls

Defined Under Namespace

Classes: Command, RunError

Constant Summary collapse

DEFAULT_RUN_OPTIONS =
{
  silent: false
}.freeze

Class Method Summary collapse

Class Method Details

.run(command_with_arguments, options = {}) ⇒ Object

Runs a system command

Options Hash (options):

  • :silent (Boolean)

    Supress the output of the command

  • :blocking (Boolean)

    Supress errors running the command



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/git_commander/system.rb', line 56

def self.run(command_with_arguments, options = {})
  command = Command.new(command_with_arguments, options)

  command.run

  unless command.status.success? || command.options[:blocking] == false
    raise RunError, "\"#{command.error}\" \"#{command.name}\" failed to run."
  end

  puts command.output if command.options[:silent] == false
  command.output.strip
end

.say(new_output) ⇒ Object

Appends to the output stream



71
72
73
74
# File 'lib/git_commander/system.rb', line 71

def self.say(new_output)
  GitCommander.logger.info "[System#say] #{new_output}"
  puts new_output
end