-
-
Save havenwood/930fa089aaeb0cb2277eb90aef60e431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Kernel | |
def require_relative_cthu path | |
absolute_path = File.absolute_path path, __dir__ | |
realpath = File.realpath "#{absolute_path.chomp '.rb'}.rb" | |
return false if $LOADED_FEATURES.include? realpath | |
RubyVM::InstructionSequence.compile_file(realpath).eval | |
$LOADED_FEATURES << realpath | |
true | |
rescue Errno::ENOTDIR, Errno::ENOENT | |
raise LoadError, "cannot load such file -- #{absolute_path}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment