Created
August 11, 2016 13:36
-
-
Save anonymous/b7c38dbcc813e5d88a4c12ba848364a5 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
def require_relative x | |
compiled_path = "#{x}c" | |
if File.exists? compiled_path | |
mtime_compiled = File.mtime(compiled_path) | |
mtime_source = File.mtime(x) | |
if mtime_source > mtime_compiled | |
File.write compiled_path,RubyVM::InstructionSequence.compile_file(x).to_binary | |
end | |
else | |
File.write compiled_path,RubyVM::InstructionSequence.compile_file(x).to_binary | |
end | |
RubyVM::InstructionSequence.load_from_binary(File.read(compiled_path)).eval | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment