1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/tool/config_files.rb
naruse 86034eafb2 fix the example of failed URI
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-01 10:55:10 +00:00

11 lines
359 B
Ruby

require 'open-uri'
ConfigFiles = "http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=%s;hb=HEAD"
def ConfigFiles.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}"
end