From 1f3d3df02a0ff764e9a8a80c8d9e2c1e2d11bdce Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 Nov 2024 15:05:58 +0900 Subject: [PATCH 1/2] Added more fallback constants like URI::PARTTERN and URI::REGEXP Fixed https://github.com/ruby/uri/issues/125 --- lib/uri/common.rb | 8 +++++++- test/uri/test_common.rb | 6 +++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/uri/common.rb b/lib/uri/common.rb index cf93fb1..fe8475f 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -46,9 +46,15 @@ def self.parser=(parser = RFC3986_PARSER) self.parser = RFC3986_PARSER def self.const_missing(const) - if value = RFC2396_PARSER.regexp[const] + if const == :REGEXP + warn "URI::REGEXP is obsolete. Use URI::RFC2396_REGEXP explicitly.", uplevel: 1 if $VERBOSE + URI::RFC2396_REGEXP + elsif value = RFC2396_PARSER.regexp[const] warn "URI::#{const} is obsolete. Use RFC2396_PARSER.regexp[#{const.inspect}] explicitly.", uplevel: 1 if $VERBOSE value + elsif value = RFC2396_Parser.const_get(const) + warn "URI::#{const} is obsolete. Use RFC2396_Parser::#{const} explicitly.", uplevel: 1 if $VERBOSE + value else super end diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index bccdeaf..176efb8 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -13,8 +13,12 @@ def teardown def test_fallback_constants orig_verbose = $VERBOSE $VERBOSE = nil - assert URI::ABS_URI + assert_raise(NameError) { URI::FOO } + + assert_equal URI::ABS_URI, URI::RFC2396_PARSER.regexp[:ABS_URI] + assert_equal URI::PATTERN, URI::RFC2396_Parser::PATTERN + assert_equal URI::REGEXP, URI::RFC2396_REGEXP ensure $VERBOSE = orig_verbose end From 3011eb6f6e53c7870f91404d4a789cb854c893ad Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 8 Nov 2024 15:07:36 +0900 Subject: [PATCH 2/2] Bump up v1.0.1 --- lib/uri/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/uri/version.rb b/lib/uri/version.rb index c68c43a..e74ddec 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '010000'.freeze + VERSION_CODE = '010001'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end