[前][次][番号順一覧][スレッド一覧]

ruby-changes:36933

From: usa <ko1@a...>
Date: Fri, 26 Dec 2014 01:26:13 +0900 (JST)
Subject: [ruby-changes:36933] usa:r49014 (trunk): * tool/downloader.rb: support old versions of ruby.

usa	2014-12-26 01:25:57 +0900 (Fri, 26 Dec 2014)

  New Revision: 49014

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49014

  Log:
    * tool/downloader.rb: support old versions of ruby.
    
    * tool/downloader.rb: now can download gems by http if openssl is not
      available (this may be danger!)

  Modified files:
    trunk/ChangeLog
    trunk/tool/downloader.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 49013)
+++ ChangeLog	(revision 49014)
@@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Dec 26 01:24:42 2014  NAKAMURA Usaku  <usa@r...>
+
+	* tool/downloader.rb: support old versions of ruby.
+
+	* tool/downloader.rb: now can download gems by http if openssl is not
+	  available (this may be danger!)
+
 Fri Dec 26 00:13:48 2014  NAKAMURA Usaku  <usa@r...>
 
 	* test/ruby/test_extlibs.rb: check existance of extension libraries
Index: tool/downloader.rb
===================================================================
--- tool/downloader.rb	(revision 49013)
+++ tool/downloader.rb	(revision 49014)
@@ -1,4 +1,33 @@ https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L1
 require 'open-uri'
+begin
+  require 'net/https'
+  $rubygems_schema = '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.
+  class OpenSSL::X509::Store
+    alias orig_add_file add_file
+    def add_file(pems)
+      Array(pems).each do |pem|
+        if File.directory?(pem)
+          add_path pem
+        else
+          orig_add_file pem
+        end
+      end
+    end
+  end
+  # since open-uri internally checks ssl_ca_cert by File.directory?, to allow
+  # accept an array.
+  class <<File
+    alias orig_directory? directory?
+    def File.directory? files
+      files.is_a?(Array) ? false : orig_directory?(files)
+    end
+  end
+rescue LoadError
+  $rubygems_schema = 'http'
+end
 
 class Downloader
   class GNU < self
@@ -10,7 +39,10 @@ class Downloader https://github.com/ruby/ruby/blob/trunk/tool/downloader.rb#L39
   class RubyGems < self
     def self.download(name, dir = nil, ims = true, options = {})
       options[:ssl_ca_cert] = Dir.glob(File.expand_path("../lib/rubygems/ssl_certs/*.pem", File.dirname(__FILE__)))
-      super("https://rubygems.org/downloads/#{name}", name, dir, ims, options)
+      if $rubygems_schema != 'https'
+        warn "*** using http instead of https ***"
+      end
+      super("#{$rubygems_schema}://rubygems.org/downloads/#{name}", name, dir, ims, options)
     end
   end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]