diff options
author | Stan Lo <stan001212@gmail.com> | 2023-04-27 16:42:16 +0100 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-04-27 15:42:21 +0000 |
commit | 5cd4f35da634a33d993017bc0a9d82685201e8d4 (patch) | |
tree | 9b4db70df9921b51120390759b8ffb495200658e | |
parent | fef8cca822f6b69fe21cbab181ce5b5e0babff91 (diff) | |
download | ruby-5cd4f35da634a33d993017bc0a9d82685201e8d4.tar.gz |
[ruby/irb] Simplify Locale#load
(https://github.com/ruby/irb/pull/571)
* Simplify Locale#load
Instead of loading file content with `MagicFile` and then evaluting it,
we can just use `Kernel.load` to load the file.
* Remove unused optional argument
* Remove unused Locale#require and #toplevel_load
-rw-r--r-- | lib/irb/locale.rb | 41 |
1 files changed, 2 insertions, 39 deletions
diff --git a/lib/irb/locale.rb b/lib/irb/locale.rb index 7615a4e8d8..f94aa0f40b 100644 --- a/lib/irb/locale.rb +++ b/lib/irb/locale.rb @@ -82,39 +82,12 @@ module IRB # :nodoc: super(*ary) end - def require(file, priv = nil) - rex = Regexp.new("lc/#{Regexp.quote(file)}\.(so|o|sl|rb)?") - return false if $".find{|f| f =~ rex} - - case file - when /\.rb$/ - begin - load(file, priv) - $".push file - return true - rescue LoadError - end - when /\.(so|o|sl)$/ - return super - end - - begin - load(f = file + ".rb") - $".push f #" - return true - rescue LoadError - return ruby_require(file) - end - end - - alias toplevel_load load - - def load(file, priv=nil) + def load(file) found = find(file) if found unless @@loaded.include?(found) @@loaded << found # cache - return real_load(found, priv) + Kernel.load(found) end else raise LoadError, "No such file to load -- #{file}" @@ -133,16 +106,6 @@ module IRB # :nodoc: end end - private - def real_load(path, priv) - src = MagicFile.open(path){|f| f.read} - if priv - eval("self", TOPLEVEL_BINDING).extend(Module.new {eval(src, nil, path)}) - else - eval(src, TOPLEVEL_BINDING, path) - end - end - # @param paths load paths in which IRB find a localized file. # @param dir directory # @param file basename to be localized |