Permalink
Browse files

Use `$stderr` instead of `STDERR` to allow redirection.

  • Loading branch information...
1 parent 0769b90 commit d011713ad0f2f37947752aa2161e620c688df3a2 @netzpirat netzpirat committed Oct 8, 2012
Showing with 11 additions and 7 deletions.
  1. +4 −0 CHANGELOG.md
  2. +7 −7 lib/guard/ui.rb
View
@@ -1,3 +1,7 @@
+## Master
+
+- Use `$stderr` instead of `STDERR` to allow redirection.
+
## 1.4.1 - 5 October, 2012
- [#334][] Extend `:tmux` notifier with use of `tmux display-message` and options to configure them. ([@matthijsgroen][])
View
@@ -2,7 +2,7 @@ module Guard
# The UI class helps to format messages for the user. Everything that is logged
# through this class is considered either as an error message or a diagnostic
- # message and is written to standard error (STDERR).
+ # message and is written to standard error ($stderr).
#
# If your Guard plugin does some output that is piped into another process for further
# processing, please just write it to STDOUT with `puts`.
@@ -20,7 +20,7 @@ class << self
def info(message, options = { })
unless ENV['GUARD_ENV'] == 'test'
reset_line if options[:reset]
- STDERR.puts color(message) if message != ''
+ $stderr.puts color(message) if message != ''
end
end
@@ -32,7 +32,7 @@ def info(message, options = { })
def warning(message, options = { })
unless ENV['GUARD_ENV'] == 'test'
reset_line if options[:reset]
- STDERR.puts color('WARNING: ', :yellow) + message
+ $stderr.puts color('WARNING: ', :yellow) + message
end
end
@@ -44,7 +44,7 @@ def warning(message, options = { })
def error(message, options = { })
unless ENV['GUARD_ENV'] == 'test'
reset_line if options[:reset]
- STDERR.puts color('ERROR: ', :red) + message
+ $stderr.puts color('ERROR: ', :red) + message
end
end
@@ -56,7 +56,7 @@ def error(message, options = { })
def deprecation(message, options = { })
unless ENV['GUARD_ENV'] == 'test'
reset_line if options[:reset]
- STDERR.puts color('DEPRECATION: ', :red) + message
+ $stderr.puts color('DEPRECATION: ', :red) + message
end
end
@@ -68,14 +68,14 @@ def deprecation(message, options = { })
def debug(message, options = { })
unless ENV['GUARD_ENV'] == 'test'
reset_line if options[:reset]
- STDERR.puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:debug]
+ $stderr.puts color("DEBUG (#{Time.now.strftime('%T')}): ", :yellow) + message if ::Guard.options && ::Guard.options[:debug]
end
end
# Reset a line.
#
def reset_line
- STDERR.print(color_enabled? ? "\r\e[0m" : "\r\n")
+ $stderr.print(color_enabled? ? "\r\e[0m" : "\r\n")
end
# Clear the output if clearable.

0 comments on commit d011713

Please sign in to comment.