Created
November 10, 2011 20:21
-
-
Save luislavena/1356075 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name = "readline" # (the one you used in your require) | |
| extensions = %w(rb so dll) | |
| extensions.each do |ext| | |
| expanded_path = $LOAD_PATH.map { |p| File.expand_path(p) } | |
| result = catch(:found) do | |
| expanded_path.each do |p| | |
| f = "#{name}.#{ext}" | |
| if File.exist? File.expand_path f, p | |
| throw :found, [f, p] | |
| # found, use this | |
| end | |
| end | |
| nil | |
| end | |
| if result then | |
| # The found file is then obtained a realpath (symlinks resolved) | |
| # before adding to $LOADED_FEATURES | |
| real = File.realpath(result[0], result[1]) | |
| puts "found: #{real}" | |
| break | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment