diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index f0e6b5d..1d70fe5 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -30,7 +30,7 @@ jobs: uses: actions/configure-pages@v5 - name: Build with RDoc # Outputs to the './_site' directory by default - run: bundle exec rake rdoc + run: rake rdoc - name: Upload artifact uses: actions/upload-pages-artifact@v3 diff --git a/Rakefile b/Rakefile index 19de93e..3935fdf 100644 --- a/Rakefile +++ b/Rakefile @@ -11,7 +11,7 @@ require "rdoc/task" RDoc::Task.new do |doc| doc.main = "README.md" doc.title = "URI - handle Uniform Resource Identifiers" - doc.rdoc_files = FileList.new %w[lib README.md LICENSE.txt] + doc.rdoc_files = FileList.new %w[lib README.md BSDL COPYING] doc.rdoc_dir = "_site" # for github pages end diff --git a/lib/uri/common.rb b/lib/uri/common.rb index fe8475f..c3fe0b4 100644 --- a/lib/uri/common.rb +++ b/lib/uri/common.rb @@ -31,15 +31,10 @@ def self.parser=(parser = RFC3986_PARSER) if Parser == RFC2396_Parser const_set("REGEXP", URI::RFC2396_REGEXP) const_set("PATTERN", URI::RFC2396_REGEXP::PATTERN) - Parser.new.pattern.each_pair do |sym, str| - unless REGEXP::PATTERN.const_defined?(sym) - REGEXP::PATTERN.const_set(sym, str) - end - end end Parser.new.regexp.each_pair do |sym, str| - remove_const(sym) if const_defined?(sym) + remove_const(sym) if const_defined?(sym, false) const_set(sym, str) end end diff --git a/lib/uri/rfc2396_parser.rb b/lib/uri/rfc2396_parser.rb index a56ca34..0336366 100644 --- a/lib/uri/rfc2396_parser.rb +++ b/lib/uri/rfc2396_parser.rb @@ -536,4 +536,11 @@ def convert_to_uri(uri) end end # class Parser + + # Backward compatibility for URI::REGEXP::PATTERN::* + RFC2396_Parser.new.pattern.each_pair do |sym, str| + unless RFC2396_REGEXP::PATTERN.const_defined?(sym, false) + RFC2396_REGEXP::PATTERN.const_set(sym, str) + end + end end # module URI diff --git a/lib/uri/rfc3986_parser.rb b/lib/uri/rfc3986_parser.rb index 4000f13..0b5f0c4 100644 --- a/lib/uri/rfc3986_parser.rb +++ b/lib/uri/rfc3986_parser.rb @@ -142,25 +142,25 @@ def join(*uris) # :nodoc: # Compatibility for RFC2396 parser def extract(str, schemes = nil, &block) # :nodoc: - warn "URI::RFC3986_PARSER.extract is obsoleted. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.extract is obsolete. Use URI::RFC2396_PARSER.extract explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.extract(str, schemes, &block) end # Compatibility for RFC2396 parser def make_regexp(schemes = nil) # :nodoc: - warn "URI::RFC3986_PARSER.make_regexp is obsoleted. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.make_regexp is obsolete. Use URI::RFC2396_PARSER.make_regexp explicitly.", uplevel: 1 if $VERBOSE RFC2396_PARSER.make_regexp(schemes) end # Compatibility for RFC2396 parser def escape(str, unsafe = nil) # :nodoc: - warn "URI::RFC3986_PARSER.escape is obsoleted. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.escape is obsolete. Use URI::RFC2396_PARSER.escape explicitly.", uplevel: 1 if $VERBOSE unsafe ? RFC2396_PARSER.escape(str, unsafe) : RFC2396_PARSER.escape(str) end # Compatibility for RFC2396 parser def unescape(str, escaped = nil) # :nodoc: - warn "URI::RFC3986_PARSER.unescape is obsoleted. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE + warn "URI::RFC3986_PARSER.unescape is obsolete. Use URI::RFC2396_PARSER.unescape explicitly.", uplevel: 1 if $VERBOSE escaped ? RFC2396_PARSER.unescape(str, escaped) : RFC2396_PARSER.unescape(str) end diff --git a/lib/uri/version.rb b/lib/uri/version.rb index e74ddec..59f1c82 100644 --- a/lib/uri/version.rb +++ b/lib/uri/version.rb @@ -1,6 +1,6 @@ module URI # :stopdoc: - VERSION_CODE = '010001'.freeze + VERSION_CODE = '010002'.freeze VERSION = VERSION_CODE.scan(/../).collect{|n| n.to_i}.join('.').freeze # :startdoc: end diff --git a/test/uri/test_common.rb b/test/uri/test_common.rb index 176efb8..e96f819 100644 --- a/test/uri/test_common.rb +++ b/test/uri/test_common.rb @@ -10,6 +10,10 @@ def setup def teardown end + class Foo + include URI::REGEXP::PATTERN + end + def test_fallback_constants orig_verbose = $VERBOSE $VERBOSE = nil @@ -19,6 +23,8 @@ def test_fallback_constants 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 + assert_equal URI::REGEXP::PATTERN, URI::RFC2396_REGEXP::PATTERN + assert_equal Foo::IPV4ADDR, URI::RFC2396_REGEXP::PATTERN::IPV4ADDR ensure $VERBOSE = orig_verbose end @@ -34,6 +40,7 @@ def test_parser_switch assert defined?(URI::REGEXP) assert defined?(URI::PATTERN) assert defined?(URI::PATTERN::ESCAPED) + assert defined?(URI::REGEXP::PATTERN::IPV6ADDR) URI.parser = URI::RFC3986_PARSER diff --git a/uri.gemspec b/uri.gemspec index 9cf0a71..0d0f897 100644 --- a/uri.gemspec +++ b/uri.gemspec @@ -30,8 +30,11 @@ Gem::Specification.new do |spec| # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. + gemspec = File.basename(__FILE__) spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do - `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } + `git ls-files -z 2>#{IO::NULL}`.split("\x0").reject do |file| + (file == gemspec) || file.start_with?(*%w[bin/ test/ rakelib/ .github/ .gitignore Gemfile Rakefile]) + end end spec.bindir = "exe" spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }