Created
August 24, 2009 18:05
-
-
Save aphyr/174012 to your computer and use it in GitHub Desktop.
This file contains 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
# From rails/activesupport/lib/active_support/dependencies.rb:333 | |
# Ulysses forgets standard library, complains instead: | |
# http://dev.rubyonrails.org/changeset?new=trunk%2Factivesupport%2Flib%2Factive_support%2Fdependencies.rb%404728&old=trunk%2Factivesupport%2Flib%2Factive_support%2Fdependencies.rb%404681 | |
# Search for a file in load_paths matching the provided suffix. | |
def search_for_file(path_suffix) | |
path_suffix = path_suffix + '.rb' unless path_suffix.ends_with? '.rb' | |
load_paths.each do |root| | |
path = File.join(root, path_suffix) | |
return path if File.file? path | |
end | |
nil # Gee, I sure wish we had first_match ;-) | |
end | |
# Hint: you were looking for Array#find. | |
# http://www.ruby-doc.org/core/classes/Enumerable.html#M003122 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment