Class: Byebug::Command
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Includes:
- Columnize
- Defined in:
- lib/byebug/command.rb
Direct Known Subclasses
AddBreakpoint, AddDisplayCommand, CatchCommand, ConditionCommand, ContinueCommand, DeleteBreakpointCommand, DeleteDisplayCommand, DisableCommand, DisplayCommand, DownCommand, Edit, EnableCommand, EvalCommand, FinishCommand, FrameCommand, HelpCommand, IRBCommand, InfoCommand, InterruptCommand, JumpCommand, KillCommand, ListCommand, MethodCommand, MethodSigCommand, NextCommand, PPCommand, PSCommand, PutLCommand, QuitCommand, ReloadCommand, RestartCommand, SaveCommand, SetCommand, ShowCommand, SkipCommand, SourceCommand, StepCommand, TextMateCommand, ThreadCurrentCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, TraceCommand, UpCommand, VarClassVarCommand, VarConstantCommand, VarGlobalCommand, VarInheritCommand, VarInstanceCommand, VarLocalCommand, WhereCommand
Defined Under Namespace
Classes: SubcmdStruct
Constant Summary
collapse
- DEF_OPTIONS =
{
:allow_in_control => false,
:allow_in_post_mortem => true ,
:event => true ,
:always_run => 0 ,
:unknown => false,
:need_context => false,
}
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(state) ⇒ Command
Returns a new instance of Command.
149
150
151
|
# File 'lib/byebug/command.rb', line 149
def initialize(state)
@state = state
end
|
Class Method Details
.commands ⇒ Object
32
33
34
|
# File 'lib/byebug/command.rb', line 32
def commands
@commands ||= []
end
|
.inherited(klass) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/byebug/command.rb', line 45
def inherited(klass)
DEF_OPTIONS.each do |o, v|
klass.options[o] = v if klass.options[o].nil?
end
commands << klass
end
|
.load_commands ⇒ Object
52
53
54
55
56
57
|
# File 'lib/byebug/command.rb', line 52
def load_commands
Dir[File.join(Byebug.const_get(:BYEBUG_DIR), 'commands', '*')].each {
|file| require file if file =~ /\.rb$/ }
Byebug.constants.grep(/Functions$/).map {
|name| Byebug.const_get(name) }.each { |mod| include mod }
end
|
.method_missing(meth, *args, &block) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/byebug/command.rb', line 59
def method_missing(meth, *args, &block)
if meth.to_s =~ /^(.+?)=$/
@options[$1.intern] = args.first
else
if @options.has_key?(meth)
@options[meth]
else
super
end
end
end
|
.options ⇒ Object
71
72
73
|
# File 'lib/byebug/command.rb', line 71
def options
@options ||= {}
end
|
.register_setting_get(name, &block) ⇒ Object
119
120
121
122
|
# File 'lib/byebug/command.rb', line 119
def register_setting_get(name, &block)
settings_map[name] ||= {}
settings_map[name][:getter] = block
end
|
.register_setting_set(name, &block) ⇒ Object
124
125
126
127
|
# File 'lib/byebug/command.rb', line 124
def register_setting_set(name, &block)
settings_map[name] ||= {}
settings_map[name][:setter] = block
end
|
.register_setting_var(name, default) ⇒ Object
112
113
114
115
116
117
|
# File 'lib/byebug/command.rb', line 112
def register_setting_var(name, default)
var_name = "@@#{name}"
class_variable_set(var_name, default)
register_setting_get(name) { class_variable_get(var_name) }
register_setting_set(name) { |value| class_variable_set(var_name, value) }
end
|
.settings ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/byebug/command.rb', line 80
def settings
unless true and defined? @settings and @settings
@settings = Object.new
map = settings_map
c = class << @settings; self end
if c.respond_to?(:funcall)
c.funcall(:define_method, :[]) do |name|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:getter].call
end
else
c.send(:define_method, :[]) do |name|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:getter].call
end
end
c = class << @settings; self end
if c.respond_to?(:funcall)
c.funcall(:define_method, :[]=) do |name, value|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:setter].call(value)
end
else
c.send(:define_method, :[]=) do |name, value|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:setter].call(value)
end
end
end
@settings
end
|
.settings_map ⇒ Object
75
76
77
|
# File 'lib/byebug/command.rb', line 75
def settings_map
@@settings_map ||= {}
end
|
Instance Method Details
#find(subcmds, param) ⇒ Object
Find param in subcmds. param id downcased and can be abbreviated to the minimum length listed in the subcommands
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/byebug/command.rb', line 20
def find(subcmds, param)
param.downcase!
for try_subcmd in subcmds do
if (param.size >= try_subcmd.min) and
(try_subcmd.name[0..param.size-1] == param)
return try_subcmd
end
end
return nil
end
|
#match(input) ⇒ Object
153
154
155
|
# File 'lib/byebug/command.rb', line 153
def match(input)
@match = regexp.match(input)
end
|