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

Return a logger object to be used for logging if nothing else is passed in as an option.

Must be overridden.

Returns:

  • (Logger)

Raises:

  • (NotImplementedError)


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

def default_logger
  raise NotImplementedError
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

  • :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



55
56
57
# File 'lib/right_git/shell/interface.rb', line 55

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



68
69
70
# File 'lib/right_git/shell/interface.rb', line 68

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