glejeune/Ruby-Graphviz — Issue #34: About the acquisition of graphml <data> tags with ruby 1.9.2p290, ruby-graphviz 1.0.3
Author: ErnestoTorresin
Created: 2012-01-24 12:28:19+00:00
State: open

Using ruby 1.9.2p290 and ruby-graphviz 1.0.3, I noticed that ruby-graphviz
presented the content of graphml tags within square brackets, and with new, escaped quotes.
So

'text'

in graphml became

'[\"text\"]'

in dot and hence

'["text"]'

in final formats, as it can be seen working out a simple graphml file like
---------------------------
ab.graphml
---------------------------

a

b

---------------------------

This behaviour can easily be corrected by redefining the method graphml_graph_node_data in
GraphViz::GraphML.
This can be done - à la Ruby - just in programs, like this
---------------------------
class GraphViz
class GraphML

def graphml_graph_node_data( node )

# drop this
#@current_node[@attributs[:nodes][node.attributes['key']][:name]] = node.texts().to_s

# add this
@current_node[@attributs[:nodes][node.attributes['key']][:name]] = node.texts().join(sep='\n',)

end
end
end
---------------------------

Bye

Ernesto Torresin (EWK)

PS I like this library. Thank you for it.