kgiszczak / shale

Shale is a Ruby object mapper and serializer for JSON, YAML, TOML, CSV and XML. It allows you to parse JSON, YAML, TOML, CSV and XML data and convert it into Ruby data structures, as well as serialize data structures into JSON, YAML, TOML, CSV or XML.
https://shalerb.org/
MIT License
618 stars 19 forks source link

Exception with ruby 3.1 - missing rexml #2

Closed feliperaul closed 2 years ago

feliperaul commented 2 years ago

Hi there! First of all, what a nice gem you've given us here. Amazed by how elegant it's API turned out to be. Excited to use it in a new API integration.

Also, 300+ stars, all these features, and no issues? Not even closed ones? What kind of sorcery is that? 😃

Anyways, I'll be the first. I was facing this exception when trying to use it in a Rails project with Ruby 3.1:

/Users/xxx/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/bootsnap-1.11.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:15:in `require': cannot load such file -- rexml/document (LoadError)

According to this blog post, rexml is now a bundled gem, so I had to add it manually in my gemfile as well, which fixed it.

In our case, since performance isn't a huge concern, I'd like to avoid the rexml dependency and use Nokogiri that we already use. Tried changing the adapter in an initiailzer, as per the gem's README instructions, but it raises the exception before reaching the initializer.

Maybe the requirement of rexml could be relaxed, or else instructions for adding rexml in the Gemfile could be added in the readme.

kgiszczak commented 2 years ago

Hi, thanks for kind words, I'm glad you like this library and thanks for pointing this issue. I will investigate and probably change the default behaviour so you have to set XML adapter explicitly.

kgiszczak commented 2 years ago

@feliperaul I just released a new version v0.5.0 that drops the requirement on REXML. I will close the issue. If you still have problems please reopen it or create a new one.

Changelog: https://www.shalerb.org/releases.html

feliperaul commented 2 years ago

@kgiszczak Thank you!