summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-26 09:09:49 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-26 09:09:49 +0000
commita3ddead9914b77b105dd0030817a20db75d93af9 (patch)
treeb4d358ad326765ecdabcf0a18dccb5cd44c1b236 /tool
parent4afebfd2c67e35a041b3265ae45346f7994d6faa (diff)
downloadruby-a3ddead9914b77b105dd0030817a20db75d93af9.tar.gz
downloader.rb: Downloader.https
* tool/downloader.rb (Downloader.https): extract a method instead of a global variable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool')
-rw-r--r--tool/downloader.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/tool/downloader.rb b/tool/downloader.rb
index 1bad317ae5..a52225c83e 100644
--- a/tool/downloader.rb
+++ b/tool/downloader.rb
@@ -1,7 +1,10 @@
require 'open-uri'
begin
require 'net/https'
- $rubygems_schema = 'https'
+rescue LoadError
+ https = 'http'
+else
+ https = 'https'
# open-uri of ruby 2.2.0 accept an array of PEMs as ssl_ca_cert, but old
# versions are not. so, patching OpenSSL::X509::Store#add_file instead.
@@ -25,14 +28,19 @@ begin
files.is_a?(Array) ? false : orig_directory?(files)
end
end
-rescue LoadError
- $rubygems_schema = 'http'
end
class Downloader
+ def self.https
+ if @@https != 'https'
+ warn "*** using http instead of https ***"
+ end
+ @@https
+ end
+
class GNU < self
def self.download(name, *rest)
- super("http://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=#{name};hb=master", name, *rest)
+ super("#{https}://gcc.gnu.org/git/?p=gcc.git;a=blob_plain;f=#{name};hb=master", name, *rest)
end
end
@@ -41,11 +49,8 @@ class Downloader
require 'rubygems'
require 'rubygems/package'
options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__)))
- if $rubygems_schema != 'https'
- warn "*** using http instead of https ***"
- end
file = under(dir, name)
- super("#{$rubygems_schema}://rubygems.org/downloads/#{name}", file, nil, ims, options) or
+ super("#{https}://rubygems.org/downloads/#{name}", file, nil, ims, options) or
return false
policy = Gem::Security::LowSecurity
(policy = policy.dup).ui = Gem::SilentUI.new if policy.respond_to?(:'ui=')
@@ -168,6 +173,8 @@ class Downloader
end
end
+Downloader.class_variable_set(:@@https, https.freeze)
+
if $0 == __FILE__
ims = true
until ARGV.empty?