зеркало из https://github.com/github/ruby.git
[ruby/irb] Refactor ExtendCommand::Nop
(https://github.com/ruby/irb/pull/598) * Rename conf to irb_context * Drop Nop#irb method because it's only used by irb/ext/loader.rb We don't need to expose this method to all command classes, especially when it's just an alias of `irb_context.irb`.
This commit is contained in:
Родитель
273b38475e
Коммит
45ff2f4a89
|
@ -30,23 +30,19 @@ module IRB
|
|||
end
|
||||
end
|
||||
|
||||
def self.execute(conf, *opts, **kwargs, &block)
|
||||
command = new(conf)
|
||||
def self.execute(irb_context, *opts, **kwargs, &block)
|
||||
command = new(irb_context)
|
||||
command.execute(*opts, **kwargs, &block)
|
||||
rescue CommandArgumentError => e
|
||||
puts e.message
|
||||
end
|
||||
|
||||
def initialize(conf)
|
||||
@irb_context = conf
|
||||
def initialize(irb_context)
|
||||
@irb_context = irb_context
|
||||
end
|
||||
|
||||
attr_reader :irb_context
|
||||
|
||||
def irb
|
||||
@irb_context.irb
|
||||
end
|
||||
|
||||
def execute(*opts)
|
||||
#nop
|
||||
end
|
||||
|
|
|
@ -42,6 +42,7 @@ module IRB # :nodoc:
|
|||
#
|
||||
# See Irb#suspend_input_method for more information.
|
||||
def source_file(path)
|
||||
irb = irb_context.irb
|
||||
irb.suspend_name(path, File.basename(path)) do
|
||||
FileInputMethod.open(path) do |io|
|
||||
irb.suspend_input_method(io) do
|
||||
|
@ -66,6 +67,7 @@ module IRB # :nodoc:
|
|||
#
|
||||
# See Irb#suspend_input_method for more information.
|
||||
def load_file(path, priv = nil)
|
||||
irb = irb_context.irb
|
||||
irb.suspend_name(path, File.basename(path)) do
|
||||
|
||||
if priv
|
||||
|
|
Загрузка…
Ссылка в новой задаче