From 944a055b05b8b42937f3939e427b42268f91e0f5 Mon Sep 17 00:00:00 2001 From: duerst Date: Sat, 23 Jan 2016 07:30:32 +0000 Subject: * tool/downloader.rb: Fixed a logical error, improved documentation git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- tool/downloader.rb | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'tool') diff --git a/tool/downloader.rb b/tool/downloader.rb index e1d648e29a..e94ecdb3ca 100644 --- a/tool/downloader.rb +++ b/tool/downloader.rb @@ -20,8 +20,8 @@ else end end end - # since open-uri internally checks ssl_ca_cert by File.directory?, to allow - # accept an array. + # since open-uri internally checks ssl_ca_cert using File.directory?, + # allow to accept an array. class < http_error if http_error.message =~ /^304 / # 304 Not Modified if $VERBOSE - $stdout.puts "not modified" + $stdout.puts "#{name} not modified" $stdout.flush end return true end raise rescue Timeout::Error - if ims.nil? and File.exist?(file) + if since.nil? and File.exist?(file) puts "Request for #{url} timed out, using old version." return true end raise rescue SocketError - if ims.nil? and File.exist?(file) + if since.nil? and File.exist?(file) puts "No network connection, unable to download #{url}, using old version." return true end @@ -180,7 +193,7 @@ end Downloader.class_variable_set(:@@https, https.freeze) if $0 == __FILE__ - ims = true + since = true until ARGV.empty? case ARGV[0] when '-d' @@ -192,9 +205,9 @@ if $0 == __FILE__ prefix = ARGV[1] ARGV.shift when '-e' - ims = nil + since = nil when '-a' - ims = true + since = false when /\A-/ abort "#{$0}: unknown option #{ARGV[0]}" else @@ -211,10 +224,10 @@ if $0 == __FILE__ ARGV.shift ARGV.each do |name| name = "#{prefix}/#{File.basename(name)}" if prefix - dl.download(name, destdir, ims) + dl.download(name, destdir, since) end else abort "usage: #{$0} url name" unless ARGV.size == 2 - Downloader.download(ARGV[0], ARGV[1], destdir, ims) + Downloader.download(ARGV[0], ARGV[1], destdir, since) end end -- cgit v1.2.3