class Arrival::Logger
Copies the ActiveRecord::Migration say
and write
plus a new write_no_newline
to log the migration's status. It's not possible to reuse the from ActiveRecord::Migration because the migration's instance can't be seen from the connection adapter.
Attributes
sanitizers[RW]
Public Class Methods
new(sanitizers)
click to toggle source
# File lib/arrival/logger.rb, line 7 def initialize(sanitizers) @sanitizers = sanitizers end
Public Instance Methods
say(message, subitem = false)
click to toggle source
Outputs the message through the stdout, following the ActiveRecord::Migration log format
@param message [String] @param subitem [Boolean] whether to show message as a nested log item
# File lib/arrival/logger.rb, line 16 def say(message, subitem = false) write "#{subitem ? ' ->' : '--'} #{message}" end
write(text = '')
click to toggle source
Outputs the text through the stdout adding a new line at the end
@param text [String]
# File lib/arrival/logger.rb, line 23 def write(text = '') puts(sanitize(text)) end
write_no_newline(text)
click to toggle source
Outputs the text through the stdout without adding a new line at the end
@param text [String]
# File lib/arrival/logger.rb, line 30 def write_no_newline(text) print(sanitize(text)) end
Private Instance Methods
sanitize(text)
click to toggle source
# File lib/arrival/logger.rb, line 38 def sanitize(text) sanitizers.inject(text) { |memo, sanitizer| sanitizer.execute(memo) } end