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 => false,
: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.
171
172
173
|
# File 'lib/byebug/command.rb', line 171
def initialize(state)
@state = state
end
|
Class Method Details
.commands ⇒ Object
59
60
61
|
# File 'lib/byebug/command.rb', line 59
def commands
@commands ||= []
end
|
.inherited(klass) ⇒ Object
72
73
74
75
76
77
|
# File 'lib/byebug/command.rb', line 72
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
79
80
81
82
83
84
|
# File 'lib/byebug/command.rb', line 79
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
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/byebug/command.rb', line 86
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
98
99
100
|
# File 'lib/byebug/command.rb', line 98
def options
@options ||= {}
end
|
.register_setting_get(name, &block) ⇒ Object
146
147
148
149
|
# File 'lib/byebug/command.rb', line 146
def register_setting_get(name, &block)
settings_map[name] ||= {}
settings_map[name][:getter] = block
end
|
.register_setting_set(name, &block) ⇒ Object
151
152
153
154
|
# File 'lib/byebug/command.rb', line 151
def register_setting_set(name, &block)
settings_map[name] ||= {}
settings_map[name][:setter] = block
end
|
.register_setting_var(name, default) ⇒ Object
139
140
141
142
143
144
|
# File 'lib/byebug/command.rb', line 139
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/byebug/command.rb', line 107
def settings
unless 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
102
103
104
|
# File 'lib/byebug/command.rb', line 102
def settings_map
@@settings_map ||= {}
end
|
Instance Method Details
#find(subcmds, param) ⇒ Object
Find param in subcmds.
the subcommands.
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/byebug/command.rb', line 47
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
175
176
177
|
# File 'lib/byebug/command.rb', line 175
def match(input)
@match = regexp.match(input)
end
|
#print_subcmds(subcmds) ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'lib/byebug/command.rb', line 30
def print_subcmds(subcmds)
cmd_name = self.class.name[/Byebug::(.*)Command/, 1].downcase
errmsg "\"#{cmd_name}\" must be followed by the name of a subcommand.\n"
print "List of \"#{cmd_name}\" subcommands:\n"
for subcmd in subcmds do
print "#{cmd_name} #{subcmd.name} -- #{subcmd.short_help}\n"
end
end
|