summaryrefslogtreecommitdiff
path: root/tool/downloader.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-28 11:27:22 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-09-28 11:27:22 +0000
commit1c01280d17f700de26440fa9431a9ce58d6353e5 (patch)
tree129d01a67180df3f3c150cad3570538791c21f34 /tool/downloader.rb
parent3bbea8ed37278c9cc584bb25624eee05efebb117 (diff)
downloader.rb
* configure.in: use tool/downloader.rb directly. * tool/get-config_files: no longer used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/downloader.rb')
-rw-r--r--tool/downloader.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index e909c10..b1c1449 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -53,6 +53,7 @@ class Downloader
# download :unicode, 'UnicodeData.txt', 'enc/unicode/data'
def self.download(url, name, dir = nil, ims = true)
file = dir ? File.join(dir, name) : name
+ return true if ims.nil? and File.exist?(file)
url = URI(url)
if $VERBOSE
$stdout.print "downloading #{name} ... "
@@ -89,3 +90,35 @@ class Downloader
raise e.class, "failed to download #{name}\n#{e.message}: #{url}", e.backtrace
end
end
+
+if $0 == __FILE__
+ ims = true
+ until ARGV.empty?
+ case ARGV[0]
+ when '-d'
+ destdir = ARGV[1]
+ ARGV.shift(2)
+ when '-e'
+ ims = nil
+ ARGV.shift
+ when /\A-/
+ abort "#{$0}: unknown option #{ARGV[0]}"
+ else
+ break
+ end
+ end
+ dl = Downloader.constants.find do |name|
+ ARGV[0].casecmp(name.to_s) == 0
+ end
+ $VERBOSE = true
+ if dl
+ dl = Downloader.const_get(dl)
+ ARGV.shift
+ ARGV.each do |name|
+ dl.download(name, destdir, ims)
+ end
+ else
+ abort "usage: #{$0} url name" unless ARGV.size == 2
+ Downloader.download(*ARGV, destdir, ims)
+ end
+end