1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Use require_relative to require lib files

1. `require` can mislead Ruby to load system irb's files and cause
   constant redefined warnings as other code loads the same module/class
   from lib folder.
2. Most files already use `require_relative`.

https://github.com/ruby/irb/commit/848d339f2e
This commit is contained in:
st0012 2022-01-16 22:20:05 +00:00 committed by git
parent 804a714971
commit 81b604fb00
4 changed files with 4 additions and 4 deletions

View file

@ -1,7 +1,7 @@
# frozen_string_literal: true
require 'reline'
require 'ripper'
require 'irb/ruby-lex'
require_relative 'ruby-lex'
module IRB # :nodoc:
module Color

View file

@ -1,6 +1,6 @@
# frozen_string_literal: true
require 'pp'
require 'irb/color'
require_relative 'color'
module IRB
class ColorPrinter < ::PP

View file

@ -114,7 +114,7 @@ module IRB # :nodoc:
end
result
}
Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require "irb/color_printer"}){|v|
Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require_relative "color_printer"}){|v|
if IRB.conf[:MAIN_CONTEXT]&.use_colorize?
IRB::ColorPrinter.pp(v, '').chomp
else

View file

@ -6,6 +6,6 @@
# by Keiju ISHITSUKA(keiju@ruby-lang.org)
#
require "irb"
require_relative '../lib/irb'
IRB.start(__FILE__)