get_path(dependency)
public
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'
get_path 'rake', '< 0.1'
get_path 'rak'
# File lib/rubygems/commands/unpack_command.rb, line 145
def get_path dependency
return dependency.name if dependency.name =~ /\.gem$/
specs = dependency.matching_specs
selected = specs.max_by { |s| s.version }
return Gem::RemoteFetcher.fetcher.download_to_cache(dependency) unless
selected
return unless dependency.name =~ /^#{selected.name}$/
# 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