Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $LOADED_SCRIPTS = {}
- def absrequire(file)
- found_candidate = false
- files = ["#{file.sub(/\.rb$/, '')}.rb", file].uniq
- $:.each do |load_path|
- files.each do |f|
- path = File.expand_path(File.join('.', load_path, f))
- if File.exists?(path)
- if $LOADED_SCRIPTS.has_key?(path)
- found_candidate = true
- break
- end
- $LOADED_SCRIPTS[path] = file
- return load(path)
- end
- end
- end
- return false if found_candidate
- raise LoadError, "no such file to load -- #{file}"
- end
Add Comment
Please, Sign In to add comment