Guest User

Untitled

a guest
Jan 21st, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. # あらゆる require より後に定義する
  2. # これより前に定義されたあらゆるrequireが失敗した場合、パスの名前をwinに変えてリトライする
  3.  
  4. module Kernel
  5.  
  6. alias win_path_original_require require
  7. def require path
  8. win_path_original_require path
  9. rescue LoadError => e
  10. win_path_original_require to_win_path path
  11. end
  12.  
  13. def to_win_path path
  14. win_path = path
  15. if path =~ /^\/(.*?)$/
  16. win_path = "C:\\#{$1}"
  17. elsif path =~ /^\.\/(.*?)$/
  18. win_path = "#{$1}"
  19. end
  20. win_path.gsub('/', "\\")
  21. end
  22. end
Add Comment
Please, Sign In to add comment