Sha256: ff4e397c436c10f2b070c12dbc12effbd0566ae72ca3b4c6ffa73b75a5db0fad
Contents?: true
Size: 1.26 KB
Versions: 7
Compression:
Stored size: 1.26 KB
Contents
require_relative "../syntax_search" # Monkey patch kernel to ensure that all `require` calls call the same # method module Kernel alias_method :original_require, :require alias_method :original_require_relative, :require_relative alias_method :original_load, :load def load(file, wrap = false) original_load(file) rescue SyntaxError => e SyntaxErrorSearch.handle_error(e) end def require(file) original_require(file) rescue SyntaxError => e SyntaxErrorSearch.handle_error(e) end def require_relative(file) if Pathname.new(file).absolute? original_require file else original_require File.expand_path("../#{file}", caller_locations(1, 1)[0].absolute_path) end rescue SyntaxError => e SyntaxErrorSearch.handle_error(e) end end # I honestly have no idea why this Object delegation is needed # I keep staring at bootsnap and it doesn't have to do this # is there a bug in their implementation they haven't caught or # am I doing something different? class Object private def load(path, wrap = false) Kernel.load(path, wrap) rescue SyntaxError => e SyntaxErrorSearch.handle_error(e) end def require(path) Kernel.require(path) rescue SyntaxError => e SyntaxErrorSearch.handle_error(e) end end
Version data entries
7 entries across 7 versions & 1 rubygems