ruby-graphviz 1.0.0 → 1.0.1

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.
Files changed (106) hide show
  1. data/.gemrc +0 -0
  2. data/.gitignore +6 -0
  3. data/AUTHORS +3 -0
  4. data/Gemfile +4 -0
  5. data/README.rdoc +25 -45
  6. data/Rakefile +59 -0
  7. data/bin/dot2ruby +0 -0
  8. data/bin/gem2gv +0 -0
  9. data/bin/git2gv +0 -0
  10. data/bin/ruby2gv +0 -0
  11. data/bin/xml2gv +0 -0
  12. data/examples/sample48.rb +2 -2
  13. data/examples/sample62.rb +24 -0
  14. data/examples/sample63.rb +32 -0
  15. data/examples/sample64.rb +31 -0
  16. data/examples/sample65.rb +9 -0
  17. data/lib/graphviz.rb +55 -25
  18. data/lib/graphviz/constants.rb +103 -100
  19. data/lib/graphviz/core_ext.rb +57 -34
  20. data/lib/graphviz/dot2ruby.rb +9 -0
  21. data/lib/graphviz/dsl.rb +59 -0
  22. data/lib/graphviz/node.rb +2 -1
  23. data/lib/graphviz/types.rb +0 -4
  24. data/lib/graphviz/types/arrow_type.rb +32 -0
  25. data/lib/graphviz/types/color.rb +56 -0
  26. data/lib/graphviz/types/color_list.rb +22 -0
  27. data/lib/graphviz/types/esc_string.rb +5 -14
  28. data/lib/graphviz/types/gv_bool.rb +49 -0
  29. data/lib/graphviz/types/gv_double.rb +12 -2
  30. data/lib/graphviz/types/html_string.rb +3 -1
  31. data/lib/graphviz/types/lbl_string.rb +2 -1
  32. data/lib/graphviz/types/rect.rb +34 -0
  33. data/lib/graphviz/types/spline_type.rb +75 -0
  34. data/lib/graphviz/utils.rb +2 -2
  35. data/lib/graphviz/utils/colors.rb +1019 -0
  36. data/ruby-graphviz.gemspec +57 -0
  37. data/test/test_examples.rb +4 -0
  38. data/test/{test_init.rb → test_graph.rb} +1 -1
  39. data/test/test_types.rb +65 -0
  40. data/test/test_utils_colors.rb +57 -0
  41. metadata +100 -112
  42. data/examples/rgv/rgv.ps +0 -125
  43. data/examples/rgv/test_rgv.rb +0 -12
  44. data/examples/rgv/test_rgv.rb.ps +0 -393
  45. data/examples/simpsons.gv +0 -69
  46. data/test/output/sample01.rb.png +0 -0
  47. data/test/output/sample02.rb.png +0 -0
  48. data/test/output/sample03.rb.png +0 -0
  49. data/test/output/sample04.rb.png +0 -0
  50. data/test/output/sample05.rb.png +0 -0
  51. data/test/output/sample06.rb.png +0 -0
  52. data/test/output/sample07.rb.png +0 -0
  53. data/test/output/sample08.rb.png +0 -0
  54. data/test/output/sample09.rb.png +0 -0
  55. data/test/output/sample10.rb.png +0 -0
  56. data/test/output/sample11.rb.png +0 -0
  57. data/test/output/sample12.rb.png +0 -0
  58. data/test/output/sample13.rb.png +0 -0
  59. data/test/output/sample14.rb.png +0 -0
  60. data/test/output/sample15.rb.png +0 -0
  61. data/test/output/sample16.rb.png +0 -0
  62. data/test/output/sample17.rb.png +0 -0
  63. data/test/output/sample18.rb.png +0 -0
  64. data/test/output/sample19.rb.png +0 -0
  65. data/test/output/sample20.rb.png +0 -0
  66. data/test/output/sample21.rb.html +0 -3
  67. data/test/output/sample21.rb.png +0 -0
  68. data/test/output/sample22.rb.html +0 -5
  69. data/test/output/sample22.rb.png +0 -0
  70. data/test/output/sample23.rb.png +0 -0
  71. data/test/output/sample24.rb.png +0 -0
  72. data/test/output/sample25.rb.png +0 -0
  73. data/test/output/sample26.rb.png +0 -0
  74. data/test/output/sample28.rb.png +0 -0
  75. data/test/output/sample29.rb.svg +0 -21
  76. data/test/output/sample30.rb.ps +0 -923
  77. data/test/output/sample31.rb.png +0 -0
  78. data/test/output/sample32.rb.png +0 -0
  79. data/test/output/sample35.rb.gv +0 -24
  80. data/test/output/sample35.rb.png +0 -0
  81. data/test/output/sample37.rb.dot +0 -50
  82. data/test/output/sample37.rb.png +0 -0
  83. data/test/output/sample38.rb.png +0 -0
  84. data/test/output/sample39.rb.png +0 -0
  85. data/test/output/sample40.rb.png +0 -0
  86. data/test/output/sample41.rb.svg +0 -8
  87. data/test/output/sample42.rb.png +0 -0
  88. data/test/output/sample43.rb.png +0 -0
  89. data/test/output/sample44.rb.png +0 -0
  90. data/test/output/sample45.rb.png +0 -0
  91. data/test/output/sample46.rb.png +0 -0
  92. data/test/output/sample47.rb.png +0 -0
  93. data/test/output/sample48.rb.png +0 -0
  94. data/test/output/sample49.rb.png +0 -0
  95. data/test/output/sample50.rb.png +0 -0
  96. data/test/output/sample51.rb.png +0 -0
  97. data/test/output/sample52.rb.png +0 -0
  98. data/test/output/sample53.rb.png +0 -0
  99. data/test/output/sample54.rb.png +0 -0
  100. data/test/output/sample55.rb.png +0 -0
  101. data/test/output/sample56.rb.svg +0 -28
  102. data/test/output/sample58.rb.png +0 -0
  103. data/test/output/sample59.rb.png +0 -0
  104. data/test/output/sample60.rb.png +0 -0
  105. data/test/output/sample61.rb.png +0 -0
  106. data/test/output/sample99.rb.png +0 -0
