Class: Imap::Backup::Text::Sanitizer

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(output) ⇒ Sanitizer

Returns a new instance of Sanitizer.

Parameters:

  • output (IO)

    the stream to write output to

 17 18 19 20
# File 'lib/imap/backup/text/sanitizer.rb', line 17 def initialize(output) @output = output @current = "" end 

Instance Method Details

#flushvoid

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 

This method returns an undefined value.

Outputs everything up to the last newline character, storing whatever follows the newline.

Parameters:

  • args (Array<String>)

    lines of text

 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