lib/nanoc/cli/cleaning_stream.rb in nanoc-3.6.6 vs lib/nanoc/cli/cleaning_stream.rb in nanoc-3.6.7

- old
+ new

@@ -39,41 +39,51 @@ # @group IO proxy methods # @see IO#write def write(s) - @stream.write(self.clean(s)) + self._nanoc_swallow_broken_pipe_errors_while do + @stream.write(self._nanoc_clean(s)) + end end # @see IO#<< def <<(s) - @stream.<<(self.clean(s)) + self._nanoc_swallow_broken_pipe_errors_while do + @stream.<<(self._nanoc_clean(s)) + end end # @see IO#tty? def tty? @cached_is_tty ||= @stream.tty? end # @see IO#flush def flush - @stream.flush + self._nanoc_swallow_broken_pipe_errors_while do + @stream.flush + end end # @see IO#tell def tell @stream.tell end # @see IO#print def print(s) - @stream.print(self.clean(s)) + self._nanoc_swallow_broken_pipe_errors_while do + @stream.print(self._nanoc_clean(s)) + end end # @see IO#puts def puts(*s) - @stream.puts(*s.map { |ss| self.clean(ss) }) + self._nanoc_swallow_broken_pipe_errors_while do + @stream.puts(*s.map { |ss| self._nanoc_clean(ss) }) + end end # @see StringIO#string def string @stream.string @@ -109,11 +119,16 @@ @stream.winsize=(arg) end protected - def clean(s) + def _nanoc_clean(s) @stream_cleaners.inject(s) { |m,c| c.clean(m) } + end + + def _nanoc_swallow_broken_pipe_errors_while + yield + rescue Errno::EPIPE end end end