Module: Gem::Tasks::Printing

Included in:
Task
Defined in:
lib/rubygems/tasks/printing.rb

Overview

Provides helper methods for printing messages.

Constant Summary collapse

ANSI_BRIGHT =

ANSI 'bright' color code

"\e[1m"
ANSI_CLEAR =

ANSI 'clear' color code

"\e[0m"
ANSI_GREEN =

ANSI 'green' color code

"\e[32m"
ANSI_YELLOW =

ANSI 'yellow' color code

"\e[33m"
ANSI_RED =

ANSI 'red' color code

"\e[31m"
STATUS_PREFIX =

Prefix for all status messages

if $stdout.tty?
  "#{ANSI_GREEN}#{ANSI_BRIGHT}>>>#{ANSI_CLEAR}"
else
  ">>>"
end
DEBUG_PREFIX =

Prefix for all debugging messages

if $stderr.tty?
   "#{ANSI_YELLOW}#{ANSI_BRIGHT}>>>#{ANSI_CLEAR}"
else
  ">>>"
end
ERROR_PREFIX =

Prefix for all error messages

if $stderr.tty?
   "#{ANSI_RED}#{ANSI_BRIGHT}!!!#{ANSI_CLEAR}"
else
  "!!!"
end

Instance Method Summary collapse

Instance Method Details

#debug(message) ⇒ Object (protected)

Prints a debugging message.

Parameters:

  • message (String)

    The message to print.



66
67
68
69
70
# File 'lib/rubygems/tasks/printing.rb', line 66

def debug(message)
  if (Rake.verbose && Rake.application.options.trace)
    $stderr.puts "#{DEBUG_PREFIX} #{message}"
  end
end

#error(message) ⇒ Object (protected)

Prints an error message and exits.

Parameters:

  • message (String)

    The message to print.



78
79
80
# File 'lib/rubygems/tasks/printing.rb', line 78

def error(message)
  $stderr.puts "#{ERROR_PREFIX} #{message}"
end

#status(message) ⇒ Object (protected)

Prints a status message.

Parameters:

  • message (String)

    The message to print.



54
55
56
57
58
# File 'lib/rubygems/tasks/printing.rb', line 54

def status(message)
  if Rake.verbose
    $stdout.puts "#{STATUS_PREFIX} #{message}"
  end
end