Class: Suppressor
Overview
Haml and AWS put out a lot of junk. Redirect stdout and stderr to /dev/null to suppress these useless warnings, then restore stdout and stderr at the end.
Instance Method Summary collapse
- #close! ⇒ Object
-
#initialize ⇒ Suppressor
constructor
A new instance of Suppressor.
-
#ok ⇒ Object
Restore stdout and stderr.
-
#shutup! ⇒ Object
Redirect stdout to /dev/null.
Constructor Details
#initialize ⇒ Suppressor
Returns a new instance of Suppressor.
4 5 6 7 8 |
# File 'lib/uploader/suppressor.rb', line 4 def initialize @hole = File.new('/dev/null', 'w') @orig_stdout = $stdout @orig_stderr = $stderr end |
Instance Method Details
#close! ⇒ Object
22 23 24 |
# File 'lib/uploader/suppressor.rb', line 22 def close! @hole.close end |
#ok ⇒ Object
Restore stdout and stderr
17 18 19 20 |
# File 'lib/uploader/suppressor.rb', line 17 def ok $stdout = @orig_stdout $stderr = @orig_stderr end |
#shutup! ⇒ Object
Redirect stdout to /dev/null
11 12 13 14 |
# File 'lib/uploader/suppressor.rb', line 11 def shutup! $stdout = @hole $stderr = @hole end |