Module: RightGit::Shell::Interface

Included in:
Default
Defined in:
lib/right_git/shell/interface.rb

Overview

Interface for a shell intended to work with RightGit.

Instance Method Summary collapse

Instance Method Details

#default_loggerLogger

Provides a default logger object (overridable).

Returns:

  • (Logger)

    default logger for STDOUT



37
38
39
# File 'lib/right_git/shell/interface.rb', line 37

def default_logger
  @default_logger ||= ::Logger.new(STDOUT)
end

#execute(cmd, options = {}) ⇒ Integer

Run the given command and print the output to stdout.

Must be overridden.

Parameters:

  • cmd (String)

    the shell command to run

  • options (Hash) (defaults to: {})

    for execution

Options Hash (options):

  • :directory (String)

    to use as working directory during command execution or nil

  • :logger (Logger)

    logger for shell execution (default = STDOUT)

  • :outstream (IO)

    output stream to receive STDOUT and STDERR from command (default = STDOUT)

  • :raise_on_failure (TrueClass|FalseClass)

    if true, wil raise a RuntimeError if the command does not end successfully (default), false to ignore errors

  • :set_env_vars (Hash)

    environment variables to set during execution (default = none set)

  • :clear_env_vars (Hash)

    environment variables to clear during execution (default = none cleared but see :clean_bundler_env)

Returns:

  • (Integer)

    exitstatus of the command

Raises:

  • (ShellError)

    on failure only if :raise_on_failure is true



57
58
59
# File 'lib/right_git/shell/interface.rb', line 57

def execute(cmd, options = {})
  raise NotImplementedError
end

#output_for(cmd, options = {}) ⇒ Object

Invoke a shell command and return its output as a string, similar to backtick but defaulting to raising exception on failure.

Must be overridden.

Parameters:

  • cmd (String)

    command to execute

  • options (Hash) (defaults to: {})

    for execution (see execute)

Raises:

  • (ShellError)

    on failure only if :raise_on_failure is true



70
71
72
# File 'lib/right_git/shell/interface.rb', line 70

def output_for(cmd, options = {})
  raise NotImplementedError
end