lib/nanoc/cli/cleaning_stream.rb in nanoc-3.7.4 vs lib/nanoc/cli/cleaning_stream.rb in nanoc-3.7.5
- old
+ new
@@ -1,13 +1,11 @@
# encoding: utf-8
module Nanoc::CLI
-
# An output stream that passes output through stream cleaners. This can be
# used to strip ANSI color sequences, for instance.
class CleaningStream
-
# @param [IO, StringIO] stream The stream to wrap
def initialize(stream)
@stream = stream
@stream_cleaners = []
end
@@ -18,11 +16,11 @@
# @param [Nanoc::CLI::StreamCleaners::Abstract] klass The class of the
# stream cleaner to add
#
# @return [void]
def add_stream_cleaner(klass)
- unless @stream_cleaners.map { |c| c.class }.include?(klass)
+ unless @stream_cleaners.map(&:class).include?(klass)
@stream_cleaners << klass.new
end
end
# Removes the stream cleaner for the given class from this cleaning stream.
@@ -120,16 +118,14 @@
end
protected
def _nanoc_clean(s)
- @stream_cleaners.reduce(s) { |m, c| c.clean(m) }
+ @stream_cleaners.reduce(s) { |a, e| e.clean(a) }
end
def _nanoc_swallow_broken_pipe_errors_while
yield
rescue Errno::EPIPE
end
-
end
-
end