diff options
author | Stan Lo <stan001212@gmail.com> | 2023-06-05 20:12:12 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-06-05 19:12:16 +0000 |
commit | 45ff2f4a89f64b20be240b654380e70e31b64619 (patch) | |
tree | 54184b14f42b12adedf531438549bb0a4e9fc062 | |
parent | 273b38475eca91e0a749d2c7a01342157a67633a (diff) |
[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`.
-rw-r--r-- | lib/irb/cmd/nop.rb | 12 | ||||
-rw-r--r-- | lib/irb/ext/loader.rb | 2 |
2 files changed, 6 insertions, 8 deletions
diff --git a/lib/irb/cmd/nop.rb b/lib/irb/cmd/nop.rb index fc6231f0a7..7fb197c51f 100644 --- a/lib/irb/cmd/nop.rb +++ b/lib/irb/cmd/nop.rb @@ -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 diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb index 1ab8a4e322..d65695df3b 100644 --- a/lib/irb/ext/loader.rb +++ b/lib/irb/ext/loader.rb @@ -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 |