Class: Departure::Logger

Inherits:
Object
  • Object
show all
Defined in:
lib/departure/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

Instance Method Details

#say(message, subitem = false) ⇒ Object

Outputs the message through the stdout, following the ActiveRecord::Migration log format

Parameters:

  • message (String)
  • subitem (Boolean) (defaults to: false)

    whether to show message as a nested log item



13
14
15
# File 'lib/departure/logger.rb', line 13

def say(message, subitem = false)
  write "#{subitem ? "   ->" : "--"} #{message}"
end

#write(text = '') ⇒ Object

Outputs the text through the stdout adding a new line at the end

Parameters:

  • text (String) (defaults to: '')


20
21
22
# File 'lib/departure/logger.rb', line 20

def write(text = '')
  puts(text)
end

#write_no_newline(text) ⇒ Object

Outputs the text through the stdout without adding a new line at the end

Parameters:

  • text (String)


27
28
29
# File 'lib/departure/logger.rb', line 27

def write_no_newline(text)
  print(text)
end