jasonroelofs/rbgccxml

Node.find() on arguments returning Enumerator

Closed this issue · 6 comments

I'm using Ruby1.9.1 and I suspect its Enumerator facility mingles with RbGCCXML:
Whereas a find() on classes and methods returns the actual Node or QueryResult, any call to RbGCCXML::Argument.find() returns an Enumerator which is inconsistent...
using rbgccxml1.0.1 on Ruby1.9.1 in Linux

irb(main):151:0> RootNode.namespaces("OpenZWave").classes.find(:name => "Manager")
=> RbGCCXML::Class @attributes={"id"=>"_4277", "name"=>"Manager", ....

irb(main):155:0> RootNode.namespaces("OpenZWave").classes.find(:name => "Manager").methods.find(:name => "WriteConfig")
=> RbGCCXML::Method @attributes={"id"=>"_13217", "name"=>"WriteConfig", ....

irb(main):156:0> RootNode.namespaces("OpenZWave").classes.find(:name => "Manager").methods("WriteConfig").arguments.find(:name => '_homeId')
=> Enumerator: [#<RbGCCXML::Argument @attributes={"name"=>"_homeId", ....

I found out that "arguments" returns a plain Array instance, whereas the other two return a QueryResult:

irb(main):057:0> target_method.arguments.class
=> Array
irb(main):058:0> RootNode.classes.class
=> RbGCCXML::QueryResult

If I remember correctly, as you can't dive any deeper than an Argument I left that to just return the direct children as parsed out of the XML. This definitely is inconsistent with the rest of the library, and something I can easily fix. Was this causing a specific issue for you?

no problem, I worked around the "bug", but since I learned Ruby some 10
years ago, I've probably set the bar too high... ("principle of least
surprise")
thanks for the quick reply...
BTW, RbGCCXML is one of the most invaluable tools I've come to use!!

2011/12/6 Jason Roelofs <
reply@reply.github.com

If I remember correctly, as you can't dive any deeper than an Argument I
left that to just return the direct children as parsed out of the XML. This
definitely is inconsistent with the rest of the library, was this causing a
specific issue for you?


Reply to this email directly or view it on GitHub:
https://github.com/jameskilton/rbgccxml/issues/8#issuecomment-3033050

I strive to adhere to that principle as well, though I guess I failed here. I shall get that fixed. If something of mine causes you extra work, that's a bug for sure. Thanks for bringing it to my attention, and I'm glad I could help make your life easier.

Here's my derived work:
Its a wrapper for Apache Thrift, it makes writing servers for it fairly
trivial...

https://github.com/ekarak/Thrift4OZW

Thanks again for everything!!!!
Elias

2011/12/6 Jason Roelofs <
reply@reply.github.com

I strive to adhere to that principle as well, though I guess I failed
here. I shall get that fixed. If something of mine causes you extra work,
that's a bug for sure. Thanks for bringing it to my attention, and I'm glad
I could help make your life easier.


Reply to this email directly or view it on GitHub:
https://github.com/jameskilton/rbgccxml/issues/8#issuecomment-3033610

I've released 1.0.2 of rbgccxml with these changes. #arguments wasn't the only place this needed to be changed. Thanks again!