lib/arql/commands/models.rb in arql-0.2.5 vs lib/arql/commands/models.rb in arql-0.2.6

- old
+ new

@@ -3,28 +3,32 @@ module Arql::Commands module Models class << self def models t = [] - t << ['Table Name', 'Model Class', 'Abbr'] + t << ['Table Name', 'Model Class', 'Abbr', 'Comment'] t << nil Arql::Definition.models.each do |definition| - t << [definition[:table], definition[:model].name, definition[:abbr] || ''] + t << [definition[:table], definition[:model].name, definition[:abbr] || '', definition[:comment] || ''] end t end - def models_table + def models_table(regexp) Terminal::Table.new do |t| - models.each { |row| t << (row || :separator) } + models.each_with_index { |row, idx| t << (row || :separator) if row.nil? || + regexp.nil? || + idx.zero? || + row.any? { |e| e =~ regexp } + } end end end end - Pry.commands.block_command 'm' do + Pry.commands.block_command 'm' do |regexp| puts - puts Models::models_table + puts Models::models_table(regexp.try { |e| eval(e) }) end Pry.commands.alias_command 'l', 'm' end