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, will 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)

  • :timeout (Numeric)

    to kill spawned process when time (in seconds) expires

  • :keep_alive_interval (Numeric)

    as periodic timer, in seconds, for emitting output to keep travis ci from killing job or nil to remain silent (default). note that keep-alives are always written to the logger even if command output is being captured by :outstream

  • :keep_alive_timeout (Numeric)

    as overall timeout, in seconds, for periodically emitting shell output when child process is silent, which prevents travis ci from killing a silent job, or nil to remain silent (default). can be combined with :timeout to ensure child process is kept alive for a maximum amount of time before it will be abandoned.

Returns:

  • (Integer)

    exitstatus of the command

Raises:

  • (ShellError)

    on failure only if :raise_on_failure is true



72
73
74
# File 'lib/right_git/shell/interface.rb', line 72

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



85
86
87
# File 'lib/right_git/shell/interface.rb', line 85

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