diff options
Diffstat (limited to 'lib/irb/ext/loader.rb')
-rw-r--r-- | lib/irb/ext/loader.rb | 35 |
1 files changed, 7 insertions, 28 deletions
diff --git a/lib/irb/ext/loader.rb b/lib/irb/ext/loader.rb index 0a599ee802..df5aaa8e5a 100644 --- a/lib/irb/ext/loader.rb +++ b/lib/irb/ext/loader.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true # # loader.rb - # by Keiju ISHITSUKA(keiju@ruby-lang.org) @@ -24,31 +24,8 @@ module IRB # :nodoc: load_file(path, priv) end - if File.respond_to?(:absolute_path?) - def absolute_path?(path) - File.absolute_path?(path) - end - else - separator = - if File::ALT_SEPARATOR - "[#{Regexp.quote(File::SEPARATOR + File::ALT_SEPARATOR)}]" - else - File::SEPARATOR - end - ABSOLUTE_PATH_PATTERN = # :nodoc: - case Dir.pwd - when /\A\w:/, /\A#{separator}{2}/ - /\A(?:\w:|#{separator})#{separator}/ - else - /\A#{separator}/ - end - def absolute_path?(path) - ABSOLUTE_PATH_PATTERN =~ path - end - end - def search_file_from_ruby_path(fn) # :nodoc: - if absolute_path?(fn) + if File.absolute_path?(fn) return fn if File.exist?(fn) return nil end @@ -65,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 @@ -89,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 @@ -119,13 +98,13 @@ module IRB # :nodoc: def old # :nodoc: back_io = @io - back_path = @irb_path + back_path = irb_path back_name = @irb_name back_scanner = @irb.scanner begin @io = FileInputMethod.new(path) @irb_name = File.basename(path) - @irb_path = path + self.irb_path = path @irb.signal_status(:IN_LOAD) do if back_io.kind_of?(FileInputMethod) @irb.eval_input @@ -140,7 +119,7 @@ module IRB # :nodoc: ensure @io = back_io @irb_name = back_name - @irb_path = back_path + self.irb_path = back_path @irb.scanner = back_scanner end end |