module IRB::ExtendCommandBundle
Installs the default irb extensions command bundle.
Constants
- NO_OVERRIDE
See install_alias_method.
- OVERRIDE_ALL
See install_alias_method.
- OVERRIDE_PRIVATE_ONLY
See install_alias_method.
Public Class Methods
all_commands_info()
click to toggle source
# File lib/irb/default_commands.rb, line 185 def self.all_commands_info user_aliases = IRB.CurrentContext.command_aliases.each_with_object({}) do |(alias_name, target), result| result[target] ||= [] result[target] << alias_name end Command.commands.map do |command_name, (command_class, aliases)| aliases = aliases.map { |a| a.first } if additional_aliases = user_aliases[command_name] aliases += additional_aliases end display_name = aliases.shift || command_name { display_name: display_name, description: command_class.description, category: command_class.category } end end
command_names()
click to toggle source
# File lib/irb/default_commands.rb, line 224 def self.command_names command_override_policies.keys.map(&:to_s) end
command_override_policies()
click to toggle source
# File lib/irb/default_commands.rb, line 207 def self.command_override_policies @@command_override_policies ||= Command.commands.flat_map do |cmd_name, (cmd_class, aliases)| [[cmd_name, OVERRIDE_ALL]] + aliases end.to_h end
def_extend_command(cmd_name, cmd_class, _, *aliases)
click to toggle source
Drepcated. Use Command.regiser instead.
# File lib/irb/default_commands.rb, line 243 def self.def_extend_command(cmd_name, cmd_class, _, *aliases) Command._register_with_aliases(cmd_name, cmd_class, *aliases) @@command_override_policies = nil end
execute_as_command?(name, public_method:, private_method:)
click to toggle source
# File lib/irb/default_commands.rb, line 213 def self.execute_as_command?(name, public_method:, private_method:) case command_override_policies[name] when OVERRIDE_ALL true when OVERRIDE_PRIVATE_ONLY !public_method when NO_OVERRIDE !public_method && !private_method end end
load_command(command)
click to toggle source
Convert a command name to its implementation class if such command exists
# File lib/irb/default_commands.rb, line 229 def self.load_command(command) command = command.to_sym Command.commands.each do |command_name, (command_class, aliases)| if command_name == command || aliases.any? { |alias_name, _| alias_name == command } return command_class end end nil end
Public Instance Methods
irb_load(*opts, &b)
click to toggle source
Loads the given file similarly to Kernel#load
, see IrbLoader#irb_load
# File lib/irb/ext/use-loader.rb, line 19 def irb_load(*opts, &b) Command::Load.execute(irb_context, *opts, &b) end
irb_require(*opts, &b)
click to toggle source
Loads the given file similarly to Kernel#require
# File lib/irb/ext/use-loader.rb, line 24 def irb_require(*opts, &b) Command::Require.execute(irb_context, *opts, &b) end