Skip to content

Instantly share code, notes, and snippets.

Created August 11, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b7c38dbcc813e5d88a4c12ba848364a5 to your computer and use it in GitHub Desktop.
Save anonymous/b7c38dbcc813e5d88a4c12ba848364a5 to your computer and use it in GitHub Desktop.
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