lib/model_probe.rb
def probe
    name_pad = columns.map { |c| c.name.length }.max + 1
    type_pad = columns.map { |c| c.type.length }.max + 2
    sql_type_pad = columns.map { |c| c.sql_type.length }.max + 1

    columns.sort { |a, b| a.name <=> b.name }.map do |column|
      name = column.name
      name = "* #{name}" if primary_key_column?(column)
      print yellow(name.to_s.rjust(name_pad))
      print " "
      print blue(column.type.to_s.ljust(type_pad, "."))
      print magenta(column.sql_type.to_s.ljust(sql_type_pad))
      column.null ? print(red("NULL")) : print("    ")
      print " [#{column.default}]" if column.default
      print " #{gray column.comment}" if column.comment
      puts
    end
    nil
  end
# Pretty prints column meta data for an ActiveModel
Pretty prints column meta data for an ActiveModel
Pretty prints column meta data for an ActiveModel
def probe
    name_pad = columns.map { |c| c.name.length }.max + 1
    type_pad = columns.map { |c| c.type.length }.max + 2
    sql_type_pad = columns.map { |c| c.sql_type.length }.max + 1
    columns.sort { |a, b| a.name <=> b.name }.map do |column|
      name = column.name
      name = "* #{name}" if primary_key_column?(column)
      print yellow(name.to_s.rjust(name_pad))
      print " "
      print blue(column.type.to_s.ljust(type_pad, "."))
      print magenta(column.sql_type.to_s.ljust(sql_type_pad))
      column.null ? print(red("NULL")) : print("    ")
      print " [#{column.default}]" if column.default
      print " #{gray column.comment}" if column.comment
      puts
    end
    nil
  end
def probe name_pad = columns . map { | c | c . name . length } . max + 1 type_pad = columns . map { | c | c . type . length } . max + 2 sql_type_pad = columns . map { | c | c . sql_type . length } . max + 1 columns . sort { | a , b | a . name <=> b . name } . map do | column | name = column . name name = "* #{name}" if primary_key_column? ( column ) print yellow ( name . to_s . rjust ( name_pad ) ) print " " print blue ( column . type . to_s . ljust ( type_pad , "." ) ) print magenta ( column . sql_type . to_s . ljust ( sql_type_pad ) ) column . null ? print ( red ( "NULL" ) ) : print ( "    " ) print " [#{column.default}]" if column . default print " #{gray column.comment}" if column . comment puts end nil end
Pretty prints column meta data for an ActiveModel
Pretty prints column meta data for an ActiveModel