lib/ruby-debug/command.rb in ruby-debug-ide-0.1.6 vs lib/ruby-debug/command.rb in ruby-debug-ide-0.1.7
- old
+ new
@@ -1,6 +1,9 @@
+require 'ruby-debug/helper'
+
module Debugger
+
class Command # :nodoc:
class << self
def commands
@commands ||= []
end
@@ -15,17 +18,20 @@
def inherited(klass)
DEF_OPTIONS.each do |o, v|
klass.options[o] = v if klass.options[o].nil?
end
commands << klass
- end
-
+ end
+
def load_commands
dir = File.dirname(__FILE__)
Dir[File.join(dir, 'commands', '*')].each do |file|
require file if file =~ /\.rb$/
end
+ Debugger.constants.grep(/Functions$/).map { |name| Debugger.const_get(name) }.each do |mod|
+ include mod
+ end
end
def method_missing(meth, *args, &block)
if meth.to_s =~ /^(.+?)=$/
@options[$1.intern] = args.first
@@ -48,13 +54,13 @@
end
def match(input)
@match = regexp.match(input)
end
-
+
protected
-
+
def method_missing(meth, *args, &block)
if @printer.respond_to? meth
@printer.send meth, *args, &block
else
super
@@ -62,15 +68,11 @@
end
def print(*args)
@state.print(*args)
end
-
- def confirm(msg)
- @state.confirm(msg) == 'y'
- end
-
+
# see Timeout::timeout, the difference is that we must use a DebugThread
# because every other thread would be halted when the event hook is reached
# in ruby-debug.c
def timeout(sec)
return yield if sec == nil or sec.zero?
@@ -97,11 +99,11 @@
rescue StandardError, ScriptError => e
@printer.print_exception(e, @state.binding)
throw :debug_error
end
end
-
+
def debug_silent_eval(str)
begin
eval(str, get_binding)
rescue StandardError, ScriptError
nil
@@ -120,17 +122,17 @@
def get_binding
binding = @state.context.frame_binding(@state.frame_pos)
binding || hbinding(@state.context.frame_locals(@state.frame_pos))
end
-
+
def line_at(file, line)
Debugger.line_at(file, line)
end
-
+
def get_context(thnum)
Debugger.contexts.find{|c| c.thnum == thnum}
- end
+ end
end
Command.load_commands
end