1 # This is a shim around whatever real rbconfig.rb is in the LOAD_PATH,
2 # so that RbConfig::CONFIG["ridir"] can be overridden to point to the
3 # custom location of the ri docs, without the main derivation having
4 # those docs in its closure.
6 MY_PATH = File.realpath(__FILE__)
8 candidates = $LOAD_PATH.map { |dir| File.join(dir, "rbconfig.rb") }
10 # First, drop everything _before_ this file in the LOAD_PATH, just on
11 # the off-chance somebody is composing shims like this for some reason.
12 candidates.drop_while { |c| !File.exist?(c) || File.realpath(c) != MY_PATH }
14 # Now, the wrapped rbconfig.rb is the next rbconfig.rb in the LOAD_PATH
15 # that isn't this same file. (Yes, duplicate LOAD_PATH entries are a
16 # thing we have to deal with.)
17 next_rbconfig = candidates.find { |c|
18 File.exist?(c) && File.realpath(c) != MY_PATH
21 # Load the wrapped rbconfig.rb
24 # Now we have RbConfig, and can modify it for our own ends.
25 RbConfig::CONFIG["ridir"] = File.expand_path("../../../share/ri", __dir__)