Asciidoctor 0.1.3 attributes and conflict with AJI

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Asciidoctor 0.1.3 attributes and conflict with AJI

asotobu
In version 0.1.3 of asciidoctor you can specify attributes as Hash, String or Array, when from AJI I specify attributes as Map, an org.jruby.exceptions.RaiseException: (ArgumentError) illegal type for attributes option exception is thrown.

I have debug the code and I have seen that JRuby transforms a Map to a RubyHash object (which with previous versions of asciidoctor works fine), concretely Java::JavaUtil::HashMap, so when asciidoctor executes the if/else to know if a String, Array or Hash has been passed as argument, it doesn't match any class and the exception is thrown.

I will try to transform this object to native Hash but maybe (hope not) it will require some kind of modification from asciidoctor part.

Well I will keep all of you informed about this important issue.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

asotobu
solved, not a very clean solution but at least it works. I intercept any Map inside options and I transform to native Hash
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

LightGuardjp
Often times while writing integration or framework code you end up doing things that aren't very clean. This is okay because the main goal is to make it easy for the end users. As long as your code is well documented and others can help maintain it, unclean code doesn't matter as much. 

Sent from Mailbox for iPhone


On Sat, Jun 1, 2013 at 12:54 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:

solved, not a very clean solution but at least it works. I intercept any Map inside options and I transform to native Hash


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p259.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

asotobu
well it is clean, the problem is that you iterate through a Map for moving all elements from one kind of map to another kind of map, so it is a problem of performance more than something that it cannot be understood. Also I must admit that when I have seen all my tests failing I have entered on panic time and for this reason I have written a post on this forum, but the solution of the problem is easy to understand.

Tomorrow I will release the 0.1.3 version, so Maven, Gradle, Asciidoclet, Viewers, ... can upgrade.
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

LightGuardjp
Another possibility is to create our own implementation of a map that also implements the RubyHash interface as well, no reason we couldn't do that. 

Sent from Mailbox for iPhone


On Sat, Jun 1, 2013 at 4:30 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:

well it is clean, the problem is that you iterate through a Map for moving all elements from one kind of map to another kind of map, so it is a problem of performance more than something that it cannot be understood. Also I must admit that when I have seen all my tests failing I have entered on panic time and for this reason I have written a post on this forum, but the solution of the problem is easy to understand.

Tomorrow I will release the 0.1.3 version, so Maven, Gradle, Asciidoclet, Viewers, ... can upgrade.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p261.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

asotobu
Well in fact RubyHash implements Map so no problem in that way but because Option class is a model class which could be used when we integrate AJI with Javascript (if we find useful of course) I would like to maintain Option class free of JRuby dependencies

El diumenge 2 de juny de 2013, lightguard.jp [via Asciidoctor :: Discussion] ha escrit:
Another possibility is to create our own implementation of a map that also implements the RubyHash interface as well, no reason we couldn't do that. 

Sent from Mailbox for iPhone


On Sat, Jun 1, 2013 at 4:30 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:

well it is clean, the problem is that you iterate through a Map for moving all elements from one kind of map to another kind of map, so it is a problem of performance more than something that it cannot be understood. Also I must admit that when I have seen all my tests failing I have entered on panic time and for this reason I have written a post on this forum, but the solution of the problem is easy to understand.

Tomorrow I will release the 0.1.3 version, so Maven, Gradle, Asciidoclet, Viewers, ... can upgrade.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p261.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p262.html
To unsubscribe from Asciidoctor 0.1.3 attributes and conflict with AJI, click here.
NAML


--
Enviat amb Gmail Mobile
Reply | Threaded
Open this post in threaded view
|

Re: Asciidoctor 0.1.3 attributes and conflict with AJI

mojavelinux
Administrator
Alex,

Thanks for bringing this to my attention. I didn't realize the type check on the attributes option would end up being too restrictive when integrating with Java. Shoot. I'll have to remember to be careful when dealing with data types that are passed in and out of the Asciidoctor APIs.

I was curious what ancestors the Map has when it comes from Java, so I did a little bit of digging. Here's the ancestor collection that is reported:

 [Java::JavaUtil::HashMap, Java::JavaLang::Cloneable, Java::JavaIo::Serializable, Java::JavaUtil::AbstractMap, Java::JavaUtil::Map, Enumerable, Java::JavaLang::Object, ConcreteJavaProxy, JavaProxy, JavaProxyMethods, Object, Kernel, BasicObject]

Looking through there, I see that we have Enumerable, but we don't have Hash. The closest type, as you pointed out, is Java::JavaUtil::Map. I filed an issue to support this type if the engine is JRuby.


I've fixed it with this pull request:


The key line that I changed was:

 if attrs.is_a?(Hash) || (RUBY_ENGINE == 'jruby' && attrs.is_a?(Java::JavaUtil::Map))

To make the API as flexible as possible, I added a fallback for anything that is Hash like (responds to both "keys" and "[]") and convert it to a Hash. That way, we should be safe if someone passes in a custom dictionary and expects it to work.

You should be able to remove your workaround in 0.1.4.

Cheers,

-Dan


On Sat, Jun 1, 2013 at 5:58 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Well in fact RubyHash implements Map so no problem in that way but because Option class is a model class which could be used when we integrate AJI with Javascript (if we find useful of course) I would like to maintain Option class free of JRuby dependencies

El diumenge 2 de juny de 2013, lightguard.jp [via Asciidoctor :: Discussion] ha escrit:
Another possibility is to create our own implementation of a map that also implements the RubyHash interface as well, no reason we couldn't do that. 

Sent from Mailbox for iPhone


On Sat, Jun 1, 2013 at 4:30 PM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:

well it is clean, the problem is that you iterate through a Map for moving all elements from one kind of map to another kind of map, so it is a problem of performance more than something that it cannot be understood. Also I must admit that when I have seen all my tests failing I have entered on panic time and for this reason I have written a post on this forum, but the solution of the problem is easy to understand.

Tomorrow I will release the 0.1.3 version, so Maven, Gradle, Asciidoclet, Viewers, ... can upgrade.


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p261.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML




If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p262.html
To unsubscribe from Asciidoctor 0.1.3 attributes and conflict with AJI, click here.
NAML


--
Enviat amb Gmail Mobile



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Asciidoctor-0-1-3-attributes-and-conflict-with-AJI-tp258p263.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--