Sha256: 4a8324cb2bfc0755c400b4b0000536fb60d9c0242e3b34a80f73d8a5cf371e2d
Contents?: true
Size: 1004 Bytes
Versions: 4
Compression:
Stored size: 1004 Bytes
Contents
require 'terminal-table' module PryHelper::Commands module Models class << self def models t = [] t << ['Table Name', 'Model Class', 'Abbr', 'Comment'] t << nil PryHelper::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 PryHelper::Commands::Models::models end def tables models end end
Version data entries
4 entries across 4 versions & 1 rubygems