ruby-changes:49275
From: akr <ko1@a...>
Date: Thu, 21 Dec 2017 23:15:11 +0900 (JST)
Subject: [ruby-changes:49275] akr:r61392 (trunk): open-uri defines URI.open defined as an alias.
akr 2017-12-21 23:15:04 +0900 (Thu, 21 Dec 2017) New Revision: 61392 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61392 Log: open-uri defines URI.open defined as an alias. open-uri's Kernel.open will be deprecated in future. Modified files: trunk/NEWS trunk/lib/open-uri.rb trunk/test/open-uri/test_open-uri.rb Index: NEWS =================================================================== --- NEWS (revision 61391) +++ NEWS (revision 61392) @@ -295,6 +295,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L295 * Net::HTTP#{proxy_user,proxy_pass} reflect http_proxy environment variable if the system's environment variable is multiuser safe. [Bug #12921] +* open-uri + * URI.open method defined as an alias to open-uri's Kernel.open. + open-uri's Kernel.open will be deprecated in future. + * OpenSSL * Updated Ruby/OpenSSL from version 2.0 to 2.1. Changes are noted in Index: lib/open-uri.rb =================================================================== --- lib/open-uri.rb (revision 61391) +++ lib/open-uri.rb (revision 61392) @@ -40,6 +40,13 @@ module Kernel https://github.com/ruby/ruby/blob/trunk/lib/open-uri.rb#L40 module_function :open end +module URI #:nodoc: + # alias for Kernel.open defined in open-uri. + def self.open(name, *rest, &block) + Kernel.open(name, *rest, &block) + end +end + # OpenURI is an easy-to-use wrapper for Net::HTTP, Net::HTTPS and Net::FTP. # # == Example Index: test/open-uri/test_open-uri.rb =================================================================== --- test/open-uri/test_open-uri.rb (revision 61391) +++ test/open-uri/test_open-uri.rb (revision 61392) @@ -68,6 +68,16 @@ class TestOpenURI < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/open-uri/test_open-uri.rb#L68 @proxies.each_with_index {|k, i| ENV[k] = @old_proxies[i] } end + def test_200_uri_open + with_http {|srv, dr, url| + srv.mount_proc("/urifoo200", lambda { |req, res| res.body = "urifoo200" } ) + URI.open("#{url}/urifoo200") {|f| + assert_equal("200", f.status[0]) + assert_equal("urifoo200", f.read) + } + } + end + def test_200 with_http {|srv, dr, url| srv.mount_proc("/foo200", lambda { |req, res| res.body = "foo200" } ) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/