ruby-graphviz 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,241 +14,6 @@ Interface to the GraphViz graphing tool
14
14
 
15
15
  * New FamilyTree
16
16
 
17
- == CHANGELOG
18
-
19
- === 1.0.3 :
20
- * The GraphViz::Theory#moore_dijkstra return a path which contains GraphViz::Node instead of GraphViz::Node#id
21
- * Add Breadth First Search algorithm (GraphViz::Theory#bfs)
22
- * Add Depth First Search algorithm (GraphViz::Theory#dfs)
23
- * Add GraphViz#add_edges (GraphViz#add_edge is deprecated)
24
- * Add GraphViz#add_nodes (GraphViz#add_node is deprecated)
25
- * Add GraphViz::generate
26
- * Remove definition of Array#all?
27
-
28
- === 1.0.2 :
29
- * Add PageRank algorithm
30
- * Major bug corrections
31
- * Fix utils/colors.rb's case syntax
32
- * Modify deprecated method: Hash#index to Hash#key
33
-
34
- === 1.0.1 :
35
- * Add GraphViz::DSL
36
- * Change project to use Bundler gem tools
37
- * Fix a few typos in the README
38
- * Change Config to RbConfig
39
- * Add possibility to get the x,y coordinates of each of the nodes
40
-
41
- === 1.0.0 :
42
- * \o/
43
- * GraphViz::Node#name has been removed - use GraphViz::Node#id
44
- * The html attribute has been removed - use a label attribut (<tt>:label => '<<html/>>'</tt>)
45
- * :output option has been removed - use :<format> => :<file>
46
- * :file option has been removed - use :<format> => :<file>
47
- * Add GraphViz#to_s
48
- * Add GraphViz#add (see sample59.rb)
49
- * GraphViz::XML.output is deprecated, use GraphViz::XML.graph.output
50
- * Issue #22 : Error when generating a graph with an ID containing a space.
51
-
52
- === 0.9.21 :
53
- * Add attributes "label_scheme" and "rotation"
54
- * Add missing options :
55
- * <tt>:scale => v</tt> : Scale input by 'v' (=72)
56
- * <tt>:inverty => [true|false]</tt> : Invert y coordinate in output
57
- * <tt>:no_layout => v</tt> : No layout mode 'v' (=1) -- neato only
58
- * <tt>:reduce => [true|false]</tt> : Reduce graph -- neato only
59
- * <tt>:Lg => [true|false]</tt> : Don't use grid -- fdp only
60
- * <tt>:LO => [true|false]</tt> : Use old attractive force -- fdp only
61
- * <tt>:Ln => i</tt> : Set number of iterations to i -- fdp only
62
- * <tt>:LU => i</tt> : Set unscaled factor to i -- fdp only
63
- * <tt>:LC => v</tt> : Set overlap expansion factor to v -- fdp only
64
- * <tt>:LT => [*]v</tt> : Set temperature (temperature factor) to v -- fdp only
65
-
66
- === 0.9.20 :
67
- * Add GraphViz#each_attribut, Node#each_attribut and Edge#each_attribut
68
- * Bugs corrections in tests (by oupo)
69
- * Major bug correction in GraphViz#output for subgraphs
70
- * Update GraphViz.escape
71
-
72
- === 0.9.19 :
73
- * Add strict digraph support (by Jonas Elfström) (see sample58.rb)
74
- g = GraphViz.new(:G, :type => "strict digraph")
75
- # or
76
- g = GraphViz.new(:G, :type => "digraph", :strict => true)
77
- # or
78
- g = GraphViz.digraph(:G, :strict => true)
79
- # or
80
- g = GraphViz.strict_digraph(:G)
81
- * Add GraphViz#root_graph, Node#root_graph, Edge#root_graph
82
- * The GraphML parser now accept a graphml file or string
83
-
84
- === 0.9.18 :
85
- * JRuby bug correction (by Nigel Thorne)
86
- * Fix autoload problem for Rubinius (by Rolf Timmermans)
87
- * Bugs corrections
88
-
89
- === 0.9.17 :
90
- * GraphViz::Edge#node_one and GraphViz::Edge#node_one now have un optional parameter to indicate if you want to (or not) get the port in the name (default: true)
91
- * GraphViz#each_node now returns the Hash of nodes if there is no block given.
92
- * GraphViz#each_edge now returns the list of edges if there is no block given.
93
- * GraphViz#each_graph now returns the Hash of graphs if there is no block given.
94
- * Add GraphViz::Node#index : return the node index
95
- * Add GraphViz::Edge#index : return the edge index
96
- * Add GraphViz#type : return the graph type (graph or digraph)
97
- * Add GraphViz#get_edge_at_index and GraphViz#get_node_at_index
98
- * Add GvDouble
99
- * Add GraphViz::Theory (see examples/theory/tests.rb)
100
- * Add GraphML[http://graphml.graphdrawing.org/] support (see sample57.rb)
101
- * fixed "edge attribut 'to_ary' invalid" on mri 1.9.2 (by Stefan Huber)
102
-
103
- === 0.9.16 :
104
- * Add <tt>xml2gv</tt>
105
- * Rename <tt>GraphViz.parser2</tt> to <tt>GraphViz.parser</tt>
106
- * Remove treetop dependency
107
- * Ruby 1.9 (and MacRuby) compatibility -- Issue #12: see sample38.rb
108
- * Add GraphViz::Attrs#each and GraphViz::Attrs#to_h
109
- * Add GraphViz::Edge#node_one and GraphViz::Edge#node_two
110
-
111
- === 0.9.15 :
112
- * Add <tt>GraphViz.parser2</tt>. <b>WARNING</b> this method will replace <tt>GraphViz.parser</tt>. So please don't use it, or only for testing.
113
- * Bug correction in <tt>dot2ruby</tt>
114
- * Add <tt>--output-format</tt> option to <tt>dot2ruby</tt>
115
- * Add <tt>git2gv</tt>
116
- * Issue #16 : escape graph ID
117
-
118
- === 0.9.14 :
119
- * Add dot2ruby script
120
- * Remove NULL character in the DOT script
121
- * <b>WARNING</b> : FamilyTree is (still) broken in this version !
122
-
123
- === 0.9.13 :
124
- * Add dot2ruby.g
125
- * Bug correction with HTML label
126
- * The html attribut is deprecated. You can use the label attribut, as dot do it : <tt>:label => '<<html/>>'</tt>
127
- * Issue #15 : Thin server
128
- * <b>WARNING</b> : FamilyTree is (still) broken in this version !
129
-
130
- === 0.9.12 :
131
- * GraphViz::Node#name is deprecated, you must use GraphViz::Node#id (issue #14)
132
- * Add :nothugly option to GraphViz#output (see sample41.rb and http://www.hokstad.com/making-graphviz-output-pretty-with-xsl.html)
133
- * Issue #13 : you must now specify a port in GraphViz::Edge.new with a syntax like this :
134
- GraphViz::Edge.new( {nodeOne => :port}, {nodeTwo => :other} )
135
- * Issue #12 : UTF8 support (see sample38.rb)
136
- * Move and rename examples + remove maketest.[sh|bat]
137
- * <b>WARNING</b> : FamilyTree is broken in this version !
138
-
139
- === 0.9.11 :
140
- * Issue #11 : Cygwin PATH
141
- * Major bugs correction in output
142
- * Bug correction in find_executable
143
- * Add tests (by Chip Malice : http://github.com/hipe)
144
-
145
- === 0.9.10 :
146
- * Move ChangeLog in README
147
- * Add GraphViz::FamilyTree (alpha). See examples/sample33.rb
148
- * Major bugs corrections in GraphViz::Parser
149
- * Issue #10 : Anonymous graph (see Subgraphs and Clusters at http://www.graphviz.org/doc/info/lang.html). See examples/sample34.rb
150
- * GraphViz#add_graph can now take a block parameter. See example/sample34.rb
151
- * Add GraphViz.digraph and GraphViz.graph (same as GraphViz.new( ..., :type => "digraph" ) and GraphViz.new( ..., :type => "graph" )). See examples/sample35.rb
152
- * Add GraphViz#subgraph. See examples/sample35.rb
153
- * GraphViz::Parser support anonymous graph
154
- * Add lage node example. See examples/sample36.rb
155
-
156
- === 0.9.9 :
157
- * Add graph as an accessor to allow you to set global graph attributs (like edge and node)
158
- * Add each_node, each_edge, each_graph (thanks to @metellius) and graph_count
159
- * Issue #9 (partial) - Solution : by default, a node will have his label set with the node ID)
160
-
161
- === 0.9.8 :
162
- * Update graph and node posibility to set properties (see sample28.rb)
163
- * Issue #7: Path option is never being used to find the executable
164
- * Adding classes to check if the attributes are in the correct type
165
- * Issue #8: dots in href are escaped with backslash, which corrupts the URL (see sample29.rb)
166
- * Add posibility to use external libraries (see sample30.rb)
167
- * Add options -u and -s to ruby2gv
168
- * Add gem2gv
169
-
170
- === 0.9.7 :
171
- * Issue #2: Small bug correction in escape_path_containing_blanks (by Andreas Ronge)
172
- * Issue #4: New find_executable (by reactive)
173
- * Issue #3: Tempfiles created in current working directory only in Windows
174
- * Issue #6: Respect "none" format in output options hash and respect String output-filename when the "none" format is selected. See examples/sample27.rb (by Dave Burt)
175
-
176
- === 0.9.6 :
177
- * jRuby support (by obruening)
178
- * Issue #1 : STDOUT in binmode
179
-
180
- === 0.9.5 :
181
- * Remove 'mkmf' dependency
182
- * GraphViz::Edge#[] modification
183
- * Small correction to escape the dot ('.') character (by Miguel Cabrera)
184
-
185
- === 0.9.4 :
186
- * Escape nodes and edges attributs
187
- * GraphViz::escape corrections (by Dave Burt)
188
- * Add :errors option to set level of message suppression (default : suppress warning messages)
189
-
190
- === 0.9.3 :
191
- * Minor bug correction for Windows
192
- * Use Open3.popen3 if installed, else use IO.popen (by Dave Burt)
193
- * Add '-', '>' and '>>' has aliases of '<<' to create an edge.
194
-
195
- === 0.9.2 :
196
- * Escape nodes (by Dave Burt)
197
- * Handle errors from graphviz command (by Dave Burt)
198
- * Output as string (if String class is passed as file i.e. output(:pdf => String)) (by Dave Burt)
199
-
200
- === 0.9.1 :
201
- * Bugs corrections
202
- * Add the ability to create edge like that : node1 << node2 << node3 ...
203
- * Complete README
204
- * Add a DOT parser. This parser has a lot of limitations. So don't use it in a production context !
205
- * :output and :file options are deprecated, please use :<format> => :<file>
206
- * You can now specify multiple outputs via :<format> => :<file> (see sample 22).
207
-
208
- === 0.9.0 :
209
- * Add fdp example (sample 15)
210
- * Add edge between cluster and node and cluster and cluster support
211
- * GraphViz.add_node now support array (sample 16)
212
- * Bug correction in GraphViz.output (sample 19)
213
- * Add GraphViz#default to set default options (:use, :path and :output)
214
- * Add possibility to set node or edge attribut via :
215
- node.<attribut>=<value> or node.<attribut>( <value> )
216
- edge.<attribut>=<value> or edge.<attribut>( <value> )
217
- * Add GraphViz::Edge.set and GraphViz::Node.set
218
- * Add sample 20
219
- * Add GraphViz.node_count and GraphViz.edge_count by Daniel Cadenas Nión
220
-
221
- === 0.8.2 :
222
- * Update Node, Edge and Graph Attributes (see http://www.graphviz.org/doc/info/attrs.html)
223
- * Bugs corrections
224
-
225
- === 0.8.1 :
226
- * Documentation
227
-
228
- === 0.8.0 :
229
- * Add all the features of the current graphviz version
230
-
231
- === 0.7.0 :
232
- * Add option "path" to output
233
-
234
- === 0.6.0 :
235
- * Add undirected graph support
236
-
237
- === 0.5.0 :
238
- * Preserve the original order of creation of nodes and edges
239
-
240
- === 0.4.0 :
241
- * Add HTML-Labels
242
-
243
- === 0.3.0 :
244
- * Bugs corrections
245
-
246
- === 0.2.0 :
247
- * Pure ruby
248
-
249
- === 0.1.0 :
250
- * Initial version
251
-
252
17
  == SYNOPSIS
253
18
 
254
19
  A basic example
@@ -259,11 +24,11 @@ A basic example
259
24
  g = GraphViz.new( :G, :type => :digraph )
260
25
 
261
26
  # Create two nodes
262
- hello = g.add_node( "Hello" )
263
- world = g.add_node( "World" )
27
+ hello = g.add_nodes( "Hello" )
28
+ world = g.add_nodes( "World" )
264
29
 
265
30
  # Create an edge between the two nodes
266
- g.add_edge( hello, world )
31
+ g.add_edges( hello, world )
267
32
 
268
33
  # Generate output image
269
34
  g.output( :png => "hello_world.png" )
@@ -333,9 +98,9 @@ Ruby/GraphViz also includes :
333
98
  require 'graphviz'
334
99
  graph_g = GraphViz.digraph( "G" ) { |graph_g|
335
100
  graph_g[:bb] = '0,0,70,108'
336
- node_hello = graph_g.add_node( "Hello", :height => '0.5', :label => '\N', :pos => '35,90', :width => '0.88889' )
337
- graph_g.add_edge( "Hello", "World", :pos => 'e,35,36.413 35,71.831 35,64.131 35,54.974 35,46.417' )
338
- node_world = graph_g.add_node( "World", :height => '0.5', :label => '\N', :pos => '35,18', :width => '0.97222' )
101
+ node_hello = graph_g.add_nodes( "Hello", :height => '0.5', :label => '\N', :pos => '35,90', :width => '0.88889' )
102
+ graph_g.add_edges( "Hello", "World", :pos => 'e,35,36.413 35,71.831 35,64.131 35,54.974 35,46.417' )
103
+ node_world = graph_g.add_nodes( "World", :height => '0.5', :label => '\N', :pos => '35,18', :width => '0.97222' )
339
104
  }
340
105
  puts graph_g.output( :canon => String )
341
106
 
data/Rakefile CHANGED
@@ -27,7 +27,7 @@ RDoc::Task.new do |rdoc|
27
27
  rdoc.options += RDOC_OPTS
28
28
  rdoc.main = "README.rdoc"
29
29
  rdoc.title = "Ruby/GraphViz, the Documentation"
30
- rdoc.rdoc_files.add ['README.rdoc', 'AUTHORS', 'COPYING',
30
+ rdoc.rdoc_files.add ['README.rdoc', 'CHANGELOG.rdoc', 'AUTHORS.rdoc', 'COPYING.rdoc',
31
31
  'lib/graphviz.rb',
32
32
  'lib/graphviz/node.rb',
33
33
  'lib/graphviz/edge.rb',
@@ -4,7 +4,7 @@ $:.unshift( "../../lib" );
4
4
  require "graphviz"
5
5
 
6
6
  Dir.glob( "*.dot" ) { |f|
7
- print "#{f} : "
7
+ puts "#{f} : "
8
8
  begin
9
9
  puts GraphViz.parse(f)
10
10
  rescue SyntaxError => e
data/examples/sample15.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  $:.unshift( "../lib" );
7
7
  require "graphviz"
8
8
 
9
- GraphViz::new( "G", :type => "graph", :use => "fdp" ) { |graph|
9
+ g = GraphViz::new( "G", :type => "graph", :use => "fdp" ) { |graph|
10
10
  graph.e
11
11
  graph.clusterA { |cA|
12
12
  cA.a << cA.b
@@ -20,4 +20,6 @@ GraphViz::new( "G", :type => "graph", :use => "fdp" ) { |graph|
20
20
  graph.clusterB.d << graph.clusterA.clusterC._d
21
21
  graph.e << graph.clusterB
22
22
  graph.clusterA.clusterC << graph.clusterB
23
- }.output( :path => '/usr/local/bin/', :png => "#{$0}.png" )
23
+ }
24
+
25
+ g.output( :path => '/usr/local/bin/', :png => "#{$0}.png" )
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/ruby
2
+
3
+ $:.unshift( "../lib" );
4
+ require "graphviz"
5
+
6
+ g = GraphViz::new( "G", :type => "graph" )
7
+ g[:compound] = true
8
+ g[:rankdir] = "LR"
9
+
10
+ c0 = g.add_graph( "cluster0", "label" => "cluster #1" )
11
+ a0 = c0.add_nodes( "a0" )
12
+
13
+ c1 = g.add_graph( "cluster1", "label" => "cluster #2" )
14
+ b0 = c1.add_nodes( "b0" )
15
+
16
+ e1 = g.add_edges(a0,b0)
17
+ e1[:lhead] = c1.id
18
+ e1[:ltail] = c0.id
19
+
20
+ e2 = g.add_edges(a0,b0)
21
+ e2[:lhead] = c1.id
22
+
23
+ g.output( :png => "#{$0}.png" )
@@ -14,15 +14,18 @@
14
14
  # along with this program; if not, write to the Free Software
15
15
  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
16
 
17
+ class AttributeException < RuntimeError
18
+ end
19
+
17
20
  class GraphViz
18
21
  class Attrs
19
22
  attr_accessor :data
20
23
 
21
- def initialize( gviz, name, attributs )
22
- @name = name
23
- @attributs = attributs
24
- @data = Hash::new( )
25
- @graphviz = gviz
24
+ def initialize( gviz, name, attributes )
25
+ @name = name
26
+ @attributes = attributes
27
+ @data = Hash::new( )
28
+ @graphviz = gviz
26
29
  end
27
30
 
28
31
  def each
@@ -49,14 +52,21 @@ class GraphViz
49
52
  end
50
53
 
51
54
  def []=( key, value )
52
- unless @attributs.keys.include?( key.to_s )
53
- raise ArgumentError, "#{@name} attribut '#{key.to_s}' invalid"
55
+ unless @attributes.keys.include?( key.to_s )
56
+ raise ArgumentError, "#{@name} attribute '#{key.to_s}' invalid"
54
57
  end
55
58
 
56
- @data[key.to_s] = GraphViz::Types.const_get(@attributs[key.to_s]).new( value )
59
+ begin
60
+ value = GraphViz::Types.const_get(@attributes[key.to_s]).new( value )
61
+ rescue => e
62
+ raise AttributeException, "Invalide value `#{value}` for attribute `#{key}` : #{e}"
63
+ end
64
+ unless value.nil?
65
+ @data[key.to_s] = value
57
66
 
58
- if @graphviz.nil? == false
59
- @graphviz.set_position( @name, key.to_s, @data[key.to_s] )
67
+ if @graphviz.nil? == false
68
+ @graphviz.set_position( @name, key.to_s, @data[key.to_s] )
69
+ end
60
70
  end
61
71
  end
62
72
  end
@@ -40,7 +40,7 @@
40
40
  # C => cluster
41
41
  #
42
42
  module Constants
43
- RGV_VERSION = "1.0.3"
43
+ RGV_VERSION = "1.0.4"
44
44
 
45
45
  ## Const: Output formats
46
46
  FORMATS = [
@@ -276,12 +276,12 @@ module Constants
276
276
  "z" => { :usedBy => "N", :type => :GvDouble }
277
277
  }
278
278
 
279
- ## Const: Graph attributs
279
+ ## Const: Graph attributes
280
280
  GRAPHSATTRS = Constants::getAttrsFor( /G|S|C/ )
281
281
 
282
- ## Const: Node attributs
282
+ ## Const: Node attributes
283
283
  NODESATTRS = Constants::getAttrsFor( /N/ )
284
284
 
285
- ## Const: Edge attributs
285
+ ## Const: Edge attributes
286
286
  EDGESATTRS = Constants::getAttrsFor( /E/ )
287
287
  end
data/lib/graphviz/edge.rb CHANGED
@@ -32,7 +32,7 @@ class GraphViz
32
32
  @node_two_id, @node_two_port = getNodeNameAndPort( vNodeTwo )
33
33
 
34
34
  @parent_graph = parent_graph
35
- @edge_attributs = GraphViz::Attrs::new( nil, "edge", EDGESATTRS )
35
+ @edge_attributes = GraphViz::Attrs::new( nil, "edge", EDGESATTRS )
36
36
  @index = nil
37
37
 
38
38
  unless @parent_graph.directed?
@@ -71,23 +71,23 @@ class GraphViz
71
71
  @index = i if @index == nil
72
72
  end
73
73
 
74
- # Set value +attribut_value+ to the edge attribut +attribut_name+
75
- def []=( attribut_name, attribut_value )
76
- attribut_value = attribut_value.to_s if attribut_value.class == Symbol
77
- @edge_attributs[attribut_name.to_s] = attribut_value
74
+ # Set value +attribute_value+ to the edge attribute +attribute_name+
75
+ def []=( attribute_name, attribute_value )
76
+ attribute_value = attribute_value.to_s if attribute_value.class == Symbol
77
+ @edge_attributes[attribute_name.to_s] = attribute_value
78
78
  end
79
79
 
80
- # Set values for edge attributs or
81
- # get the value of the given edge attribut +attribut_name+
82
- def []( attribut_name )
80
+ # Set values for edge attributes or
81
+ # get the value of the given edge attribute +attribute_name+
82
+ def []( attribute_name )
83
83
  # Modification by axgle (http://github.com/axgle)
84
- if Hash === attribut_name
85
- attribut_name.each do |key, value|
84
+ if Hash === attribute_name
85
+ attribute_name.each do |key, value|
86
86
  self[key] = value
87
87
  end
88
88
  else
89
- if @edge_attributs[attribut_name.to_s]
90
- @edge_attributs[attribut_name.to_s].clone
89
+ if @edge_attributes[attribute_name.to_s]
90
+ @edge_attributes[attribute_name.to_s].clone
91
91
  else
92
92
  nil
93
93
  end
@@ -95,13 +95,13 @@ class GraphViz
95
95
  end
96
96
 
97
97
  #
98
- # Calls block once for each attribut of the edge, passing the name and value to the
98
+ # Calls block once for each attribute of the edge, passing the name and value to the
99
99
  # block as a two-element array.
100
100
  #
101
- # If global is set to false, the block does not receive the attributs set globally
101
+ # If global is set to false, the block does not receive the attributes set globally
102
102
  #
103
- def each_attribut(global = true, &b)
104
- attrs = @edge_attributs.to_h
103
+ def each_attribute(global = true, &b)
104
+ attrs = @edge_attributes.to_h
105
105
  if global
106
106
  attrs = pg.edge.to_h.merge attrs
107
107
  end
@@ -109,6 +109,10 @@ class GraphViz
109
109
  yield(k,v)
110
110
  end
111
111
  end
112
+ def each_attribut(global = true, &b)
113
+ warn "`GraphViz::Edge#each_attribut` is deprecated, please use `GraphViz::Edge#each_attribute`"
114
+ each_attribute(global, &b)
115
+ end
112
116
 
113
117
  def <<( node ) #:nodoc:
114
118
  n = @parent_graph.get_node(@node_two_id)
@@ -130,7 +134,7 @@ class GraphViz
130
134
  @parent_graph
131
135
  end
132
136
 
133
- # Set edge attributs
137
+ # Set edge attributes
134
138
  #
135
139
  # Example :
136
140
  # e = graph.add_edges( ... )
@@ -161,7 +165,7 @@ class GraphViz
161
165
  xOut = self.node_one + xLink + self.node_two
162
166
  xAttr = ""
163
167
  xSeparator = ""
164
- @edge_attributs.data.each do |k, v|
168
+ @edge_attributes.data.each do |k, v|
165
169
  xAttr << xSeparator + k + " = " + v.to_gv
166
170
  xSeparator = ", "
167
171
  end
@@ -20,7 +20,11 @@ require 'rexml/document'
20
20
 
21
21
  class GraphViz
22
22
  class GraphML
23
- attr_reader :attributs
23
+ attr_reader :attributes
24
+ def attributs
25
+ warn "`GraphViz::GraphML#attributs` is deprecated, please, use `GraphViz::GraphML#attributes`"
26
+ return @attributes
27
+ end
24
28
 
25
29
  # The GraphViz object
26
30
  attr_accessor :graph
@@ -41,7 +45,7 @@ class GraphViz
41
45
  def initialize( file_or_str )
42
46
  data = ((File.file?( file_or_str )) ? File::new(file_or_str) : file_or_str)
43
47
  @xmlDoc = REXML::Document::new( data )
44
- @attributs = {
48
+ @attributes = {
45
49
  :nodes => {},
46
50
  :edges => {},
47
51
  :graphs => {}
@@ -80,7 +84,7 @@ class GraphViz
80
84
  :type => node.attributes['attr.type']
81
85
  }
82
86
  DEST[node.attributes['for']].each do |d|
83
- @attributs[d][id] = @current_attr
87
+ @attributes[d][id] = @current_attr
84
88
  end
85
89
 
86
90
  node.each_element( ) do |child|
@@ -110,13 +114,13 @@ class GraphViz
110
114
  @current_graph = previous_graph.add_graph( node.attributes['id'] )
111
115
  end
112
116
 
113
- @attributs[:graphs].each do |id, data|
117
+ @attributes[:graphs].each do |id, data|
114
118
  @current_graph.graph[data[:name]] = data[:default] if data.has_key?(:default)
115
119
  end
116
- @attributs[:nodes].each do |id, data|
120
+ @attributes[:nodes].each do |id, data|
117
121
  @current_graph.node[data[:name]] = data[:default] if data.has_key?(:default)
118
122
  end
119
- @attributs[:edges].each do |id, data|
123
+ @attributes[:edges].each do |id, data|
120
124
  @current_graph.edge[data[:name]] = data[:default] if data.has_key?(:default)
121
125
  end
122
126
 
@@ -132,7 +136,7 @@ class GraphViz
132
136
  end
133
137
 
134
138
  def graphml_graph_data( node ) #:nodoc:
135
- @current_graph[@attributs[:graphs][node.attributes['key']][:name]] = node.texts().to_s
139
+ @current_graph[@attributes[:graphs][node.attributes['key']][:name]] = node.texts().to_s
136
140
  end
137
141
 
138
142
  def graphml_graph_node( node ) #:nodoc:
@@ -162,7 +166,8 @@ class GraphViz
162
166
  end
163
167
 
164
168
  def graphml_graph_node_data( node ) #:nodoc:
165
- @current_node[@attributs[:nodes][node.attributes['key']][:name]] = node.texts().to_s
169
+ #@current_node[@attributes[:nodes][node.attributes['key']][:name]] = node.texts().to_s
170
+ @current_node[@attributes[:nodes][node.attributes['key']][:name]] = node.texts().join(sep='\n',)
166
171
  end
167
172
 
168
173
  def graphml_graph_node_port( node ) #:nodoc:
@@ -196,7 +201,7 @@ class GraphViz
196
201
  end
197
202
 
198
203
  def graphml_graph_edge_data( node ) #:nodoc:
199
- @current_edge[@attributs[:edges][node.attributes['key']][:name]] = node.texts().to_s
204
+ @current_edge[@attributes[:edges][node.attributes['key']][:name]] = node.texts().to_s
200
205
  end
201
206
 
202
207
  def graphml_graph_hyperedge( node ) #:nodoc:
data/lib/graphviz/node.rb CHANGED
@@ -35,7 +35,7 @@ class GraphViz
35
35
  @incidents = []
36
36
  @node_id = node_id
37
37
  @parent_graph = parent_graph
38
- @node_attributs = GraphViz::Attrs::new( nil, "node", NODESATTRS )
38
+ @node_attributes = GraphViz::Attrs::new( nil, "node", NODESATTRS )
39
39
  @index = nil
40
40
  end
41
41
 
@@ -57,30 +57,30 @@ class GraphViz
57
57
  return( (self.pg.nil?) ? nil : self.pg.root_graph )
58
58
  end
59
59
 
60
- # Set value +attribut_value+ to the node attribut +attribut_name+
61
- def []=( attribut_name, attribut_value )
62
- attribut_value = attribut_value.to_s if attribut_value.class == Symbol
63
- @node_attributs[attribut_name.to_s] = attribut_value
60
+ # Set value +attribute_value+ to the node attribute +attribute_name+
61
+ def []=( attribute_name, attribute_value )
62
+ attribute_value = attribute_value.to_s if attribute_value.class == Symbol
63
+ @node_attributes[attribute_name.to_s] = attribute_value
64
64
  end
65
65
 
66
- # Get the value of the node attribut +attribut_name+
67
- def []( attribut_name )
68
- if Hash === attribut_name
69
- attribut_name.each do |key, value|
66
+ # Get the value of the node attribute +attribute_name+
67
+ def []( attribute_name )
68
+ if Hash === attribute_name
69
+ attribute_name.each do |key, value|
70
70
  self[key] = value
71
71
  end
72
72
  return self
73
73
  else
74
- (@node_attributs[attribut_name.to_s].nil?)?nil:@node_attributs[attribut_name.to_s].clone
74
+ (@node_attributes[attribute_name.to_s].nil?)?nil:@node_attributes[attribute_name.to_s].clone
75
75
  end
76
76
  end
77
77
 
78
- # Calls block once for each attribut of the node, passing the name and value to the
78
+ # Calls block once for each attribute of the node, passing the name and value to the
79
79
  # block as a two-element array.
80
80
  #
81
- # If global is set to false, the block does not receive the attributs set globally
82
- def each_attribut(global = true, &b)
83
- attrs = @node_attributs.to_h
81
+ # If global is set to false, the block does not receive the attributes set globally
82
+ def each_attribute(global = true, &b)
83
+ attrs = @node_attributes.to_h
84
84
  if global
85
85
  attrs = pg.node.to_h.merge attrs
86
86
  end
@@ -88,6 +88,10 @@ class GraphViz
88
88
  yield(k,v)
89
89
  end
90
90
  end
91
+ def each_attribut(global = true, &b)
92
+ warn "`GraphViz::Node#each_attribut` is deprecated, please use `GraphViz::Node#each_attribute`"
93
+ each_attribute(global, &b)
94
+ end
91
95
 
92
96
  # Create an edge between the current node and the node +node+
93
97
  def <<( node )
@@ -103,7 +107,7 @@ class GraphViz
103
107
  alias :- :<<
104
108
  alias :>> :<<
105
109
 
106
- # Set node attributs
110
+ # Set node attributes
107
111
  #
108
112
  # Example :
109
113
  # n = graph.add_nodes( ... )
@@ -138,10 +142,10 @@ class GraphViz
138
142
  xAttr = ""
139
143
  xSeparator = ""
140
144
 
141
- if @node_attributs.data.has_key?("label") and @node_attributs.data.has_key?("html")
142
- @node_attributs.data.delete("label")
145
+ if @node_attributes.data.has_key?("label") and @node_attributes.data.has_key?("html")
146
+ @node_attributes.data.delete("label")
143
147
  end
144
- @node_attributs.data.each do |k, v|
148
+ @node_attributes.data.each do |k, v|
145
149
  xAttr << xSeparator + k + " = " + v.to_gv
146
150
  xSeparator = ", "
147
151
  end
@@ -11,6 +11,8 @@ class GraphViz
11
11
 
12
12
  def check(data)
13
13
  data = data.to_s if data.is_a?(Symbol)
14
+ return nil if data.empty?
15
+
14
16
  if data[0].chr == "#"
15
17
  m = RGBA.match(data)
16
18
  if m.nil?
@@ -3,6 +3,8 @@ class GraphViz
3
3
  class ColorList < Common
4
4
  def check(data)
5
5
  data = data.to_s if data.is_a?(Symbol)
6
+ return nil if data.empty?
7
+
6
8
  @to_ruby = data.split(/\s*:\s*/).map { |c| GraphViz::Types::Color.new(c).to_ruby }
7
9
  return data
8
10
  end