Class: Imap::Backup::Text::Sanitizer
- Inherits:
-
Object
- Object
- Imap::Backup::Text::Sanitizer
- Extended by:
- Forwardable
- Defined in:
- lib/imap/backup/text/sanitizer.rb
Overview
Wraps standard output and hides passwords from debug output Any text matching Net::IMAP debug output of passwords is sanitized
Instance Method Summary collapse
-
#flush ⇒ void
Outputs any text still not printed.
-
#initialize(output) ⇒ Sanitizer
constructor
A new instance of Sanitizer.
-
#print(*args) ⇒ void
Outputs everything up to the last newline character, storing whatever follows the newline.
Constructor Details
#initialize(output) ⇒ Sanitizer
Returns a new instance of Sanitizer.
17 18 19 20 |
# File 'lib/imap/backup/text/sanitizer.rb', line 17 def initialize(output) @output = output @current = "" end |
Instance Method Details
#flush ⇒ void
This method returns an undefined value.
Outputs any text still not printed
40 41 42 43 44 45 |
# File 'lib/imap/backup/text/sanitizer.rb', line 40 def flush return if @current == "" clean = sanitize(@current) output.puts clean end |
#print(*args) ⇒ void
This method returns an undefined value.
Outputs everything up to the last newline character, storing whatever follows the newline.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/imap/backup/text/sanitizer.rb', line 26 def print(*args) @current << args.join loop do line, newline, rest = @current.partition("\n") break if newline != "\n" clean = sanitize(line) output.puts clean @current = rest end end |