Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Feature req: adapters for ruby's xmlrpc class #84
It would be neat to be able to use ox to provide XMLRPC parsing in https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/parser.rb
I think the things to look at would be the AbstractStreamParser and AbstractTreeParser classes
I'm not exactly sure what you are looking for but with the Ox callback parser (SAX) you should be able to drive your XMLRPC calls. You will have to either rename some of them or wrap them but I don't see a problem with doing so. If I am missing the point please explain in more details what you are looking for.
I thought it would be nice to have the matching adapter code in the ox gem that integrates within the stdlib xmlrpc client. Basically that code that "wraps them" so people don't have to write it themselves.
Examples that are included in stdlib:
REXML Stream parser: https://github.com/ruby/ruby/blob/trunk/lib/xmlrpc/parser.rb#L723-L746
You can use .set_parser() on the XMLRPC client and pass in a class
require 'rubygems' require 'xmlrpc/client' require 'ox/xmlrpc_adapters' bla = XMLRPC::Client.new3(...) bla.set_parser(Ox::XMLRPC_ADAPTERS::Streamparser)
Seeing as XMLRPC is part of the stdlib, integrating in that doesn't seem tooooo far fetched :)
Nice and simple. I like it. Can you move it to the contrib directory though. It doesn't belong in the Ox directly as it can not be pulled in with the oj require since it has external dependencies and it is kind of odd requiring something from inside the module when it has already been loaded.
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
The problem moving this file to the contrib directory is that it is not added to the gem so this file will need to be imported manually to the project that uses it.
Another problem I've seen is that Ox does not unescape html/xml, that is, convert < to <, etc. This can be easily fixed changing the "character" alias to a method that calls, for example, CGI.unescape_html. Still most of the libraries to unescape html are awfully slow and most the time won with Ox parsing is lost unescaping the strings.
I'll move the file to contrib if you still think it's the way to go.