diff --git a/Gemfile b/Gemfile index e5c0ebcbed..a58e183a00 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,7 @@ gem "dalli" gem "listen", "~> 3.2", require: false, github: "guard/listen" gem "libxml-ruby", platforms: :ruby gem "connection_pool", require: false +gem "rexml", require: false # for railties app_generator_test gem "bootsnap", ">= 1.4.4", require: false diff --git a/Gemfile.lock b/Gemfile.lock index 336c64155b..69630d0e2e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -95,7 +95,6 @@ PATH concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) - rexml tzinfo (~> 2.0) zeitwerk (~> 2.3) rails (6.1.0.alpha) @@ -607,6 +606,7 @@ DEPENDENCIES redis-namespace! resque resque-scheduler + rexml rouge rubocop (>= 0.90) rubocop-packaging diff --git a/activesupport/activesupport.gemspec b/activesupport/activesupport.gemspec index 9cffc2696c..72cd995f02 100644 --- a/activesupport/activesupport.gemspec +++ b/activesupport/activesupport.gemspec @@ -38,5 +38,4 @@ Gem::Specification.new do |s| s.add_dependency "concurrent-ruby", "~> 1.0", ">= 1.0.2" s.add_dependency "zeitwerk", "~> 2.3" s.add_dependency "minitest", ">= 5.1" - s.add_dependency "rexml" end diff --git a/activesupport/lib/active_support/xml_mini/rexml.rb b/activesupport/lib/active_support/xml_mini/rexml.rb index 8d6e3af066..626e0122ac 100644 --- a/activesupport/lib/active_support/xml_mini/rexml.rb +++ b/activesupport/lib/active_support/xml_mini/rexml.rb @@ -25,7 +25,7 @@ module ActiveSupport if data.eof? {} else - silence_warnings { require "rexml/document" } unless defined?(REXML::Document) + require_rexml unless defined?(REXML::Document) doc = REXML::Document.new(data) if doc.root @@ -38,6 +38,14 @@ module ActiveSupport end private + + def require_rexml + silence_warnings { require "rexml/document" } + rescue LoadError => e + $stderr.puts "You don't have rexml installed in your application. Please add it to your Gemfile and run bundle install" + raise e + end + # Convert an XML element and merge into the hash # # hash::