module Sprockets::Resolve

def resolve_under_paths(paths, logical_name, accepts)

Returns Array. Filename, type, dependencies, and index_alias

`accepts`.
of the `logical_name` directory that matches a valid mime-type/version from
Finds a file with the same name as `logical_name` or "index" inside

e.g. [["application/javascript", 1.0]]
accepts - Array of array containing mime/version pairs
e.g. "application" or "coffee/foo"
logical_name - String. A filename without extension
paths - Array of Strings.

Internal: Finds a file in a set of given paths
def resolve_under_paths(paths, logical_name, accepts)
  deps = Set.new
  return nil, nil, deps if accepts.empty?
  # TODO: Allow new path resolves to be registered
  @resolvers ||= [
    method(:resolve_main_under_path),
    method(:resolve_alts_under_path),
    method(:resolve_index_under_path)
  ]
  mime_exts = config[:mime_exts]
  paths.each do |load_path|
    candidates = []
    @resolvers.each do |fn|
      result = fn.call(load_path, logical_name, mime_exts)
      candidates.concat(result[0])
      deps.merge(result[1])
    end
    candidate = HTTPUtils.find_best_q_match(accepts, candidates) do |c, matcher|
      match_mime_type?(c[:type] || "application/octet-stream", matcher)
    end
    return candidate[:filename], candidate[:type], deps, candidate[:index_alias] if candidate
  end
  return nil, nil, deps
end