Sha256: b682cade60147c5e784c9b6c7afe4974a11ee5b13951dd28495a28f62c9eb4e4
Contents?: true
Size: 1.07 KB
Versions: 1
Compression:
Stored size: 1.07 KB
Contents
require 'terminal-table' module Arql::Commands module Models class << self def models t = [] t << ['Table Name', 'Model Class', 'Abbr', 'Comment'] t << nil Arql::Definition.models.each do |definition| t << [definition[:table], definition[:model].name, definition[:abbr] || '', definition[:comment] || ''] end t end def models_table(regexp) Terminal::Table.new do |t| 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 |regexp| puts puts Models::models_table(regexp.try { |e| e.start_with?('/') ? eval(e) : Regexp.new(e) }) end Pry.commands.alias_command 'l', 'm' end module Kernel def models Arql::Commands::Models::models end def tables models end def model_classes ::ArqlModel.subclasses end def table_names models[2..-1].map(&:first) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
arql-0.3.17 | lib/arql/commands/models.rb |