Sha256: 5bbd93251f05c916b9623702309a6dcf494d3439f2262e04fd3ff185e9b97783
Contents?: true
Size: 874 Bytes
Versions: 1
Compression:
Stored size: 874 Bytes
Contents
unless Kernel.respond_to?(:require_relative, true) module Kernel module_function OriginalDir = File.expand_path(Dir.pwd) # try to accomodate for later Directory changes... def require_relative(relative_feature) c = caller.first # could be spec.sane.rb:127 # or e:/abc.rb:127 e = c.rindex(/:\d+/) file = $` if /\A\((.*)\)/ =~ file # eval, etc. raise LoadError, "require_relative is called in #{$1}" end p 'relative is', relative_feature, File.dirname(file), OriginalDir absolute_feature = File.expand_path(File.join(File.dirname(file), relative_feature)) begin require absolute_feature rescue LoadError => e # hacky kludge in case they've changed dirs... require File.expand_path(File.join(OriginalDir,File.dirname(file), relative_feature)) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sane-0.23.2 | lib/sane/require_relative.rb |