sprockets
https://github.com/rails/sprockets
Ruby
Rack-based asset packaging system
Sprockets::PathUtils#find_matching_path_for_extensions
Internal: Match paths in a directory against available extensions.
path - String directory
basename - String basename of target file
extensions - Hash of String extnames to values
Examples
exts = { ".js" => "application/javascript" }
find_matching_path_for_extensions("app/assets", "application", exts)
# => ["app/assets/application.js", "application/javascript"]
Returns an Array of [String path, Object value] matches.Edit
git clone [email protected]:rails/sprockets.git
cd sprockets
open lib/sprockets/path_utils.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Sprockets--PathUtils-find_matching_path_for_extensions-for-pr
# Commit to gitgit add lib/sprockets/path_utils.rbgit commit -m "better docs for Sprockets::PathUtils#find_matching_path_for_extensions"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Sprockets--PathUtils-find_matching_path_for_extensions-for-pr
hub pull-request
# Celebrate!