diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-24 01:26:21 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-24 01:26:21 +0000 |
commit | 204a83f5f3a3167815a1439e7e6652a7eec934f2 (patch) | |
tree | 323739f619a410c87cc51e017fb390fa3285b845 /tool/downloader.rb | |
parent | 63e8293147fcaf2d107175bd7013dca7d81fbcb9 (diff) |
* tool/downloader.rb: make Downloader class to general download utility.
It can be used without config.guess and configu.sub.
* tool/get-config_files: ditto.
* tool/make-snapshot: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/downloader.rb')
-rw-r--r-- | tool/downloader.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb index 83554fb19d..5d5efe541a 100644 --- a/tool/downloader.rb +++ b/tool/downloader.rb @@ -1,11 +1,11 @@ require 'open-uri' -Downloader = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD" -def Downloader.download(name, dir = nil) - uri = URI(self % name) - data = uri.read - file = dir ? File.join(dir, name) : name - open(file, "wb", 0755) {|f| f.write(data)} -rescue => e - raise "failed to download #{name}\n#{e.message}: #{uri}" +class Downloader + def self.download(url, name, dir = nil) + data = URI(url).read + file = dir ? File.join(dir, name) : name + open(file, "wb", 0755) {|f| f.write(data)} + rescue => e + raise "failed to download #{name}\n#{e.message}: #{uri}" + end end |