Skip to content

Commit

Permalink
Don't make rexml an dependency of activesupport
Browse files Browse the repository at this point in the history
rexml is only used in the xml_mini backend and it should be the users
choice if they want to use that feature or not. If they do we will warn
them that installing rexml is needed like we do with all backends.
  • Loading branch information
rafaelfranca committed Sep 24, 2020
1 parent 357013d commit f624ed0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -607,6 +606,7 @@ DEPENDENCIES
redis-namespace!
resque
resque-scheduler
rexml
rouge
rubocop (>= 0.90)
rubocop-packaging
Expand Down
1 change: 0 additions & 1 deletion activesupport/activesupport.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion activesupport/lib/active_support/xml_mini/rexml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def parse(data)
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
Expand All @@ -38,6 +38,14 @@ def parse(data)
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::
Expand Down

0 comments on commit f624ed0

Please sign in to comment.