@@ -1,125 +0,0 @@
1
- %! Greg shapes for GraphViz/DOT
2
-
3
- % input format :
4
- % [ 54 36 0 36 0 0 54 0 54 36 ] 4 false yourshape
5
- % or
6
- % [ 54 36 0 36 0 0 54 0 54 36 ] 4 true yourshape
7
- % [ 150 150 100 150 100 100 150 100 150 150 ] 4 true yourshape
8
- %
9
- % [upper right (y, x), lower right (y, x), lower left (y, x), upper left (y, x), upper right (y, x)]
10
-
11
- /xdef {exch def} bind def
12
-
13
- /rgv_box {
14
- 10 dict begin
15
- /fflag xdef
16
- /sides xdef
17
-
18
- 4 sides ne { stop } if
19
-
20
- aload pop
21
-
22
- newpath
23
- moveto
24
- lineto
25
- lineto
26
- lineto
27
- closepath
28
-
29
- pop pop
30
-
31
- fflag { fill } { stroke } ifelse
32
- end
33
- } bind def
34
-
35
- /rgv_cloud {
36
- 10 dict begin
37
- /fflag xdef
38
- /sides xdef
39
-
40
- % Check if we have 4 sides. Else stop
41
- 4 sides ne { stop } if
42
-
43
- % (aload) takes an array as its argument and places the individual elements
44
- % of that array, and then the array itself, on the stack. Then (pop) remove
45
- % the top element from the stack (the array)
46
- aload pop
47
-
48
- /ury xdef /urx xdef
49
- /lry xdef /lrx xdef
50
- /lly xdef /llx xdef
51
- /uly xdef /ulx xdef
52
- pop pop
53
-
54
- /mx lrx llx neg add 2 div def
55
- /my uly lly neg add 2 div def
56
-
57
- % empty the current path and declares we are starting a new path
58
- newpath
59
-
60
- urx ury my neg add my 270 90 arc
61
- ulx mx add uly mx 0 180 arc
62
- llx lly my add my 90 270 arc
63
- lrx lry lineto
64
-
65
- closepath
66
-
67
- % The stroke operator on line four causes the path we have constructed to be
68
- % painted onto the current page.
69
- % The fill operator fills the current path with ink.
70
- fflag { fill } { stroke } ifelse
71
- end
72
- } bind def
73
-
74
- /rgv_flower {
75
- 10 dict begin
76
- /fflag xdef
77
- /sides xdef
78
-
79
- % Check if we have 4 sides. Else stop
80
- 4 sides ne { stop } if
81
-
82
- % (aload) takes an array as its argument and places the individual elements
83
- % of that array, and then the array itself, on the stack. Then (pop) remove
84
- % the top element from the stack (the array)
85
- aload pop
86
-
87
- /ury xdef /urx xdef
88
- /lry xdef /lrx xdef
89
- /lly xdef /llx xdef
90
- /uly xdef /ulx xdef
91
- pop pop
92
-
93
- /mx lrx llx neg add 2 div def
94
- /my uly lly neg add 2 div def
95
-
96
- % empty the current path and declares we are starting a new path
97
- newpath
98
-
99
- % Arcs
100
- urx ury my neg add my 270 90 arc
101
- ulx mx add uly mx 0 180 arc
102
- llx lly my add my 90 270 arc
103
- lrx mx neg add lry mx 180 0 arc
104
-
105
- closepath
106
-
107
- % The stroke operator on line four causes the path we have constructed to be
108
- % painted onto the current page.
109
- % The fill operator fills the current path with ink.
110
- fflag { fill } { stroke } ifelse
111
- end
112
- } bind def
113
-
114
- %[ 150 150 50 150 50 100 150 100 150 150 ] 4 false rgv_box
115
- %[ 250 250 150 250 150 200 250 200 250 250 ] 4 false rgv_flower
116
- %[ 350 350 250 350 250 300 350 300 350 350 ] 4 false rgv_cloud
117
- %
118
- %.5 setgray
119
- %[ 150 450 50 450 50 400 150 400 150 450 ] 4 true rgv_box
120
- %.5 setgray
121
- %[ 250 550 150 550 150 500 250 500 250 550 ] 4 true rgv_flower
122
- %.5 setgray
123
- %[ 350 650 250 650 250 600 350 600 350 650 ] 4 true rgv_cloud
124
- %
125
- %showpage
@@ -1,12 +0,0 @@
1
- #!/usr/bin/ruby
2
-
3
- $:.unshift( "../../lib" );
4
- require "graphviz"
5
-
6
- GraphViz.new(:g){ |g|
7
- g[:center] = true
8
- a = g.add_node("A", :shape => "rgv_box", :peripheries => 0)
9
- b = g.add_node("Bonjour le monde\nComment va tu ?", :shape => "rgv_cloud", :peripheries => 0)
10
- c = g.add_node("C", :shape => "rgv_flower", :peripheries => 0)
11
- a << b << c
12
- }.save( :ps => "#{$0}.ps", :extlib => "rgv.ps" )
@@ -1,393 +0,0 @@
1
- %!PS-Adobe-3.0
2
- %%Creator: graphviz version 2.26.0 (20091210.2329)
3
- %%Title: g
4
- %%Pages: (atend)
5
- %%BoundingBox: (atend)
6
- %%EndComments
7
- save
8
- %%BeginProlog
9
- /DotDict 200 dict def
10
- DotDict begin
11
-
12
- /setupLatin1 {
13
- mark
14
- /EncodingVector 256 array def
15
- EncodingVector 0
16
-
17
- ISOLatin1Encoding 0 255 getinterval putinterval
18
- EncodingVector 45 /hyphen put
19
-
20
- % Set up ISO Latin 1 character encoding
21
- /starnetISO {
22
- dup dup findfont dup length dict begin
23
- { 1 index /FID ne { def }{ pop pop } ifelse
24
- } forall
25
- /Encoding EncodingVector def
26
- currentdict end definefont
27
- } def
28
- /Times-Roman starnetISO def
29
- /Times-Italic starnetISO def
30
- /Times-Bold starnetISO def
31
- /Times-BoldItalic starnetISO def
32
- /Helvetica starnetISO def
33
- /Helvetica-Oblique starnetISO def
34
- /Helvetica-Bold starnetISO def
35
- /Helvetica-BoldOblique starnetISO def
36
- /Courier starnetISO def
37
- /Courier-Oblique starnetISO def
38
- /Courier-Bold starnetISO def
39
- /Courier-BoldOblique starnetISO def
40
- cleartomark
41
- } bind def
42
-
43
- %%BeginResource: procset graphviz 0 0
44
- /coord-font-family /Times-Roman def
45
- /default-font-family /Times-Roman def
46
- /coordfont coord-font-family findfont 8 scalefont def
47
-
48
- /InvScaleFactor 1.0 def
49
- /set_scale {
50
- dup 1 exch div /InvScaleFactor exch def
51
- scale
52
- } bind def
53
-
54
- % styles
55
- /solid { [] 0 setdash } bind def
56
- /dashed { [9 InvScaleFactor mul dup ] 0 setdash } bind def
57
- /dotted { [1 InvScaleFactor mul 6 InvScaleFactor mul] 0 setdash } bind def
58
- /invis {/fill {newpath} def /stroke {newpath} def /show {pop newpath} def} bind def
59
- /bold { 2 setlinewidth } bind def
60
- /filled { } bind def
61
- /unfilled { } bind def
62
- /rounded { } bind def
63
- /diagonals { } bind def
64
-
65
- % hooks for setting color
66
- /nodecolor { sethsbcolor } bind def
67
- /edgecolor { sethsbcolor } bind def
68
- /graphcolor { sethsbcolor } bind def
69
- /nopcolor {pop pop pop} bind def
70
-
71
- /beginpage { % i j npages
72
- /npages exch def
73
- /j exch def
74
- /i exch def
75
- /str 10 string def
76
- npages 1 gt {
77
- gsave
78
- coordfont setfont
79
- 0 0 moveto
80
- (\() show i str cvs show (,) show j str cvs show (\)) show
81
- grestore
82
- } if
83
- } bind def
84
-
85
- /set_font {
86
- findfont exch
87
- scalefont setfont
88
- } def
89
-
90
- % draw text fitted to its expected width
91
- /alignedtext { % width text
92
- /text exch def
93
- /width exch def
94
- gsave
95
- width 0 gt {
96
- [] 0 setdash
97
- text stringwidth pop width exch sub text length div 0 text ashow
98
- } if
99
- grestore
100
- } def
101
-
102
- /boxprim { % xcorner ycorner xsize ysize
103
- 4 2 roll
104
- moveto
105
- 2 copy
106
- exch 0 rlineto
107
- 0 exch rlineto
108
- pop neg 0 rlineto
109
- closepath
110
- } bind def
111
-
112
- /ellipse_path {
113
- /ry exch def
114
- /rx exch def
115
- /y exch def
116
- /x exch def
117
- matrix currentmatrix
118
- newpath
119
- x y translate
120
- rx ry scale
121
- 0 0 1 0 360 arc
122
- setmatrix
123
- } bind def
124
-
125
- /endpage { showpage } bind def
126
- /showpage { } def
127
-
128
- /layercolorseq
129
- [ % layer color sequence - darkest to lightest
130
- [0 0 0]
131
- [.2 .8 .8]
132
- [.4 .8 .8]
133
- [.6 .8 .8]
134
- [.8 .8 .8]
135
- ]
136
- def
137
-
138
- /layerlen layercolorseq length def
139
-
140
- /setlayer {/maxlayer exch def /curlayer exch def
141
- layercolorseq curlayer 1 sub layerlen mod get
142
- aload pop sethsbcolor
143
- /nodecolor {nopcolor} def
144
- /edgecolor {nopcolor} def
145
- /graphcolor {nopcolor} def
146
- } bind def
147
-
148
- /onlayer { curlayer ne {invis} if } def
149
-
150
- /onlayers {
151
- /myupper exch def
152
- /mylower exch def
153
- curlayer mylower lt
154
- curlayer myupper gt
155
- or
156
- {invis} if
157
- } def
158
-
159
- /curlayer 0 def
160
-
161
- %%EndResource
162
- %%EndProlog
163
- %%BeginSetup
164
- 14 default-font-family set_font
165
- 1 setmiterlimit
166
- % /arrowlength 10 def
167
- % /arrowwidth 5 def
168
-
169
- % make sure pdfmark is harmless for PS-interpreters other than Distiller
170
- /pdfmark where {pop} {userdict /pdfmark /cleartomark load put} ifelse
171
- % make '<<' and '>>' safe on PS Level 1 devices
172
- /languagelevel where {pop languagelevel}{1} ifelse
173
- 2 lt {
174
- userdict (<<) cvn ([) cvn load put
175
- userdict (>>) cvn ([) cvn load put
176
- } if
177
-
178
- %%EndSetup
179
- %! Greg shapes for GraphViz/DOT
180
-
181
- % input format :
182
- % [ 54 36 0 36 0 0 54 0 54 36 ] 4 false yourshape
183
- % or
184
- % [ 54 36 0 36 0 0 54 0 54 36 ] 4 true yourshape
185
- % [ 150 150 100 150 100 100 150 100 150 150 ] 4 true yourshape
186
- %
187
- % [upper right (y, x), lower right (y, x), lower left (y, x), upper left (y, x), upper right (y, x)]
188
-
189
- /xdef {exch def} bind def
190
-
191
- /rgv_box {
192
- 10 dict begin
193
- /fflag xdef
194
- /sides xdef
195
-
196
- 4 sides ne { stop } if
197
-
198
- aload pop
199
-
200
- newpath
201
- moveto
202
- lineto
203
- lineto
204
- lineto
205
- closepath
206
-
207
- pop pop
208
-
209
- fflag { fill } { stroke } ifelse
210
- end
211
- } bind def
212
-
213
- /rgv_cloud {
214
- 10 dict begin
215
- /fflag xdef
216
- /sides xdef
217
-
218
- % Check if we have 4 sides. Else stop
219
- 4 sides ne { stop } if
220
-
221
- % (aload) takes an array as its argument and places the individual elements
222
- % of that array, and then the array itself, on the stack. Then (pop) remove
223
- % the top element from the stack (the array)
224
- aload pop
225
-
226
- /ury xdef /urx xdef
227
- /lry xdef /lrx xdef
228
- /lly xdef /llx xdef
229
- /uly xdef /ulx xdef
230
- pop pop
231
-
232
- /mx lrx llx neg add 2 div def
233
- /my uly lly neg add 2 div def
234
-
235
- % empty the current path and declares we are starting a new path
236
- newpath
237
-
238
- urx ury my neg add my 270 90 arc
239
- ulx mx add uly mx 0 180 arc
240
- llx lly my add my 90 270 arc
241
- lrx lry lineto
242
-
243
- closepath
244
-
245
- % The stroke operator on line four causes the path we have constructed to be
246
- % painted onto the current page.
247
- % The fill operator fills the current path with ink.
248
- fflag { fill } { stroke } ifelse
249
- end
250
- } bind def
251
-
252
- /rgv_flower {
253
- 10 dict begin
254
- /fflag xdef
255
- /sides xdef
256
-
257
- % Check if we have 4 sides. Else stop
258
- 4 sides ne { stop } if
259
-
260
- % (aload) takes an array as its argument and places the individual elements
261
- % of that array, and then the array itself, on the stack. Then (pop) remove
262
- % the top element from the stack (the array)
263
- aload pop
264
-
265
- /ury xdef /urx xdef
266
- /lry xdef /lrx xdef
267
- /lly xdef /llx xdef
268
- /uly xdef /ulx xdef
269
- pop pop
270
-
271
- /mx lrx llx neg add 2 div def
272
- /my uly lly neg add 2 div def
273
-
274
- % empty the current path and declares we are starting a new path
275
- newpath
276
-
277
- % Arcs
278
- urx ury my neg add my 270 90 arc
279
- ulx mx add uly mx 0 180 arc
280
- llx lly my add my 90 270 arc
281
- lrx mx neg add lry mx 180 0 arc
282
-
283
- closepath
284
-
285
- % The stroke operator on line four causes the path we have constructed to be
286
- % painted onto the current page.
287
- % The fill operator fills the current path with ink.
288
- fflag { fill } { stroke } ifelse
289
- end
290
- } bind def
291
-
292
- %[ 150 150 50 150 50 100 150 100 150 150 ] 4 false rgv_box
293
- %[ 250 250 150 250 150 200 250 200 250 250 ] 4 false rgv_flower
294
- %[ 350 350 250 350 250 300 350 300 350 350 ] 4 false rgv_cloud
295
- %
296
- %.5 setgray
297
- %[ 150 450 50 450 50 400 150 400 150 450 ] 4 true rgv_box
298
- %.5 setgray
299
- %[ 250 550 150 550 150 500 250 500 250 550 ] 4 true rgv_flower
300
- %.5 setgray
301
- %[ 350 650 250 650 250 600 350 600 350 650 ] 4 true rgv_cloud
302
- %
303
- %showpage
304
-
305
- setupLatin1
306
- %%Page: 1 1
307
- %%PageBoundingBox: 242 301 370 491
308
- %%PageOrientation: Portrait
309
- 0 0 1 beginpage
310
- gsave
311
- 242 301 128 190 boxprim clip newpath
312
- 1 1 set_scale 0 rotate 246 306 translate
313
- % A
314
- gsave
315
- 1 setlinewidth
316
- 0 0 0 nodecolor
317
- [ 87 182 33 182 33 146 87 146 87 182 ] 4 false rgv_box
318
- 0 0 0 nodecolor
319
- 14 /Times-Roman set_font
320
- 54.5 158.9 moveto 11 (A) alignedtext
321
- grestore
322
- % Bonjour le monde\nComment va tu ?
323
- gsave
324
- 1 setlinewidth
325
- 0 0 0 nodecolor
326
- [ 120 110 0 110 0 72 120 72 120 110 ] 4 false rgv_cloud
327
- 0 0 0 nodecolor
328
- 14 /Times-Roman set_font
329
- 7.5 93.4 moveto 105 (Bonjour le monde) alignedtext
330
- 0 0 0 nodecolor
331
- 14 /Times-Roman set_font
332
- 11 78.4 moveto 98 (Comment va tu ?) alignedtext
333
- grestore
334
- % A->Bonjour le monde\nComment va tu ?
335
- gsave
336
- 1 setlinewidth
337
- 0 0 0 edgecolor
338
- newpath 60 145.96 moveto
339
- 60 138.21 60 128.96 60 120.28 curveto
340
- stroke
341
- 0 0 0 edgecolor
342
- newpath 63.5 120.11 moveto
343
- 60 110.11 lineto
344
- 56.5 120.11 lineto
345
- closepath fill
346
- 1 setlinewidth
347
- solid
348
- 0 0 0 edgecolor
349
- newpath 63.5 120.11 moveto
350
- 60 110.11 lineto
351
- 56.5 120.11 lineto
352
- closepath stroke
353
- grestore
354
- % C
355
- gsave
356
- 1 setlinewidth
357
- 0 0 0 nodecolor
358
- [ 87 36 33 36 33 0 87 0 87 36 ] 4 false rgv_flower
359
- 0 0 0 nodecolor
360
- 14 /Times-Roman set_font
361
- 55 12.9 moveto 10 (C) alignedtext
362
- grestore
363
- % Bonjour le monde\nComment va tu ?->C
364
- gsave
365
- 1 setlinewidth
366
- 0 0 0 edgecolor
367
- newpath 60 71.82 moveto
368
- 60 64.1 60 55.03 60 46.56 curveto
369
- stroke
370
- 0 0 0 edgecolor
371
- newpath 63.5 46.3 moveto
372
- 60 36.3 lineto
373
- 56.5 46.3 lineto
374
- closepath fill
375
- 1 setlinewidth
376
- solid
377
- 0 0 0 edgecolor
378
- newpath 63.5 46.3 moveto
379
- 60 36.3 lineto
380
- 56.5 46.3 lineto
381
- closepath stroke
382
- grestore
383
- endpage
384
- showpage
385
- grestore
386
- %%PageTrailer
387
- %%EndPage: 1
388
- %%Trailer
389
- %%Pages: 1
390
- %%BoundingBox: 242 301 370 491
391
- end
392
- restore
393
- %%EOF