本帖最后由 taroxd 于 2015-3-7 21:06 编辑
喵呜喵5 发表于 2015-2-28 19:50
顺便
把下面的代码放到脚本编辑器里试试看(但是别把 Scripts.rvdata2 提交到 git 里面)
module Kernel def require(filename) $LOAD_PATH.each do |path| fn = File.absolute_path("#{path}/#{filename}") fn << '.rb' unless fn.end_with?('.rb') return false if $LOADED_FEATURES.include?(fn) if File.exist?(fn) eval File.read(fn), TOPLEVEL_BINDING, fn $LOADED_FEATURES.push(fn) return true end end raise LoadError, "cannot load such file -- #{filename}" end module_function :require end
module Kernel
def require(filename)
$LOAD_PATH.each do |path|
fn = File.absolute_path("#{path}/#{filename}")
fn << '.rb' unless fn.end_with?('.rb')
return false if $LOADED_FEATURES.include?(fn)
if File.exist?(fn)
eval File.read(fn), TOPLEVEL_BINDING, fn
$LOADED_FEATURES.push(fn)
return true
end
end
raise LoadError, "cannot load such file -- #{filename}"
end
module_function :require
end
|