Class: Arrival::Logger
- Inherits:
-
Object
- Object
- Arrival::Logger
- Defined in:
- lib/arrival/logger.rb
Overview
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.
Instance Method Summary collapse
-
#initialize(sanitizers) ⇒ Logger
constructor
A new instance of Logger.
-
#say(message, subitem = false) ⇒ Object
Outputs the message through the stdout, following the ActiveRecord::Migration log format.
-
#write(text = '') ⇒ Object
Outputs the text through the stdout adding a new line at the end.
-
#write_no_newline(text) ⇒ Object
Outputs the text through the stdout without adding a new line at the end.
Constructor Details
#initialize(sanitizers) ⇒ Logger
Returns a new instance of Logger.
7 8 9 |
# File 'lib/arrival/logger.rb', line 7 def initialize(sanitizers) @sanitizers = sanitizers end |
Instance Method Details
#say(message, subitem = false) ⇒ Object
Outputs the message through the stdout, following the ActiveRecord::Migration log format
16 17 18 |
# File 'lib/arrival/logger.rb', line 16 def say(, subitem = false) write "#{subitem ? ' ->' : '--'} #{}" end |
#write(text = '') ⇒ Object
Outputs the text through the stdout adding a new line at the end
23 24 25 |
# File 'lib/arrival/logger.rb', line 23 def write(text = '') puts(sanitize(text)) end |
#write_no_newline(text) ⇒ Object
Outputs the text through the stdout without adding a new line at the end
30 31 32 |
# File 'lib/arrival/logger.rb', line 30 def write_no_newline(text) print(sanitize(text)) end |