ruby-changes:61078
From: David <ko1@a...>
Date: Fri, 8 May 2020 07:39:44 +0900 (JST)
Subject: [ruby-changes:61078] 427eb2b93f (master): [rubygems/rubygems] Remove unnecessary DIR constant
https://git.ruby-lang.org/ruby.git/commit/?id=427eb2b93f From 427eb2b93ff10860668bb3864746aa8720a494e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...> Date: Fri, 10 Apr 2020 22:09:41 +0200 Subject: [rubygems/rubygems] Remove unnecessary DIR constant We have `__dir__` which is the same thing. https://github.com/rubygems/rubygems/commit/f89776427f diff --git a/test/rubygems/test_gem_remote_fetcher.rb b/test/rubygems/test_gem_remote_fetcher.rb index 0e12007..c72bffb 100644 --- a/test/rubygems/test_gem_remote_fetcher.rb +++ b/test/rubygems/test_gem_remote_fetcher.rb @@ -78,8 +78,6 @@ gems: https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L78 PROXY_DATA = SERVER_DATA.gsub(/0.4.11/, '0.4.2') - DIR = File.expand_path(File.dirname(__FILE__)) - # Generated via: # x = OpenSSL::PKey::DH.new(2048) # wait a while... # x.to_s => pem @@ -890,7 +888,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L888 def test_ssl_connection ssl_server = start_ssl_server - temp_ca_cert = File.join(DIR, 'ca_cert.pem') + temp_ca_cert = File.join(__dir__, 'ca_cert.pem') with_configured_fetcher(":ssl_ca_cert: #{temp_ca_cert}") do |fetcher| fetcher.fetch_path("https://localhost:#{ssl_server.config[:Port]}/yaml") end @@ -901,8 +899,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L899 :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT}) - temp_ca_cert = File.join(DIR, 'ca_cert.pem') - temp_client_cert = File.join(DIR, 'client.pem') + temp_ca_cert = File.join(__dir__, 'ca_cert.pem') + temp_client_cert = File.join(__dir__, 'client.pem') with_configured_fetcher( ":ssl_ca_cert: #{temp_ca_cert}\n" + @@ -916,8 +914,8 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L914 :SSLVerifyClient => OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT}) - temp_ca_cert = File.join(DIR, 'ca_cert.pem') - temp_client_cert = File.join(DIR, 'invalid_client.pem') + temp_ca_cert = File.join(__dir__, 'ca_cert.pem') + temp_client_cert = File.join(__dir__, 'invalid_client.pem') with_configured_fetcher( ":ssl_ca_cert: #{temp_ca_cert}\n" + @@ -946,7 +944,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L944 def test_do_not_follow_insecure_redirect ssl_server = start_ssl_server - temp_ca_cert = File.join(DIR, 'ca_cert.pem') + temp_ca_cert = File.join(__dir__, 'ca_cert.pem') expected_error_message = "redirecting to non-https resource: #{@server_uri} (https://localhost:#{ssl_server.config[:Port]}/insecure_redirect?to=#{@server_uri})" @@ -1055,8 +1053,6 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L1053 @proxy_server[:server].config[:Port] end - DIR = File.expand_path(File.dirname(__FILE__)) - def start_ssl_server(config = {}) null_logger = NilLog.new server = WEBrick::HTTPServer.new({ @@ -1064,7 +1060,7 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L1060 :Logger => null_logger, :AccessLog => [], :SSLEnable => true, - :SSLCACertificateFile => File.join(DIR, 'ca_cert.pem'), + :SSLCACertificateFile => File.join(__dir__, 'ca_cert.pem'), :SSLCertificate => cert('ssl_cert.pem'), :SSLPrivateKey => key('ssl_key.pem'), :SSLVerifyClient => nil, @@ -1145,11 +1141,11 @@ PeIQQkFng2VVot/WAQbv3ePqWq07g1BBcwIBAg== https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_remote_fetcher.rb#L1141 end def cert(filename) - OpenSSL::X509::Certificate.new(File.read(File.join(DIR, filename))) + OpenSSL::X509::Certificate.new(File.read(File.join(__dir__, filename))) end def key(filename) - OpenSSL::PKey::RSA.new(File.read(File.join(DIR, filename))) + OpenSSL::PKey::RSA.new(File.read(File.join(__dir__, filename))) end end if defined?(OpenSSL::SSL) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/