def get_path dependency
    return dependency.name if dependency.name =~ /\.gem$/i

    specs = dependency.matching_specs

    selected = specs.sort_by { |s| s.version }.last # HACK: hunt last down

    return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
      selected

    return unless dependency.name =~ /^#{selected.name}$/i

    # We expect to find (basename).gem in the 'cache' directory.  Furthermore,
    # the name match must be exact (ignoring case).

    path = find_in_cache File.basename selected.cache_file

    return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless path

    path
  end
#
Return the full path to the cached gem file matching the given
name and version requirement.  Returns 'nil' if no match.

Example:

get_path 'rake', '> 0.4' # "/usr/lib/ruby/gems/1.8/cache/rake-0.4.2.gem"
get_path 'rake', '< 0.1' # nil
get_path 'rak'           # nil (exact name required)
--
TODO: This should be refactored so that it's a general service. I don't
think any of our existing classes are the right place though.  Just maybe
'Cache'?

TODO: It just uses Gem.dir for now.  What's an easy way to get the list of
source directories?