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

Gem rexml runtime dependency #100

Closed rchekaluk closed 6 months ago

rchekaluk commented 6 months ago

Fixes issue #99.

The issue contains failing QuickBooks Online XML, but I was unable to readily craft a suitable spec, leaving that as an exercise.

Empact commented 6 months ago

Merged as: https://github.com/Empact/roxml/commit/517d5ad89f91b94efe41b60aa10d2a48807562eb

Empact commented 6 months ago

@rchekaluk would you mind testing the latest code (from master) against your codebase before I make a release? I've made a few internal api changes which may present an issue.

Empact commented 6 months ago

CI is passing: https://github.com/Empact/roxml/actions/runs/9181556726

But I had to disable one test to achieve that: https://github.com/Empact/roxml/commit/e7201ddf5332492daa4c6d134400f9985bd2a3d6

rchekaluk commented 6 months ago

Problem 1 during "bundle install":

[!] There was an error while loading `roxml.gemspec`: undefined local variable or method `spec' for main:Object
Did you mean?  inspect. Bundler cannot continue.

 #  from /usr/share/rvm/gems/ruby-3.1.2/bundler/gems/roxml-f233380db9b2/roxml.gemspec:8
 #  -------------------------------------------
 #  
 >    spec.required_ruby_version = ">= 3.0.0"
 #    s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
 #  -------------------------------------------
rchekaluk commented 6 months ago

Problem 2 during runtime (after fixing problem 1 locally):

/usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:159:in `rescue in parse_collection': Error parsing XML: uninitialized constant Quickbooks::Model::BaseModel::HashWithIndifferentAccess (Quickbooks::IntuitRequestException)

        HashWithIndifferentAccess[attributes]
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:127:in `parse_collection'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:120:in `fetch_collection'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/service_crud.rb:6:in `query'
    from local_script.rb:46:in `get_customers'
    from local_script.rb:85:in `<main>'
/usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/model/base_model.rb:52:in `attributes': uninitialized constant Quickbooks::Model::BaseModel::HashWithIndifferentAccess (NameError)

        HashWithIndifferentAccess[attributes]
        ^^^^^^^^^^^^^^^^^^^^^^^^^
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:521:in `attribute_method?'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:528:in `block in matched_attribute_method'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:528:in `each'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:528:in `detect'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:528:in `matched_attribute_method'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/activemodel-7.1.3.3/lib/active_model/attribute_methods.rb:515:in `respond_to?'
    from $ROXML_FORK/lib/roxml.rb:581:in `block in from_xml'
    from <internal:kernel>:90:in `tap'
    from $ROXML_FORK/lib/roxml.rb:572:in `from_xml'
    from $ROXML_FORK/lib/roxml/xml/references.rb:321:in `block in fetch_value'
    from $ROXML_FORK/lib/roxml/xml/references.rb:137:in `nodes_in'
    from $ROXML_FORK/lib/roxml/xml/references.rb:319:in `fetch_value'
    from $ROXML_FORK/lib/roxml/xml/references.rb:37:in `value_in'
    from $ROXML_FORK/lib/roxml.rb:576:in `block (2 levels) in from_xml'
    from $ROXML_FORK/lib/roxml.rb:575:in `each'
    from $ROXML_FORK/lib/roxml.rb:575:in `block in from_xml'
    from <internal:kernel>:90:in `tap'
    from $ROXML_FORK/lib/roxml.rb:572:in `from_xml'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:153:in `block in parse_collection'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xml/node_set.rb:235:in `block in each'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xml/node_set.rb:234:in `upto'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/nokogiri-1.16.5-x86_64-linux/lib/nokogiri/xml/node_set.rb:234:in `each'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:152:in `parse_collection'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/base_service.rb:120:in `fetch_collection'
    from /usr/share/rvm/gems/ruby-3.1.2/gems/quickbooks-ruby-2.0.3/lib/quickbooks/service/service_crud.rb:6:in `query'
    from local_script.rb:46:in `get_customers'
    from local_script.rb:85:in `<main>'
Empact commented 6 months ago

Thanks for testing! Pushed a fix for the former bug, looks like the second is an issue in quickbooks-ruby.

They're not declaring their dependency on activesupport, they happened to get by thanks to ours, so now that we've removed it they need to declare it. You should be able to work around the issue in the mean time by requiring activesupport as a dependency in your own project before you require quickbooks-ruby.

rchekaluk commented 5 months ago

@Empact your workaround is successful. Ready for your release at any time.