Guest User

Untitled

a guest
Mar 6th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. $LOADED_SCRIPTS = {}
  2.  
  3. def absrequire(file)
  4. found_candidate = false
  5. files = ["#{file.sub(/\.rb$/, '')}.rb", file].uniq
  6.  
  7. $:.each do |load_path|
  8. files.each do |f|
  9. path = File.expand_path(File.join('.', load_path, f))
  10.  
  11. if File.exists?(path)
  12. if $LOADED_SCRIPTS.has_key?(path)
  13. found_candidate = true
  14. break
  15. end
  16. $LOADED_SCRIPTS[path] = file
  17. return load(path)
  18. end
  19. end
  20. end
  21. return false if found_candidate
  22. raise LoadError, "no such file to load -- #{file}"
  23. end
Add Comment
Please, Sign In to add comment