Class: Nanoc::CLI::CleaningStream Private
- Inherits:
-
Object
- Object
- Nanoc::CLI::CleaningStream
- Defined in:
- lib/nanoc/cli/cleaning_stream.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
An output stream that passes output through stream cleaners. This can be used to strip ANSI color sequences, for instance.
IO proxy methods collapse
- #<<(s) ⇒ Object private
- #close ⇒ Object private
- #exist? ⇒ Boolean private
- #exists? ⇒ Boolean private
- #external_encoding ⇒ Object private
- #flush ⇒ Object private
- #print(s) ⇒ Object private
- #puts(*s) ⇒ Object private
- #reopen(*a) ⇒ Object private
- #set_encoding(*args) ⇒ Object private
- #string ⇒ Object private
- #sync ⇒ Object private
- #sync=(arg) ⇒ Object private
- #tell ⇒ Object private
- #tty? ⇒ Boolean private
- #winsize ⇒ Object private
- #winsize=(arg) ⇒ Object private
- #write(s) ⇒ Object private
Instance Method Summary collapse
-
#add_stream_cleaner(klass) ⇒ void
private
Adds a stream cleaner for the given class to this cleaning stream.
-
#initialize(stream) ⇒ CleaningStream
constructor
private
A new instance of CleaningStream.
-
#remove_stream_cleaner(klass) ⇒ void
private
Removes the stream cleaner for the given class from this cleaning stream.
Constructor Details
#initialize(stream) ⇒ CleaningStream
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of CleaningStream.
8 9 10 11 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 8 def initialize(stream) @stream = stream @stream_cleaners = [] end |
Instance Method Details
#<<(s) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 48 def <<(s) _nanoc_swallow_broken_pipe_errors_while do @stream.<<(_nanoc_clean(s)) end end |
#add_stream_cleaner(klass) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Adds a stream cleaner for the given class to this cleaning stream. If the cleaning stream already has the given stream cleaner, nothing happens.
20 21 22 23 24 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 20 def add_stream_cleaner(klass) unless @stream_cleaners.map(&:class).include?(klass) @stream_cleaners << klass.new end end |
#close ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
96 97 98 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 96 def close @stream.close end |
#exist? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
101 102 103 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 101 def exist? @stream.exist? end |
#exists? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
106 107 108 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 106 def exists? @stream.exists? end |
#external_encoding ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
131 132 133 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 131 def external_encoding @stream.external_encoding end |
#flush ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
60 61 62 63 64 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 60 def flush _nanoc_swallow_broken_pipe_errors_while do @stream.flush end end |
#print(s) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
72 73 74 75 76 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 72 def print(s) _nanoc_swallow_broken_pipe_errors_while do @stream.print(_nanoc_clean(s)) end end |
#puts(*s) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 82 83 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 79 def puts(*s) _nanoc_swallow_broken_pipe_errors_while do @stream.puts(*s.map { |ss| _nanoc_clean(ss) }) end end |
#remove_stream_cleaner(klass) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Removes the stream cleaner for the given class from this cleaning stream. If the cleaning stream does not have the given stream cleaner, nothing happens.
34 35 36 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 34 def remove_stream_cleaner(klass) @stream_cleaners.delete_if { |c| c.class == klass } end |
#reopen(*a) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
91 92 93 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 91 def reopen(*a) @stream.reopen(*a) end |
#set_encoding(*args) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
136 137 138 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 136 def set_encoding(*args) @stream.set_encoding(*args) end |
#string ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 86 def string @stream.string end |
#sync ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
121 122 123 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 121 def sync @stream.sync end |
#sync=(arg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
126 127 128 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 126 def sync=(arg) @stream.sync = arg end |
#tell ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
67 68 69 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 67 def tell @stream.tell end |
#tty? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 55 def tty? @cached_is_tty ||= @stream.tty? end |
#winsize ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
111 112 113 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 111 def winsize @stream.winsize end |
#winsize=(arg) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
116 117 118 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 116 def winsize=(arg) @stream.winsize = arg end |
#write(s) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
41 42 43 44 45 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 41 def write(s) _nanoc_swallow_broken_pipe_errors_while do @stream.write(_nanoc_clean(s)) end end |