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
- #<<(str) ⇒ Object private
- #close ⇒ Object private
- #closed? ⇒ Boolean private
- #exist? ⇒ Boolean private
- #exists? ⇒ Boolean private
- #external_encoding ⇒ Object private
- #flush ⇒ Object private
- #isatty ⇒ Object private
- #print(str) ⇒ Object private
- #printf(*args) ⇒ Object private
- #puts(*str) ⇒ Object private
- #reopen(*args) ⇒ 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(str) ⇒ 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.
9 10 11 12 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 9 def initialize(stream) @stream = stream @stream_cleaners = [] end |
Instance Method Details
#<<(str) ⇒ 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.
49 50 51 52 53 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 49 def <<(str) _nanoc_swallow_broken_pipe_errors_while do @stream << (_nanoc_clean(str)) 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.
21 22 23 24 25 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 21 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.
107 108 109 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 107 def close @stream.close end |
#closed? ⇒ 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.
112 113 114 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 112 def closed? @stream.closed? 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.
117 118 119 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 117 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.
122 123 124 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 122 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.
147 148 149 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 147 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.
66 67 68 69 70 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 66 def flush _nanoc_swallow_broken_pipe_errors_while do @stream.flush end end |
#isatty ⇒ 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.
61 62 63 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 61 def isatty tty? end |
#print(str) ⇒ 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.
78 79 80 81 82 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 78 def print(str) _nanoc_swallow_broken_pipe_errors_while do @stream.print(_nanoc_clean(str)) end end |
#printf(*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.
85 86 87 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 85 def printf(*args) @stream.printf(*args) end |
#puts(*str) ⇒ 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.
90 91 92 93 94 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 90 def puts(*str) _nanoc_swallow_broken_pipe_errors_while do @stream.puts(*str.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.
35 36 37 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 35 def remove_stream_cleaner(klass) @stream_cleaners.delete_if { |c| c.instance_of?(klass) } end |
#reopen(*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.
102 103 104 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 102 def reopen(*args) @stream.reopen(*args) 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.
152 153 154 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 152 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.
97 98 99 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 97 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.
137 138 139 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 137 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.
142 143 144 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 142 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.
73 74 75 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 73 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.
56 57 58 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 56 def tty? @_tty_eh ||= @stream.tty? # rubocop:disable Naming/MemoizedInstanceVariableName 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.
127 128 129 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 127 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.
132 133 134 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 132 def winsize=(arg) @stream.winsize = arg end |
#write(str) ⇒ 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.
42 43 44 45 46 |
# File 'lib/nanoc/cli/cleaning_stream.rb', line 42 def write(str) _nanoc_swallow_broken_pipe_errors_while do @stream.write(_nanoc_clean(str)) end end |