ruby-graphviz 0.9.19 → 0.9.20
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 +6 -0
- data/examples/dot/so-sample001.gv +30 -0
- data/examples/dot/so-sample002.gv +33 -0
- data/examples/dot/so-sample003.gv +45 -0
- data/examples/graphml/cluster.graphml +4 -4
- data/examples/sample35.rb +1 -1
- data/examples/sample57.rb +2 -1
- data/lib/graphviz/attrs.rb +1 -1
- data/lib/graphviz/constants.rb +1 -1
- data/lib/graphviz/edge.rb +18 -2
- data/lib/graphviz/family_tree.rb +2 -0
- data/lib/graphviz/node.rb +16 -0
- data/lib/graphviz.rb +29 -5
- 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 +3 -0
- data/test/output/sample21.rb.png +0 -0
- data/test/output/sample22.rb.html +5 -0
- 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 +21 -0
- data/test/output/sample30.rb.ps +923 -0
- data/test/output/sample31.rb.png +0 -0
- data/test/output/sample32.rb.png +0 -0
- data/test/output/sample35.rb.gv +24 -0
- data/test/output/sample35.rb.png +0 -0
- data/test/output/sample37.rb.dot +50 -0
- data/test/output/sample37.rb.png +0 -0
- data/test/output/sample38.rb.png +0 -0
- data/test/output/sample39.rb.png +0 -0
- data/test/output/sample40.rb.png +0 -0
- data/test/output/sample41.rb.svg +8 -0
- data/test/output/sample42.rb.png +0 -0
- data/test/output/sample43.rb.png +0 -0
- data/test/output/sample44.rb.png +0 -0
- data/test/output/sample45.rb.png +0 -0
- data/test/output/sample46.rb.png +0 -0
- data/test/output/sample47.rb.png +0 -0
- data/test/output/sample48.rb.png +0 -0
- data/test/output/sample49.rb.png +0 -0
- data/test/output/sample50.rb.png +0 -0
- data/test/output/sample51.rb.png +0 -0
- data/test/output/sample52.rb.png +0 -0
- data/test/output/sample53.rb.png +0 -0
- data/test/output/sample54.rb.png +0 -0
- data/test/output/sample55.rb.png +0 -0
- data/test/output/sample56.rb.svg +28 -0
- data/test/output/sample58.rb.png +0 -0
- data/test/output/sample99.rb.png +0 -0
- data/test/support.rb +7 -2
- data/test/test_examples.rb +4 -4
- data/test/test_init.rb +1 -1
- metadata +65 -4
data/AUTHORS
CHANGED
data/README.rdoc
CHANGED
@@ -16,6 +16,12 @@ Interface to the GraphViz graphing tool
|
|
16
16
|
|
17
17
|
== CHANGELOG
|
18
18
|
|
19
|
+
=== 0.9.20 :
|
20
|
+
* Add GraphViz#each_attribut, Node#each_attribut and Edge#each_attribut
|
21
|
+
* Bugs corrections in tests (by oupo)
|
22
|
+
* Major bug correction in GraphViz#output for subgraphs
|
23
|
+
* Update GraphViz.escape
|
24
|
+
|
19
25
|
=== 0.9.19 :
|
20
26
|
* Add strict digraph support (by Jonas Elfström) (see sample58.rb)
|
21
27
|
g = GraphViz.new(:G, :type => "strict digraph")
|
@@ -0,0 +1,30 @@
|
|
1
|
+
digraph G {
|
2
|
+
layout="neato"
|
3
|
+
// scale things down for example
|
4
|
+
size="5,5"
|
5
|
+
rankdir=TD
|
6
|
+
ranksep=1
|
7
|
+
nodesep=1
|
8
|
+
|
9
|
+
node [shape=box]
|
10
|
+
|
11
|
+
top[pos="5,10!", width=5, height=2]
|
12
|
+
|
13
|
+
left1[pos="3.5,7!", width=2, height=2]
|
14
|
+
left2[pos="3.5,4!", width=2, height=2]
|
15
|
+
|
16
|
+
right[pos="6.5,5.5!", width=2, height=5]
|
17
|
+
|
18
|
+
bottom[pos="5,1!", width=5, height=2]
|
19
|
+
|
20
|
+
|
21
|
+
top->left1
|
22
|
+
top->right
|
23
|
+
|
24
|
+
left1->left2
|
25
|
+
left1->right
|
26
|
+
left2->right
|
27
|
+
|
28
|
+
left2->bottom
|
29
|
+
right->bottom
|
30
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
//{:category1 =>
|
3
|
+
// {:subcategory1 =>
|
4
|
+
// [
|
5
|
+
// {:article => "some article", :date => "2010-04-04"},
|
6
|
+
// ...
|
7
|
+
// ],
|
8
|
+
// :subc2 => [...]
|
9
|
+
// },
|
10
|
+
// :category2 => {...},
|
11
|
+
// ...
|
12
|
+
//}
|
13
|
+
|
14
|
+
graph G {
|
15
|
+
rankdir=LR
|
16
|
+
category1
|
17
|
+
|
18
|
+
subgraph clusterC {
|
19
|
+
node[shape="box"]
|
20
|
+
subcategory1
|
21
|
+
subc2
|
22
|
+
|
23
|
+
subgraph clusterS {
|
24
|
+
article -- "somme article"
|
25
|
+
date -- "2010-04-04"
|
26
|
+
}
|
27
|
+
|
28
|
+
subcategory1 -- clusterS
|
29
|
+
subc2 -- "..."
|
30
|
+
}
|
31
|
+
|
32
|
+
category1 -- clusterC
|
33
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
//{:category1 =>
|
3
|
+
// {:subcategory1 =>
|
4
|
+
// [
|
5
|
+
// {:article => "some article", :date => "2010-04-04"},
|
6
|
+
// ...
|
7
|
+
// ],
|
8
|
+
// :subc2 => [...]
|
9
|
+
// },
|
10
|
+
// :category2 => {...},
|
11
|
+
// ...
|
12
|
+
//}
|
13
|
+
|
14
|
+
graph G {
|
15
|
+
layout="fdp"
|
16
|
+
|
17
|
+
category1[label=":category1", shape="box"]
|
18
|
+
|
19
|
+
subgraph cluster_category1 {
|
20
|
+
subcategory1[label=":subcategory1", shape="box"]
|
21
|
+
subc2[label=":subc2", shape="box"]
|
22
|
+
|
23
|
+
subgraph cluster_subcategory1 {
|
24
|
+
subgraph cluster_subcategory1_Array0 {
|
25
|
+
article0[label=":article", shape="box"]
|
26
|
+
date0[label=":date", shape="box"]
|
27
|
+
|
28
|
+
article0 -- "somme article"
|
29
|
+
date0 -- "2010-04-04"
|
30
|
+
}
|
31
|
+
subgraph cluster_subcategory1_Array1 {
|
32
|
+
article1[label=":article", shape="box"]
|
33
|
+
date1[label=":date", shape="box"]
|
34
|
+
|
35
|
+
article1 -- "an other article"
|
36
|
+
date1 -- "2010-09-09"
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
subcategory1 -- cluster_subcategory1
|
41
|
+
subc2 -- "..."
|
42
|
+
}
|
43
|
+
|
44
|
+
category1 -- cluster_category1
|
45
|
+
}
|
@@ -15,19 +15,19 @@ xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns http://graphml.graphdr
|
|
15
15
|
<data key="label">process #1</data>
|
16
16
|
<node id="a0">
|
17
17
|
<data key="style">filled</data>
|
18
|
-
<data key="
|
18
|
+
<data key="color">white</data>
|
19
19
|
</node>
|
20
20
|
<node id="a1">
|
21
21
|
<data key="style">filled</data>
|
22
|
-
<data key="
|
22
|
+
<data key="color">white</data>
|
23
23
|
</node>
|
24
24
|
<node id="a2">
|
25
25
|
<data key="style">filled</data>
|
26
|
-
<data key="
|
26
|
+
<data key="color">white</data>
|
27
27
|
</node>
|
28
28
|
<node id="a3">
|
29
29
|
<data key="style">filled</data>
|
30
|
-
<data key="
|
30
|
+
<data key="color">white</data>
|
31
31
|
</node>
|
32
32
|
<edge id="e0" source="a0" target="a1"/>
|
33
33
|
<edge id="e1" source="a1" target="a2"/>
|
data/examples/sample35.rb
CHANGED
data/examples/sample57.rb
CHANGED
@@ -2,6 +2,7 @@ $:.unshift( "../lib" )
|
|
2
2
|
|
3
3
|
require 'graphviz/graphml'
|
4
4
|
|
5
|
-
graphml = File.join( File.dirname( File.expand_path( __FILE__ ) ), "graphml", "
|
5
|
+
graphml = File.join( File.dirname( File.expand_path( __FILE__ ) ), "graphml", "port.graphml" )
|
6
6
|
g = GraphViz::GraphML.new( graphml )
|
7
7
|
g.graph.output( :png => "#{$0}.png" )
|
8
|
+
puts g.graph.output( :none => String )
|
data/lib/graphviz/attrs.rb
CHANGED
data/lib/graphviz/constants.rb
CHANGED
data/lib/graphviz/edge.rb
CHANGED
@@ -61,7 +61,7 @@ class GraphViz
|
|
61
61
|
if @xNodeOnePort.nil? or with_port == false
|
62
62
|
GraphViz.escape(@xNodeOne)
|
63
63
|
else
|
64
|
-
GraphViz.escape(@xNodeOne, true) + ":#{@xNodeOnePort}"
|
64
|
+
GraphViz.escape(@xNodeOne, :force => true) + ":#{@xNodeOnePort}"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
alias :tail_node :node_one
|
@@ -71,7 +71,7 @@ class GraphViz
|
|
71
71
|
if @xNodeTwoPort.nil? or with_port == false
|
72
72
|
GraphViz.escape(@xNodeTwo)
|
73
73
|
else
|
74
|
-
GraphViz.escape(@xNodeTwo, true) + ":#{@xNodeTwoPort}"
|
74
|
+
GraphViz.escape(@xNodeTwo, :force => true) + ":#{@xNodeTwoPort}"
|
75
75
|
end
|
76
76
|
end
|
77
77
|
alias :head_node :node_two
|
@@ -112,6 +112,22 @@ class GraphViz
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
#
|
116
|
+
# Calls block once for each attribut of the edge, passing the name and value to the
|
117
|
+
# block as a two-element array.
|
118
|
+
#
|
119
|
+
# If global is set to false, the block does not receive the attributs set globally
|
120
|
+
#
|
121
|
+
def each_attribut(global = true, &b)
|
122
|
+
attrs = @oAttrEdge.to_h
|
123
|
+
if global
|
124
|
+
attrs = pg.edge.to_h.merge attrs
|
125
|
+
end
|
126
|
+
attrs.each do |k,v|
|
127
|
+
yield(k,v)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
115
131
|
def <<( oNode ) #:nodoc:
|
116
132
|
n = @oGParrent.get_node(@xNodeTwo)
|
117
133
|
|
data/lib/graphviz/family_tree.rb
CHANGED
data/lib/graphviz/node.rb
CHANGED
@@ -91,6 +91,22 @@ class GraphViz
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
+
#
|
95
|
+
# Calls block once for each attribut of the node, passing the name and value to the
|
96
|
+
# block as a two-element array.
|
97
|
+
#
|
98
|
+
# If global is set to false, the block does not receive the attributs set globally
|
99
|
+
#
|
100
|
+
def each_attribut(global = true, &b)
|
101
|
+
attrs = @oAttrNode.to_h
|
102
|
+
if global
|
103
|
+
attrs = pg.node.to_h.merge attrs
|
104
|
+
end
|
105
|
+
attrs.each do |k,v|
|
106
|
+
yield(k,v)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
94
110
|
#
|
95
111
|
# Create an edge between the current node and the node +oNode+
|
96
112
|
#
|
data/lib/graphviz.rb
CHANGED
@@ -230,7 +230,7 @@ class GraphViz
|
|
230
230
|
hOpts = xGraphName
|
231
231
|
xGraphName = nil
|
232
232
|
end
|
233
|
-
|
233
|
+
|
234
234
|
if xGraphName.nil?
|
235
235
|
xGraphID = String.random(11)
|
236
236
|
xGraphName = ""
|
@@ -337,6 +337,16 @@ class GraphViz
|
|
337
337
|
end
|
338
338
|
end
|
339
339
|
|
340
|
+
#
|
341
|
+
# Calls block once for each attribut of the graph, passing the name and value to the
|
342
|
+
# block as a two-element array.
|
343
|
+
#
|
344
|
+
def each_attribut(&b)
|
345
|
+
@graph.each do |k,v|
|
346
|
+
yield(k,v)
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
340
350
|
#
|
341
351
|
# Generate the graph
|
342
352
|
#
|
@@ -432,7 +442,7 @@ class GraphViz
|
|
432
442
|
xDOTScript << "}"
|
433
443
|
|
434
444
|
if @oParentGraph.nil? == false
|
435
|
-
xDOTScript = "subgraph #{GraphViz.escape(@name)} {\n" << xDOTScript
|
445
|
+
xDOTScript = "subgraph #{GraphViz.escape(@name, :unquote_empty => true)} {\n" << xDOTScript
|
436
446
|
|
437
447
|
return( xDOTScript )
|
438
448
|
else
|
@@ -480,7 +490,7 @@ class GraphViz
|
|
480
490
|
@output = hOutput if hOutput.size > 0
|
481
491
|
|
482
492
|
xStict = ((@strict && @oGraphType == "digraph") ? "strict " : "")
|
483
|
-
xDOTScript = ("#{xStict}#{@oGraphType} #{GraphViz.escape(@name)} {\n" << xDOTScript).gsub( "\0", "" )
|
493
|
+
xDOTScript = ("#{xStict}#{@oGraphType} #{GraphViz.escape(@name, :unquote_empty => true)} {\n" << xDOTScript).gsub( "\0", "" )
|
484
494
|
|
485
495
|
xOutputString = (@filename == String ||
|
486
496
|
@output.any? {|format, file| file == String })
|
@@ -797,8 +807,13 @@ class GraphViz
|
|
797
807
|
#
|
798
808
|
# Escape a string to be acceptable as a node name in a graphviz input file
|
799
809
|
#
|
800
|
-
def self.escape(str,
|
801
|
-
|
810
|
+
def self.escape(str, opts = {} ) #:nodoc:
|
811
|
+
options = {
|
812
|
+
:force => false,
|
813
|
+
:unquote_empty => false,
|
814
|
+
}.merge(opts)
|
815
|
+
|
816
|
+
if (options[:force] or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z/ ).nil?) and options[:unquote_empty] == false
|
802
817
|
'"' + str.gsub('"', '\\"').gsub("\n", '\\\\n').gsub(".","\\.") + '"'
|
803
818
|
## MAYBE WE NEED TO USE THIS ONE ## str.inspect.gsub(".","\\.").gsub( "\\\\", "\\" )
|
804
819
|
else
|
@@ -806,4 +821,13 @@ class GraphViz
|
|
806
821
|
end
|
807
822
|
end
|
808
823
|
|
824
|
+
#def self.escape(str, force = false ) #:nodoc:
|
825
|
+
# if force or str.match( /\A[a-zA-Z_]+[a-zA-Z0-9_]*\Z/ ).nil?
|
826
|
+
# '"' + str.gsub('"', '\\"').gsub("\n", '\\\\n').gsub(".","\\.") + '"'
|
827
|
+
# ## MAYBE WE NEED TO USE THIS ONE ## str.inspect.gsub(".","\\.").gsub( "\\\\", "\\" )
|
828
|
+
# else
|
829
|
+
# str
|
830
|
+
# end
|
831
|
+
#end
|
832
|
+
|
809
833
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,3 @@
|
|
1
|
+
base referer
|
2
|
+
poly http://www.research.att.com/base.html 133,29 130,22 121,15 107,10 89,7 69,5 50,7 32,10 17,15 8,22 5,29 8,37 17,43 32,49 50,52 69,53 89,52 107,49 121,43 130,37
|
3
|
+
poly colors.html 114,125 112,118 106,111 96,106 83,103 69,101 55,103 43,106 33,111 26,118 24,125 26,133 33,139 43,145 55,148 69,149 83,148 96,145 106,139 112,133
|
Binary file
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<map id="mainmap" name="mainmap">
|
2
|
+
<area shape="poly" id="node1" href="http://www.research.att.com/command.html" title="command" alt="" coords="133,29 130,22 121,15 107,10 89,7 69,5 50,7 32,10 17,15 8,22 5,29 8,37 17,43 32,49 50,52 69,53 89,52 107,49 121,43 130,37"/>
|
3
|
+
<area shape="poly" id="edge2" href="colors.html" alt="" coords="72,54 72,87 67,87 67,54"/>
|
4
|
+
<area shape="rect" id="graph1" href="http://www.research.att.com/base.html" alt="" coords="0,0,139,155"/>
|
5
|
+
</map>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
|
3
|
+
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
4
|
+
<!-- Generated by graphviz version 2.27.20100802.0445 (20100802.0445)
|
5
|
+
-->
|
6
|
+
<!-- Title: G Pages: 1 -->
|
7
|
+
<svg width="150pt" height="62pt"
|
8
|
+
viewBox="0.00 0.00 150.00 62.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
|
9
|
+
<g id="graph1" class="graph" transform="scale(1 1) rotate(0) translate(4 58)">
|
10
|
+
<title>G</title>
|
11
|
+
<polygon fill="white" stroke="white" points="-4,5 -4,-58 147,-58 147,5 -4,5"/>
|
12
|
+
<!-- "Hello\."\nHow are you ? -->
|
13
|
+
<g id="node1" class="node"><title>"Hello\."\nHow are you ?</title>
|
14
|
+
<a xlink:href="http://www.website.com" xlink:title=""Hello."\nHow are you ?">
|
15
|
+
<ellipse fill="none" stroke="#ff0000" cx="71" cy="-27" rx="70.9184" ry="26.8701"/>
|
16
|
+
<text text-anchor="middle" x="71" y="-29.4" font-family="Times,serif" font-size="14.00">"Hello."</text>
|
17
|
+
<text text-anchor="middle" x="71" y="-14.4" font-family="Times,serif" font-size="14.00">How are you ?</text>
|
18
|
+
</a>
|
19
|
+
</g>
|
20
|
+
</g>
|
21
|
+
</svg>
|