Module: RGitFlow::Printing

Included in:
CLI, Install, Tasks::Task
Defined in:
lib/rgitflow/printing.rb

Overview

Contains logic for printing messages to the console. Supports ANSI colors. Inspired by rubygems-tasks' printing.rb

Constant Summary collapse

STATUS_PREFIX =

String to prepend to any status messages

Returns:

  • (String)

    prefix for status messages

if $stdout.tty?
  "#{ANSI::Constants::GREEN}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
else
  '>>>'
end
DEBUG_PREFIX =

String to prepend to any debug messages

Returns:

  • (String)

    prefix for debug messages

if $stderr.tty?
  "#{ANSI::Constants::YELLOW}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
else
  '>>>'
end
ERROR_PREFIX =

String to prepend to any error messages

Returns:

  • (String)

    prefix for error messages

if $stderr.tty?
  "#{ANSI::Constants::RED}#{ANSI::Constants::BRIGHT}>>>#{ANSI::Constants::CLEAR}"
else
  '>>>'
end
INPUT_PREFIX =
if $stderr.tty?
  "#{ANSI::Constants::BLUE}#{ANSI::Constants::BRIGHT}<<<#{ANSI::Constants::CLEAR}"
else
  '<<<'
end

Instance Method Summary collapse

Instance Method Details

#debug(message = '') ⇒ void (protected)

This method returns an undefined value.

Prints a debug message to the console

Parameters:

  • message (String) (defaults to: '')

    message to print to the console



52
53
54
55
56
57
# File 'lib/rgitflow/printing.rb', line 52

def debug(message = '')
  if Rake.verbose
    STDERR.puts "#{DEBUG_PREFIX} #{message}"
  end
  nil
end

#error(message = '') ⇒ void (protected)

This method returns an undefined value.

Prints an error message to the console

Parameters:

  • message (String) (defaults to: '')

    message to print to the console



62
63
64
65
# File 'lib/rgitflow/printing.rb', line 62

def error(message = '')
  STDERR.puts "#{ERROR_PREFIX} #{message}"
  nil
end

#prompt(message = '') ⇒ void (protected)

This method returns an undefined value.

Prints a prompt message to the console

Parameters:

  • message (String) (defaults to: '')

    message to print to the console



70
71
72
73
74
# File 'lib/rgitflow/printing.rb', line 70

def prompt(message = '')
  status message
  STDOUT.print "#{INPUT_PREFIX} "
  nil
end

#status(message = '') ⇒ void (protected)

This method returns an undefined value.

Prints a status message to the console

Parameters:

  • message (String) (defaults to: '')

    message to print to the console



42
43
44
45
46
47
# File 'lib/rgitflow/printing.rb', line 42

def status(message = '')
  if Rake.verbose
    STDOUT.puts "#{STATUS_PREFIX} #{message}"
  end
  nil
end