ruby-graphviz 0.9.11 → 0.9.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/README.rdoc +49 -7
- data/bin/ruby2gv +2 -2
- data/examples/sample07.rb +2 -2
- data/examples/sample08.rb +7 -7
- data/examples/sample30.rb +1 -1
- data/examples/sample39.rb +11 -0
- data/examples/sample40.rb +13 -42
- data/examples/sample41.rb +8 -0
- data/examples/{p2p.rb → sample42.rb} +1 -1
- data/examples/{HTML-Labels.rb → sample43.rb} +2 -2
- data/examples/{arrowhead.rb → sample44.rb} +0 -0
- data/examples/{shapes.rb → sample45.rb} +1 -1
- data/examples/{testorder.rb → sample46.rb} +0 -0
- data/examples/{testxml.rb → sample47.rb} +1 -1
- data/examples/{graphviz.org/cluster.rb → sample48.rb} +1 -1
- data/examples/{graphviz.org/hello_world.rb → sample49.rb} +1 -1
- data/examples/{graphviz.org/lion_share.rb → sample50.rb} +1 -1
- data/examples/{graphviz.org/process.rb → sample51.rb} +1 -1
- data/examples/{graphviz.org/TrafficLights.rb → sample52.rb} +1 -1
- data/examples/sample53.rb +26 -0
- data/examples/sample54.rb +26 -0
- data/examples/sample99.rb +70 -0
- data/lib/graphviz.rb +31 -8
- data/lib/graphviz/attrs.rb +1 -1
- data/lib/graphviz/constants.rb +2 -2
- data/lib/graphviz/edge.rb +44 -20
- data/lib/graphviz/family_tree.rb +56 -5
- data/lib/graphviz/family_tree/couple.rb +16 -6
- data/lib/graphviz/family_tree/generation.rb +19 -5
- data/lib/graphviz/family_tree/person.rb +39 -13
- data/lib/graphviz/family_tree/sibling.rb +13 -0
- data/lib/graphviz/node.rb +11 -3
- data/lib/graphviz/nothugly.rb +42 -0
- data/lib/graphviz/nothugly/nothugly.xsl +321 -0
- data/lib/graphviz/parser.rb +1 -1
- data/lib/graphviz/xml.rb +1 -1
- data/test/test_examples.rb +4 -0
- metadata +44 -58
- data/examples/maketest.bat +0 -109
- data/examples/maketest.sh +0 -109
- data/examples/sample30.rb.ps +0 -923
- data/examples/sample37.rb.dot +0 -50
- data/examples/sample37.rb.png +0 -0
- data/test/output/sample01.rb.png +0 -0
- data/test/output/sample02.rb.png +0 -0
- data/test/output/sample03.rb.png +0 -0
- data/test/output/sample04.rb.png +0 -0
- data/test/output/sample05.rb.png +0 -0
- data/test/output/sample06.rb.png +0 -0
- data/test/output/sample07.rb.png +0 -0
- data/test/output/sample08.rb.png +0 -0
- data/test/output/sample09.rb.png +0 -0
- data/test/output/sample10.rb.png +0 -0
- data/test/output/sample11.rb.png +0 -0
- data/test/output/sample12.rb.png +0 -0
- data/test/output/sample13.rb.png +0 -0
- data/test/output/sample14.rb.png +0 -0
- data/test/output/sample15.rb.png +0 -0
- data/test/output/sample16.rb.png +0 -0
- data/test/output/sample17.rb.png +0 -0
- data/test/output/sample18.rb.png +0 -0
- data/test/output/sample19.rb.png +0 -0
- data/test/output/sample20.rb.png +0 -0
- data/test/output/sample21.rb.html +0 -3
- data/test/output/sample21.rb.png +0 -0
- data/test/output/sample22.rb.html +0 -5
- data/test/output/sample22.rb.png +0 -0
- data/test/output/sample23.rb.png +0 -0
- data/test/output/sample24.rb.png +0 -0
- data/test/output/sample25.rb.png +0 -0
- data/test/output/sample26.rb.png +0 -0
- data/test/output/sample28.rb.png +0 -0
- data/test/output/sample29.rb.svg +0 -21
- data/test/output/sample30.rb.ps +0 -268
- data/test/output/sample31.rb.png +0 -0
- data/test/output/sample32.rb.png +0 -0
- data/test/output/sample37.rb.dot +0 -50
- data/test/output/sample37.rb.png +0 -0
- data/test/output/sample38.rb.png +0 -0
- data/test/output/sample40.rb.png +0 -0
data/AUTHORS
CHANGED
data/README.rdoc
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
= Ruby/GraphViz
|
2
2
|
|
3
|
-
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune
|
3
|
+
Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Gregoire Lejeune
|
4
4
|
|
5
5
|
* Doc : http://rdoc.info/projects/glejeune/Ruby-Graphviz
|
6
6
|
* Sources : http://github.com/glejeune/Ruby-Graphviz
|
7
|
-
*
|
7
|
+
* <b>NEW</b> - Mailing List : http://groups.google.com/group/ruby-graphviz
|
8
8
|
|
9
9
|
== DESCRIPTION
|
10
10
|
|
@@ -12,12 +12,21 @@ Interface to the GraphViz graphing tool
|
|
12
12
|
|
13
13
|
== CHANGELOG
|
14
14
|
|
15
|
+
=== 0.9.12 :
|
16
|
+
* GraphViz::Node#name is deprecated, you must use GraphViz::Node#id (issue #14)
|
17
|
+
* Add :nothugly option to GraphViz#output (see sample41.rb and http://www.hokstad.com/making-graphviz-output-pretty-with-xsl.html)
|
18
|
+
* Issue #13 : you must now specify a port in GraphViz::Edge.new with a syntax like this :
|
19
|
+
GraphViz::Edge.new( {nodeOne => :port}, {nodeTwo => :other} )
|
20
|
+
* Issue #12 : UTF8 support (see sample38.rb)
|
21
|
+
* Move and rename examples + remove maketest.[sh|bat]
|
22
|
+
* <b>WARNING</b> : FamilyTree is broken in this version !
|
23
|
+
* TODO: GraphViz::Parser support block
|
24
|
+
|
15
25
|
=== 0.9.11 :
|
16
26
|
* Issue #11 : Cygwin PATH
|
17
27
|
* Major bugs correction in output
|
18
28
|
* Bug correction in find_executable
|
19
29
|
* Add tests (by Chip Malice : http://github.com/hipe)
|
20
|
-
* TODO: GraphViz::Parser support block
|
21
30
|
* TODO: Issue #12
|
22
31
|
|
23
32
|
=== 0.9.10 :
|
@@ -90,8 +99,8 @@ Interface to the GraphViz graphing tool
|
|
90
99
|
* Bug correction in GraphViz.output (sample 19)
|
91
100
|
* Add GraphViz#default to set default options (:use, :path and :output)
|
92
101
|
* Add possibility to set node or edge attribut via :
|
93
|
-
|
94
|
-
|
102
|
+
node.<attribut>=<value> or node.<attribut>( <value> )
|
103
|
+
edge.<attribut>=<value> or edge.<attribut>( <value> )
|
95
104
|
* Add GraphViz::Edge.set and GraphViz::Node.set
|
96
105
|
* Add sample 20
|
97
106
|
* Add GraphViz.node_count and GraphViz.edge_count by Daniel Cadenas Nión
|
@@ -174,11 +183,39 @@ Ruby/GraphViz also include :
|
|
174
183
|
|
175
184
|
* ruby2gv, a simple tool that's allow you to create a dependency graph from a ruby script. Example : http://drp.ly/dShaZ
|
176
185
|
|
177
|
-
|
186
|
+
ruby2gv -Tpng -oruby2gv.png ruby2gv
|
178
187
|
|
179
188
|
* gem2gv, a tools that's allow you to create a dependency graph between gems. Example : http://drp.ly/dSj9Y
|
180
189
|
|
181
|
-
|
190
|
+
gem2gv -Tpng -oruby-graphviz.png ruby-graphviz
|
191
|
+
|
192
|
+
At last, you can create familly tree with GraphViz::FamilyTree (<b>beta</b>) :
|
193
|
+
|
194
|
+
require 'graphviz/family_tree'
|
195
|
+
|
196
|
+
tree = GraphViz::FamilyTree.new do
|
197
|
+
generation do
|
198
|
+
benoist.is_a_man( "Benoist" )
|
199
|
+
nathalie.is_a_woman( "Nathalie" )
|
200
|
+
|
201
|
+
benoist.is_maried_with nathalie
|
202
|
+
end
|
203
|
+
|
204
|
+
generation do
|
205
|
+
charlotte.is_a_woman( "Charlotte" )
|
206
|
+
amelie.is_a_woman( "Amelie" )
|
207
|
+
clement.is_a_man( "Clement" )
|
208
|
+
gregoire.is_a_man( "Gregoire" )
|
209
|
+
|
210
|
+
muriel.is_a_woman( "Muriel" )
|
211
|
+
|
212
|
+
gregoire.is_maried_with muriel
|
213
|
+
end
|
214
|
+
|
215
|
+
couple( benoist, nathalie ).kids( charlotte, amelie, clement, gregoire )
|
216
|
+
end
|
217
|
+
|
218
|
+
tree.graph.save( :png => "#{$0}.png" )
|
182
219
|
|
183
220
|
== INSTALLATION
|
184
221
|
|
@@ -195,3 +232,8 @@ GNU General Public License (see the file 'COPYING').
|
|
195
232
|
|
196
233
|
This program is distributed without any warranty. See the file
|
197
234
|
'COPYING' for details.
|
235
|
+
|
236
|
+
=== nothugly.xsl
|
237
|
+
|
238
|
+
By Vidar Hokstad and Ryan Shea; Contributions by Jonas Tingborn,
|
239
|
+
Earl Cummings, Michael Kennedy (Graphviz 2.20.2 compatibility, bug fixes, testing, lots of gradients)
|
data/bin/ruby2gv
CHANGED
@@ -142,9 +142,9 @@ class Rb2Gv
|
|
142
142
|
end
|
143
143
|
|
144
144
|
puts " + Edge #{xLib} -> #{xRequiredLib}" if DEBUG
|
145
|
-
unless @hxEdge.include?( "#{@hxNodes[xLib].
|
145
|
+
unless @hxEdge.include?( "#{@hxNodes[xLib].id}-#{@hxNodes[xRequiredLib].id}" )
|
146
146
|
@oGraph.add_edge( @hxNodes[xLib], @hxNodes[xRequiredLib] )
|
147
|
-
@hxEdge << "#{@hxNodes[xLib].
|
147
|
+
@hxEdge << "#{@hxNodes[xLib].id}-#{@hxNodes[xRequiredLib].id}"
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
data/examples/sample07.rb
CHANGED
@@ -17,7 +17,7 @@ g.add_node( "struct1", "shape" => "record", "label" => "<f0> left|<f1> middle|<f
|
|
17
17
|
g.add_node( "struct2", "shape" => "record", "label" => "<f0> one|<f1> two" )
|
18
18
|
g.add_node( "struct3", "shape" => "record", "label" => 'hello\nworld |{ b |{c|<here> d|e}| f}| g | h' )
|
19
19
|
|
20
|
-
g.add_edge( "struct1:f1
|
21
|
-
g.add_edge( "struct1:f2
|
20
|
+
g.add_edge( { "struct1" => :f1}, {"struct2" => :f0} )
|
21
|
+
g.add_edge( {"struct1" => :f2}, {"struct3" => :here} )
|
22
22
|
|
23
23
|
g.output( :png => "#{$0}.png", :canon => nil )
|
data/examples/sample08.rb
CHANGED
@@ -23,12 +23,12 @@ g.add_node( "node5", "label" => "{<n> t20 | 959 |<p> }", "width" => "1.5" )
|
|
23
23
|
g.add_node( "node6", "label" => "{<n> o15 | 794 |<p> }", "width" => "1.5" )
|
24
24
|
g.add_node( "node7", "label" => "{<n> s19 | 659 |<p> }", "width" => "1.5" )
|
25
25
|
|
26
|
-
g.add_edge( "node0:f0
|
27
|
-
g.add_edge( "node0:f1
|
28
|
-
g.add_edge( "node0:f2
|
29
|
-
g.add_edge( "node0:f5
|
30
|
-
g.add_edge( "node0:f6
|
31
|
-
g.add_edge( "node2:p
|
32
|
-
g.add_edge( "node4:p
|
26
|
+
g.add_edge( {"node0" => :f0}, {"node1" => :n} )
|
27
|
+
g.add_edge( {"node0" => :f1}, {"node2" => :n} )
|
28
|
+
g.add_edge( {"node0" => :f2}, {"node3" => :n} )
|
29
|
+
g.add_edge( {"node0" => :f5}, {"node4" => :n} )
|
30
|
+
g.add_edge( {"node0" => :f6}, {"node5" => :n} )
|
31
|
+
g.add_edge( {"node2" => :p}, {"node6" => :n} )
|
32
|
+
g.add_edge( {"node4" => :p}, {"node7" => :n} )
|
33
33
|
|
34
34
|
g.output( :png => "#{$0}.png" )
|
data/examples/sample30.rb
CHANGED
@@ -9,4 +9,4 @@ GraphViz.new(:g){ |g|
|
|
9
9
|
b = g.add_node("B", :shape => "sdl_save", :peripheries => 0)
|
10
10
|
c = g.add_node("n", :shape => "box", :label => "\\G::\\N\\r")
|
11
11
|
a << b << c
|
12
|
-
}.save( :ps => "#{$0}.ps", :extlib => "sdlshapes
|
12
|
+
}.save( :ps => "#{$0}.ps", :extlib => File.join( File.dirname(__FILE__), "sdlshapes", "sdl.ps" ) )
|
@@ -0,0 +1,11 @@
|
|
1
|
+
$:.unshift( "../lib" );
|
2
|
+
require "graphviz"
|
3
|
+
|
4
|
+
g = GraphViz::new( "G", :type => "graph" )
|
5
|
+
n1 = g.add_node( "A" )
|
6
|
+
n2 = g.add_node( "B" )
|
7
|
+
n3 = g.add_node( "C" )
|
8
|
+
e1 = g.add_edge( n1, n2 )
|
9
|
+
e1[:dir] = 'forward'
|
10
|
+
e2 = g.add_edge( n1, n3 )
|
11
|
+
g.output( :png => "#{$0}.png" )
|
data/examples/sample40.rb
CHANGED
@@ -1,46 +1,17 @@
|
|
1
1
|
$:.unshift( "../lib" );
|
2
|
-
require
|
2
|
+
require "graphviz"
|
3
3
|
|
4
|
-
|
5
|
-
generation do
|
6
|
-
benoist.is_a_man( "Benoist" )
|
7
|
-
nathalie.is_a_woman( "Nathalie" )
|
8
|
-
|
9
|
-
benoist.is_maried_with nathalie
|
10
|
-
|
11
|
-
michel.is_a_man( "Michel" )
|
12
|
-
brigitte.is_a_woman( "Brigitte" )
|
13
|
-
|
14
|
-
michel.is_maried_with brigitte
|
15
|
-
end
|
16
|
-
|
17
|
-
generation do
|
18
|
-
charlotte.is_a_woman( "Charlotte" )
|
19
|
-
amelie.is_a_woman( "Amelie" )
|
20
|
-
clement.is_a_man( "Clement" )
|
21
|
-
gregoire.is_a_man( "Gregoire" )
|
22
|
-
|
23
|
-
muriel.is_a_woman( "Muriel" )
|
24
|
-
gilles.is_a_man( "Gilles" )
|
4
|
+
graph = GraphViz.new( :G, :type => :digraph )
|
25
5
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
couple( michel, brigitte ).kids( muriel, gilles )
|
30
|
-
couple( benoist, nathalie ).kids( charlotte, amelie, clement, gregoire )
|
31
|
-
|
32
|
-
generation do
|
33
|
-
arthur.is_a_boy( "Arthur" )
|
34
|
-
colyne.is_a_girl( "Colyne" )
|
35
|
-
benedict.is_a_boy( "Benedict" )
|
36
|
-
maia.is_a_girl( "Maia" )
|
37
|
-
enaitz.is_a_boy( "Enaitz" )
|
38
|
-
milo.is_a_boy( "Milo" )
|
39
|
-
end
|
40
|
-
|
41
|
-
gregoire.kids( arthur, colyne, benedict )
|
42
|
-
couple( gregoire, muriel ).kids( maia )
|
43
|
-
muriel.kids( enaitz, milo )
|
44
|
-
end
|
6
|
+
node1 = graph.add_node("hello:world",
|
7
|
+
"shape" => "record",
|
8
|
+
"label" => "<left>|<f1> 1|<right>" )
|
45
9
|
|
46
|
-
|
10
|
+
node2 = graph.add_node("2",
|
11
|
+
"shape" => "record",
|
12
|
+
"label" => "<left>|<f1> 2|<right>" )
|
13
|
+
|
14
|
+
graph.add_edge( {node1 => :left}, node2 )
|
15
|
+
graph.add_edge( {node2 => :right}, node1 )
|
16
|
+
|
17
|
+
puts graph.output( :none => String, :png => "#{$0}.png" )
|
@@ -19,8 +19,8 @@ g.add_node( "struct1", "html" => '
|
|
19
19
|
g.add_node( "struct2", "html" => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0"> <TR><TD PORT="f0">one</TD><TD>two</TD></TR> </TABLE>' )
|
20
20
|
g.add_node( "struct3", "html" => '<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4"> <TR> <TD ROWSPAN="3">hello<BR/>world</TD> <TD COLSPAN="3">b</TD> <TD ROWSPAN="3">g</TD> <TD ROWSPAN="3">h</TD> </TR> <TR> <TD>c</TD><TD PORT="here">d</TD><TD>e</TD> </TR> <TR> <TD COLSPAN="3">f</TD> </TR> </TABLE>' )
|
21
21
|
|
22
|
-
g.add_edge( "struct1:f1
|
23
|
-
g.add_edge( "struct1:f2
|
22
|
+
g.add_edge( {"struct1" => :f1}, {"struct2" => :f0} )
|
23
|
+
g.add_edge( {"struct1" => :f2}, {"struct3" => :here} )
|
24
24
|
|
25
25
|
g.add_edge( "HTML", "struct1" )
|
26
26
|
|
File without changes
|
File without changes
|
@@ -3,5 +3,5 @@
|
|
3
3
|
$:.unshift( "../lib" )
|
4
4
|
require 'graphviz/xml'
|
5
5
|
|
6
|
-
gvxml = GraphViz::XML::new( "test.xml", :text => true, :attrs => true )
|
6
|
+
gvxml = GraphViz::XML::new( File.join( File.dirname(__FILE__), "test.xml" ), :text => true, :attrs => true )
|
7
7
|
gvxml.output( :png => "#{$0}.png", :use => "dot" )
|
@@ -212,4 +212,4 @@ GraphViz::new( "Ped_Lion_Share", :type => :digraph ) { |g|
|
|
212
212
|
(g._026 << g.marr0017).set { |e| e[:dir] = :none; e[:weight] = 1 }
|
213
213
|
(g._027 << g.marr0017).set { |e| e[:dir] = :none; e[:weight] = 1 }
|
214
214
|
(g.marr0017 << g._028).set { |e| e[:dir] = :none; e[:weight] = 2 }
|
215
|
-
}.output( :png => "
|
215
|
+
}.output( :png => "#{$0}.png" )
|
@@ -59,4 +59,4 @@ GraphViz::new( "TrafficLights", :type => :digraph ) { |g|
|
|
59
59
|
g[:overlap] = :false
|
60
60
|
g[:label] = 'PetriNet Model TrafficLights\nExtracted from ConceptBase and layed out by Graphviz'
|
61
61
|
g[:fontsize] = 12;
|
62
|
-
}.output( :errors => 1, :png => "
|
62
|
+
}.output( :errors => 1, :png => "#{$0}.png" )
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.unshift( "../lib" )
|
2
|
+
require 'graphviz/family_tree'
|
3
|
+
|
4
|
+
tree = GraphViz::FamilyTree.new do
|
5
|
+
generation do
|
6
|
+
benoist.is_a_man( "Benoist" )
|
7
|
+
nathalie.is_a_woman( "Nathalie" )
|
8
|
+
|
9
|
+
benoist.is_maried_with nathalie
|
10
|
+
end
|
11
|
+
|
12
|
+
generation do
|
13
|
+
charlotte.is_a_woman( "Charlotte" )
|
14
|
+
amelie.is_a_woman( "Amelie" )
|
15
|
+
clement.is_a_man( "Clement" )
|
16
|
+
gregoire.is_a_man( "Gregoire" )
|
17
|
+
|
18
|
+
muriel.is_a_woman( "Muriel" )
|
19
|
+
|
20
|
+
gregoire.is_maried_with muriel
|
21
|
+
end
|
22
|
+
|
23
|
+
couple( benoist, nathalie ).kids( charlotte, amelie, clement, gregoire )
|
24
|
+
end
|
25
|
+
|
26
|
+
tree.graph.save( :png => "#{$0}.png" )
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$:.unshift( "../lib" )
|
2
|
+
require 'graphviz'
|
3
|
+
|
4
|
+
class Array
|
5
|
+
def rotate
|
6
|
+
## Solution #1 by greg
|
7
|
+
# self.push(r = self.shift)
|
8
|
+
# return r
|
9
|
+
|
10
|
+
## Solution #2 by madx
|
11
|
+
# shift.tap {|e| push e }
|
12
|
+
|
13
|
+
## Solution #3 by greg
|
14
|
+
push(shift)[-1]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
type = ["box", "point"]
|
19
|
+
|
20
|
+
GraphViz.graph( :G, :use => :neato ) { |g|
|
21
|
+
(1..5).each do |x|
|
22
|
+
(1..5).each do |y|
|
23
|
+
g.add_node( "n#{x}x#{y}", :pos => "#{x},#{y}!", :shape => type.rotate )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
}.output( :png => "#{$0}.png" )
|
@@ -0,0 +1,70 @@
|
|
1
|
+
$:.unshift( "../lib" );
|
2
|
+
require 'graphviz/family_tree'
|
3
|
+
|
4
|
+
tree = GraphViz::FamilyTree.new do
|
5
|
+
generation do
|
6
|
+
chantale.is_a_woman( "Chantale" )
|
7
|
+
jacques.is_a_man( "Jacques" )
|
8
|
+
|
9
|
+
jacques.is_dead
|
10
|
+
jacques.is_maried_with chantale
|
11
|
+
|
12
|
+
rose.is_a_woman( "Rose Marie" )
|
13
|
+
andre.is_a_man( "Andre" )
|
14
|
+
|
15
|
+
andre.is_maried_with rose
|
16
|
+
andre.is_dead
|
17
|
+
end
|
18
|
+
|
19
|
+
generation do
|
20
|
+
benoist.is_a_man( "Benoist" )
|
21
|
+
nathalie.is_a_woman( "Nathalie" )
|
22
|
+
|
23
|
+
benoist.is_maried_with nathalie
|
24
|
+
|
25
|
+
michel.is_a_man( "Michel" )
|
26
|
+
brigitte.is_a_woman( "Brigitte" )
|
27
|
+
|
28
|
+
michel.is_maried_with brigitte
|
29
|
+
end
|
30
|
+
|
31
|
+
couple( chantale, jacques ).kids( nathalie )
|
32
|
+
couple( rose, andre ).kids( benoist )
|
33
|
+
|
34
|
+
generation do
|
35
|
+
charlotte.is_a_woman( "Charlotte" )
|
36
|
+
amelie.is_a_woman( "Amelie" )
|
37
|
+
clement.is_a_man( "Clement" )
|
38
|
+
gregoire.is_a_man( "Gregoire" )
|
39
|
+
|
40
|
+
muriel.is_a_woman( "Muriel" )
|
41
|
+
gilles.is_a_man( "Gilles" )
|
42
|
+
|
43
|
+
morgane.is_a_woman( "Morgane" )
|
44
|
+
gregoire.is_divorced_with morgane
|
45
|
+
|
46
|
+
pascal.is_a_man( "Pascal" )
|
47
|
+
muriel.is_divorced_with pascal
|
48
|
+
|
49
|
+
gregoire.is_maried_with muriel
|
50
|
+
end
|
51
|
+
|
52
|
+
couple( michel, brigitte ).kids( muriel, gilles )
|
53
|
+
couple( benoist, nathalie ).kids( charlotte, amelie, clement, gregoire )
|
54
|
+
|
55
|
+
generation do
|
56
|
+
arthur.is_a_boy( "Arthur" )
|
57
|
+
colyne.is_a_girl( "Colyne" )
|
58
|
+
benedict.is_a_boy( "Benedict" )
|
59
|
+
maia.is_a_girl( "Maia" )
|
60
|
+
enaitz.is_a_boy( "Enaitz" )
|
61
|
+
milo.is_a_boy( "Milo" )
|
62
|
+
end
|
63
|
+
|
64
|
+
couple( gregoire, morgane ).kids( arthur, colyne, benedict )
|
65
|
+
couple( gregoire, muriel ).kids( maia )
|
66
|
+
couple( muriel, pascal ).kids( milo )
|
67
|
+
muriel.kids( enaitz )
|
68
|
+
end
|
69
|
+
|
70
|
+
tree.graph.save( :png => "#{$0}.png" )
|
data/lib/graphviz.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
1
|
+
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>
|
2
2
|
#
|
3
3
|
# This program is free software; you can redistribute it and/or modify
|
4
4
|
# it under the terms of the GNU General Public License as published by
|
@@ -28,6 +28,8 @@ require 'graphviz/parser'
|
|
28
28
|
require 'graphviz/types'
|
29
29
|
require 'graphviz/core_ext'
|
30
30
|
|
31
|
+
$KCODE = "UTF8"
|
32
|
+
|
31
33
|
class GraphViz
|
32
34
|
include Constants
|
33
35
|
|
@@ -148,7 +150,6 @@ class GraphViz
|
|
148
150
|
add_edge( oNodeOne, nt, hOpts )
|
149
151
|
end
|
150
152
|
else
|
151
|
-
|
152
153
|
oEdge = GraphViz::Edge::new( oNodeOne, oNodeTwo, self )
|
153
154
|
|
154
155
|
hOpts.each do |xKey, xValue|
|
@@ -254,16 +255,16 @@ class GraphViz
|
|
254
255
|
rCod = add_graph( xName, args[0]||{} )
|
255
256
|
yield( rCod )
|
256
257
|
else
|
257
|
-
# Create a node named '#{xName}' or search for a node, edge or cluster
|
258
|
+
# Create a node named '#{xName}' or search for a node, edge or cluster
|
258
259
|
if @hoNodes.keys.include?( xName )
|
259
260
|
if( args[0] )
|
260
|
-
return
|
261
|
+
return { xName => args[0] }
|
261
262
|
else
|
262
263
|
return( @hoNodes[xName] )
|
263
264
|
end
|
264
265
|
end
|
265
266
|
return( @hoGraphs[xName] ) if @hoGraphs.keys.include?( xName )
|
266
|
-
|
267
|
+
|
267
268
|
rCod = add_node( xName, args[0]||{} )
|
268
269
|
end
|
269
270
|
|
@@ -313,6 +314,7 @@ class GraphViz
|
|
313
314
|
xLastType = nil
|
314
315
|
xSeparator = ""
|
315
316
|
xData = ""
|
317
|
+
lNotHugly = []
|
316
318
|
|
317
319
|
@elements_order.each { |kElement|
|
318
320
|
if xLastType.nil? == true or xLastType != kElement["type"]
|
@@ -414,6 +416,14 @@ class GraphViz
|
|
414
416
|
@errors = xValue
|
415
417
|
when "extlib"
|
416
418
|
@extlibs = xValue.split( "," ).map{ |x| x.strip }
|
419
|
+
when "nothugly"
|
420
|
+
begin
|
421
|
+
require 'graphviz/nothugly'
|
422
|
+
@nothugly = true
|
423
|
+
rescue
|
424
|
+
warn "You must install ruby-xslt to use nothugly option!"
|
425
|
+
@nothugly = false
|
426
|
+
end
|
417
427
|
else
|
418
428
|
if FORMATS.index( xKey.to_s ).nil? == true
|
419
429
|
raise ArgumentError, "output format '#{xValue}' invalid"
|
@@ -443,7 +453,7 @@ class GraphViz
|
|
443
453
|
|
444
454
|
if (@format.to_s != "none" and not @format.nil?) or (@output.any? {|format, file| format != "none" } and @output.size > 0)
|
445
455
|
## Act: Save script and send it to dot
|
446
|
-
t = Tempfile::open( File.basename(
|
456
|
+
t = Tempfile::open( File.basename(__FILE__) )
|
447
457
|
t.print( xDOTScript )
|
448
458
|
t.close
|
449
459
|
|
@@ -457,6 +467,7 @@ class GraphViz
|
|
457
467
|
xOutputWithFile = ""
|
458
468
|
xOutputWithoutFile = ""
|
459
469
|
unless @format.nil? or @format == "none"
|
470
|
+
lNotHugly << @filename if @format.to_s == "svg" and @nothugly
|
460
471
|
if @filename.nil? or @filename == String
|
461
472
|
xOutputWithoutFile = "-T#{@format} "
|
462
473
|
else
|
@@ -464,6 +475,7 @@ class GraphViz
|
|
464
475
|
end
|
465
476
|
end
|
466
477
|
@output.each_except( :key => ["none"] ) do |format, file|
|
478
|
+
lNotHugly << file if format.to_s == "svg" and @nothugly
|
467
479
|
if file.nil? or file == String
|
468
480
|
xOutputWithoutFile << "-T#{format} "
|
469
481
|
else
|
@@ -492,7 +504,16 @@ class GraphViz
|
|
492
504
|
|
493
505
|
xOutput << output_from_command( xCmd )
|
494
506
|
end
|
495
|
-
|
507
|
+
|
508
|
+
# Not Hugly
|
509
|
+
lNotHugly.each do |f|
|
510
|
+
if f.nil? or f == String
|
511
|
+
xOutput = GraphViz.nothugly( xOutput, false )
|
512
|
+
else
|
513
|
+
GraphViz.nothugly( f, true )
|
514
|
+
end
|
515
|
+
end
|
516
|
+
|
496
517
|
if xOutputString
|
497
518
|
xOutput
|
498
519
|
else
|
@@ -540,6 +561,7 @@ class GraphViz
|
|
540
561
|
def name
|
541
562
|
@name.clone
|
542
563
|
end
|
564
|
+
alias :id :name
|
543
565
|
|
544
566
|
#
|
545
567
|
# Create an edge between the current cluster and the node or cluster +oNode+
|
@@ -669,6 +691,7 @@ class GraphViz
|
|
669
691
|
@errors = @@errors
|
670
692
|
@extlibs = @@extlibs
|
671
693
|
@output = {}
|
694
|
+
@nothugly = false
|
672
695
|
|
673
696
|
@elements_order = Array::new()
|
674
697
|
|
@@ -731,7 +754,7 @@ class GraphViz
|
|
731
754
|
# Escape a string to be acceptable as a node name in a graphviz input file
|
732
755
|
#
|
733
756
|
def self.escape(str, force = false ) #:nodoc:
|
734
|
-
if force or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_
|
757
|
+
if force or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z/ ).nil?
|
735
758
|
'"' + str.gsub('"', '\\"').gsub("\n", '\\\\n').gsub(".","\\.") + '"'
|
736
759
|
#if force or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_:\.]*\Z/ ).nil?
|
737
760
|
# '"' + str.gsub('"', '\\"').gsub("\n", '\\\\n') + '"'
|