diff options
author | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
---|---|---|
committer | ryan <ryan@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-03-01 09:41:32 +0000 |
commit | 25a9b62d45ddd60a231272567c7dda9337da9b62 (patch) | |
tree | e72ba4c9c01cba5fb510eb1eafaba76d998baf4c /lib/rubygems/remote_fetcher.rb | |
parent | 86bb0af7ea3b50f72e6845a6f5f64cb1b23fd279 (diff) | |
download | ruby-25a9b62d45ddd60a231272567c7dda9337da9b62.tar.gz |
Import rubygems 1.6.0 (released version @ 58d8a0b9)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rubygems/remote_fetcher.rb')
-rw-r--r-- | lib/rubygems/remote_fetcher.rb | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/lib/rubygems/remote_fetcher.rb b/lib/rubygems/remote_fetcher.rb index aa63392848..520adb5827 100644 --- a/lib/rubygems/remote_fetcher.rb +++ b/lib/rubygems/remote_fetcher.rb @@ -78,6 +78,23 @@ class Gem::RemoteFetcher end ## + # Given a name and requirement, downloads this gem into cache and returns the + # filename. Returns nil if the gem cannot be located. + #-- + # Should probably be integrated with #download below, but that will be a + # larger, more emcompassing effort. -erikh + + def download_to_cache dependency + found = Gem::SpecFetcher.fetcher.fetch dependency + + return if found.empty? + + spec, source_uri = found.first + + download spec, source_uri + end + + ## # Moves the gem +spec+ from +source_uri+ to the cache dir unless it is # already there. If the source_uri is local the gem cache dir copy is # always replaced. @@ -86,9 +103,9 @@ class Gem::RemoteFetcher Gem.ensure_gem_subdirectories(install_dir) rescue nil if File.writable?(install_dir) - cache_dir = File.join install_dir, 'cache' + cache_dir = Gem.cache_dir(install_dir) else - cache_dir = File.join(Gem.user_dir, 'cache') + cache_dir = Gem.cache_dir(Gem.user_dir) end gem_file_name = spec.file_name @@ -140,7 +157,7 @@ class Gem::RemoteFetcher path = source_uri.path path = File.dirname(path) if File.extname(path) == '.gem' - remote_gem_path = File.join(path, 'gems', gem_file_name) + remote_gem_path = correct_for_windows_path(File.join(path, 'gems', gem_file_name)) FileUtils.cp(remote_gem_path, local_gem_path) rescue Errno::EACCES @@ -276,6 +293,14 @@ class Gem::RemoteFetcher raise FetchError.new(e.message, uri) end + def correct_for_windows_path(path) + if path[0].chr == '/' && path[1].chr =~ /[a-z]/i && path[2].chr == ':' + path = path[1..-1] + else + path + end + end + ## # Read the data from the (source based) URI, but if it is a file:// URI, # read from the filesystem instead. @@ -293,13 +318,7 @@ class Gem::RemoteFetcher end if uri.scheme == 'file' - path = uri.path - - # Deal with leading slash on Windows paths - if path[0].chr == '/' && path[1].chr =~ /[a-zA-Z]/ && path[2].chr == ':' - path = path[1..-1] - end - + path = correct_for_windows_path(uri.path) return Gem.read_binary(path) end |