Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

72 lines (61 sloc) 1.594 kB
module Guard
module UI
class << self
def info(message, options = {})
unless ENV["GUARD_ENV"] == "test"
reset_line if options[:reset]
puts reset_color(message) if message != ''
end
end
def error(message, options = {})
unless ENV["GUARD_ENV"] == "test"
reset_line if options[:reset]
puts "ERROR: #{message}"
end
end
def debug(message, options = {})
unless ENV["GUARD_ENV"] == "test"
reset_line if options[:reset]
puts "DEBUG: #{message}" if ::Guard.options && ::Guard.options[:debug]
end
end
def reset_line
if color_enabled?
print "\r\e[0m"
else
print "\r\n"
end
end
def clear
system("clear;")
end
private
def reset_color(text)
color(text, "\e[0m")
end
def color(text, color_code)
if color_enabled?
return "#{color_code}#{text}\e[0m"
else
return text
end
end
def color_enabled?
@color_enabled ||= if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
unless ENV['ANSICON']
begin
require 'rubygems' unless ENV['NO_RUBYGEMS']
require 'Win32/Console/ANSI'
rescue LoadError
@color_enabled = false
info "You must 'gem install win32console' to use color on Windows"
false
end
end
else
true
end
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.