Empact / roxml

ROXML is a module for binding Ruby classes to XML. It supports custom mapping and bidirectional marshalling between Ruby and XML using annotation-style class methods, via Nokogiri or LibXML.
http://roxml.rubyforge.org/
MIT License
223 stars 176 forks source link

Remove ActiveSupport dependency #65

Closed timriley closed 6 months ago

timriley commented 5 years ago

Hi there! 👋

I've been resuscitating another old gem that relies on roxml, and I wanted to be able to run it without introducing ActiveSupport and its patching of various Ruby core classes.

So in this PR, I've removed all usages of ActiveSupport core classes extensions from within roxml.

I know you opened up https://github.com/Empact/roxml/issues/8 back in 2009(!) and decided in the end to leave ActiveSupport in place, because "it will then be a reliable base library," but IMHO, this didn't quite work out as expected, e.g. you can't even use the ActiveSupport inflector standalone without bringing in its various patches on String, etc. From my perspective, an ideal Ruby library today shouldn't change core class behaviour if it can easily avoid it (particularly if that library supports usage outside of Rails – or even by other libraries, which is the case for me) so I hope you will be open to reconsidering this in 2019! :)

I've made a commit for each specific group of changes, so hopefully the history here is easy to follow.

The biggest of all the adjustments I made (in terms of roxml's actual API) is the introduction of xml_inflector (in https://github.com/Empact/roxml/commit/ae34e42302a4eb56b203c41e169e289d15713c43), for providing a user-configurable inflector object. For this I rely on Dry::Core::Inflector, which will detect an appropriate inflector backend based on the currently available gems. If ActiveSupport is available, it will use its inflector first, so there should be no change in actual behaviour for your existing users. And unlike activesupport, dry-core is a very small and minimal-impact dependency.

Apart from this, the only other thing of note is that to preserve some meaningful behaviour from ActiveSupport's String#blank? patch, I copied the implementation into ROXML::Utils.string_blank? and used that where appropriate, which seemed like a reasonable approach to maintain feature compatibility.

Thanks for taking a look at this, and please let me know if there's any more I can do! I appreciate all you've done to keep a gem like this maintained over all the years ❤️

lostapathy commented 5 years ago

I definitely like the spirit of this change! I'll have to defer to @Empact on how he wants to proceed on it.

timriley commented 5 years ago

Hi @Empact, just wanted to check in again and if you're able to weigh in on this PR? Thank you!

rmacklin commented 4 years ago

@timriley You may or may not be interested in this: https://github.com/Empact/roxml/issues/64#issuecomment-641553363

Does anyone want to step up as a maintainer?

Empact commented 4 years ago

Thanks @timriley, I appreciate the work you've done here - we can get this in the next release.

Could you rebase the PR?

Empact commented 6 months ago

Merged as https://github.com/Empact/roxml/commit/0bc78e6a0fa95a78815b4939215229e0116de9af