module DbSucker::Application::Window::Keypad::Core
Public Instance Methods
_detect_worker(arg, &block)
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 46 def _detect_worker arg, &block sklaventreiber.sync do if arg == "--all" sklaventreiber.workers.each{|w| block.call(w) } else wrk = sklaventreiber.workers.detect do |w| if arg.start_with?("^") w.table.match(/#{arg}/i) elsif arg.start_with?("/") w.table.match(/#{arg[1..-1]}/i) else w.table == arg end end if wrk block.call(wrk) else prompt!("Could not find any worker by the pattern `#{arg}'", color: :red) end end end end
_eval(evil)
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 69 def _eval evil return if evil.blank? app.dump_file "eval-result", true do |f| begin f.puts("#{evil}\n\n") f.puts(app.sync{ app.instance_eval(evil) }) rescue Exception => ex f.puts("#{ex.class}: #{ex.message}") ex.backtrace.each {|l| f.puts(" #{l}") } end end end
app()
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 14 def app @window.app end
enabled?()
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 18 def enabled? app.opts[:window_keypad] end
prompt!(*a, &b)
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 41 def prompt! *a, &b return false unless enabled? @prompt.set!(*a, &b) end
sklaventreiber()
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 10 def sklaventreiber @window.sklaventreiber end
start_loop()
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 22 def start_loop return false unless enabled? @keyloop = app.spawn_thread(:window_keypad_loop) do |thr| loop { begin handle_input(@window.send(:getch)) rescue StandardError => ex app.notify_exception("DbSucker::Window::Keypad encountered an input handle error on tick ##{@window.tick}", ex) end } end end
stop_loop()
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 35 def stop_loop return unless @keyloop sync { @keyloop.kill } @keyloop.join end
sync(&block)
click to toggle source
# File lib/db_sucker/application/window/keypad/core.rb, line 6 def sync &block @monitor.synchronize(&block) end