class Gm::Notepad::InputHandlers::QueryTableNamesHandler

Constants

QUERY_TABLE_NAMES_PREFIX
WITH_GREP_REGEXP

Public Class Methods

handles?(input:) click to toggle source
# File lib/gm/notepad/input_handlers/query_table_names_handler.rb, line 8
def self.handles?(input:)
  # Does not have the table prefix
  return false unless input.match(/^\+/)
  # It is only the table prefix
  return true if input.match(/^\+$/)
  # It is querying all tables by way of grep
  return true if input.match(/^\+\//)
  false
end

Public Instance Methods

after_initialize!() click to toggle source
# File lib/gm/notepad/input_handlers/query_table_names_handler.rb, line 19
def after_initialize!
  grep = nil
  input.sub!(/^./,'')
  if match = input.match(WITH_GREP_REGEXP)
    input.sub!(match[:declaration], '')
    grep = match[:grep]
  end

  table_names = table_registry.table_names
  table_names = table_names.grep(%r{#{grep}}) if grep
  table_names.each do |table_name|
    input.render_current_text(text: table_name, to_interactive: true, to_output: false, expand_line: false)
  end
end