1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Only check for color once

This commit is contained in:
Ryan Fitzgerald 2012-09-08 21:46:37 -07:00
parent f4b7ddf870
commit 0e221391b0

View file

@ -12,13 +12,9 @@ require 'open4'
# TODO: Make own gem (assigned to rking)
module Bacon
COLORS = {'F' => 31, 'E' => 35, 'M' => 33, '.' => 32}
USE_COLOR = Pry::Helpers::BaseHelpers.use_ansi_codes?
module TestUnitOutput
def handle_specification(name)
@use_color = Pry::Helpers::BaseHelpers.use_ansi_codes?
yield
end
def handle_requirement(description)
error = yield
@ -44,7 +40,7 @@ module Bacon
end
def colorize_string(text, color = nil)
if @use_color
if USE_COLOR
"\e[#{ COLORS[color || text] }m#{ text }\e[0m"
else
text