lib/graphviz/graphml.rb in ruby-graphviz-1.0.3 vs lib/graphviz/graphml.rb in ruby-graphviz-1.0.4

- old
+ new

@@ -18,11 +18,15 @@ require 'graphviz' require 'rexml/document' class GraphViz class GraphML - attr_reader :attributs + attr_reader :attributes + def attributs + warn "`GraphViz::GraphML#attributs` is deprecated, please, use `GraphViz::GraphML#attributes`" + return @attributes + end # The GraphViz object attr_accessor :graph DEST = { @@ -39,11 +43,11 @@ # Create a new GraphViz object from a GraphML file of string def initialize( file_or_str ) data = ((File.file?( file_or_str )) ? File::new(file_or_str) : file_or_str) @xmlDoc = REXML::Document::new( data ) - @attributs = { + @attributes = { :nodes => {}, :edges => {}, :graphs => {} } @graph = nil @@ -78,11 +82,11 @@ @current_attr = { :name => node.attributes['attr.name'], :type => node.attributes['attr.type'] } DEST[node.attributes['for']].each do |d| - @attributs[d][id] = @current_attr + @attributes[d][id] = @current_attr end node.each_element( ) do |child| begin send( "graphml_key_#{child.name}".to_sym, child ) @@ -108,17 +112,17 @@ else previous_graph = @current_graph @current_graph = previous_graph.add_graph( node.attributes['id'] ) end - @attributs[:graphs].each do |id, data| + @attributes[:graphs].each do |id, data| @current_graph.graph[data[:name]] = data[:default] if data.has_key?(:default) end - @attributs[:nodes].each do |id, data| + @attributes[:nodes].each do |id, data| @current_graph.node[data[:name]] = data[:default] if data.has_key?(:default) end - @attributs[:edges].each do |id, data| + @attributes[:edges].each do |id, data| @current_graph.edge[data[:name]] = data[:default] if data.has_key?(:default) end node.each_element( ) do |child| #begin @@ -130,11 +134,11 @@ @current_graph = previous_graph end def graphml_graph_data( node ) #:nodoc: - @current_graph[@attributs[:graphs][node.attributes['key']][:name]] = node.texts().to_s + @current_graph[@attributes[:graphs][node.attributes['key']][:name]] = node.texts().to_s end def graphml_graph_node( node ) #:nodoc: @current_node = {} @@ -160,11 +164,12 @@ @current_node = nil end def graphml_graph_node_data( node ) #:nodoc: - @current_node[@attributs[:nodes][node.attributes['key']][:name]] = node.texts().to_s + #@current_node[@attributes[:nodes][node.attributes['key']][:name]] = node.texts().to_s + @current_node[@attributes[:nodes][node.attributes['key']][:name]] = node.texts().join(sep='\n',) end def graphml_graph_node_port( node ) #:nodoc: @current_node[:shape] = :record port = node.attributes['name'] @@ -194,10 +199,10 @@ @current_edge = nil end def graphml_graph_edge_data( node ) #:nodoc: - @current_edge[@attributs[:edges][node.attributes['key']][:name]] = node.texts().to_s + @current_edge[@attributes[:edges][node.attributes['key']][:name]] = node.texts().to_s end def graphml_graph_hyperedge( node ) #:nodoc: list = []