Sha256: 3468445325397de00aa2ad93563eb044bafbe8f60764e2721f1f039bc4111862

Contents?: true

Size: 943 Bytes

Versions: 2

Compression:

Stored size: 943 Bytes

Contents

module Departure
  # 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.
  class Logger

    # 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
    def say(message, subitem = false)
      write "#{subitem ? "   ->" : "--"} #{message}"
    end

    # Outputs the text through the stdout adding a new line at the end
    #
    # @param text [String]
    def write(text = '')
      puts(text)
    end

    # Outputs the text through the stdout without adding a new line at the end
    #
    # @param text [String]
    def write_no_newline(text)
      print(text)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
departure-1.0.1 lib/departure/logger.rb
departure-1.0.0 lib/departure/logger.rb