ruby-graphviz 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/AUTHORS.rdoc +1 -0
- data/CHANGELOG.rdoc +12 -0
- data/README.rdoc +2 -0
- data/Rakefile +13 -6
- data/bin/dot2ruby +2 -2
- data/bin/gem2gv +2 -3
- data/bin/git2gv +2 -4
- data/bin/ruby2gv +16 -19
- data/bin/xml2gv +2 -2
- data/examples/sample38.rb +5 -5
- data/lib/graphviz.rb +82 -116
- data/lib/graphviz/attrs.rb +1 -1
- data/lib/graphviz/constants.rb +247 -240
- data/lib/graphviz/core_ext.rb +1 -1
- data/lib/graphviz/dot2ruby.rb +1 -1
- data/lib/graphviz/dot_script.rb +109 -0
- data/lib/graphviz/edge.rb +4 -4
- data/lib/graphviz/node.rb +1 -1
- data/lib/graphviz/theory.rb +3 -3
- data/lib/graphviz/types.rb +2 -1
- data/lib/graphviz/types/lbl_string.rb +1 -1
- data/lib/graphviz/utils.rb +70 -67
- data/lib/graphviz/utils/colors.rb +1 -1
- data/man/dot2ruby.1 +66 -0
- data/man/dot2ruby.1.ronn +55 -0
- data/man/gem2gv.1 +60 -0
- data/man/gem2gv.1.ronn +47 -0
- data/man/git2gv.1 +48 -0
- data/man/git2gv.1.ronn +40 -0
- data/man/ruby2gv.1 +60 -0
- data/man/ruby2gv.1.ronn +47 -0
- data/man/xml2gv.1 +48 -0
- data/man/xml2gv.1.ronn +39 -0
- data/ruby-graphviz.gemspec +4 -1
- data/test/test_dot_script.rb +43 -0
- data/test/test_graph.rb +9 -0
- data/test/test_subgraph.rb +1 -1
- metadata +70 -23
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 09cf41331aaf2b0baafb4602ffc9fd380f8b3fe9
|
4
|
+
data.tar.gz: bb8ecb3ec2d96996b88828571fab1b5524f722ca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bb891ab78f980673972eedbd897d507b5fef69e9bf168765f6fd576025d25f504e2844a9af294166ecf2a89b9c2478307cbdee86f3dd90206e70012306b0ee56
|
7
|
+
data.tar.gz: 3b509fdc45e4332048a718a7bac659b376fa2eeecee2d716d12a252ed507e053e107a190b9184d01c021ef582c679acacfeb6ad3e8c5de755b387a9e5543aa43
|
data/AUTHORS.rdoc
CHANGED
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
= CHANGELOG
|
2
2
|
|
3
|
+
== 1.0.9 :
|
4
|
+
* Add support for attributs
|
5
|
+
* forcelabels
|
6
|
+
* gradientangle
|
7
|
+
* imagepath
|
8
|
+
* layerlistsep
|
9
|
+
* layerselect
|
10
|
+
* Issue #52 : Extracted xDOTScript to DOTScript class (by markus1189)
|
11
|
+
* Issue #54 : Fixes a couple of typos and spacing (by Mike Fiedler)
|
12
|
+
* Issue #55 : Avoid autoload
|
13
|
+
* Update graphviz attributs
|
14
|
+
|
3
15
|
== 1.0.8 :
|
4
16
|
* Cleanup format (by markus1189)
|
5
17
|
* Issue #49 : (undefined local variable or method `file' ) (by markus1189)
|
data/README.rdoc
CHANGED
data/Rakefile
CHANGED
@@ -29,7 +29,7 @@ RDoc::Task.new do |rdoc|
|
|
29
29
|
rdoc.main = "README.rdoc"
|
30
30
|
rdoc.title = "Ruby/GraphViz, the Documentation"
|
31
31
|
rdoc.rdoc_files.add ['README.rdoc', 'CHANGELOG.rdoc', 'AUTHORS.rdoc', 'COPYING.rdoc',
|
32
|
-
'lib/graphviz.rb',
|
32
|
+
'lib/graphviz.rb',
|
33
33
|
'lib/graphviz/node.rb',
|
34
34
|
'lib/graphviz/edge.rb',
|
35
35
|
'lib/graphviz/constants.rb',
|
@@ -44,11 +44,18 @@ end
|
|
44
44
|
|
45
45
|
Rake::TestTask.new(:test) do |t|
|
46
46
|
require 'graphviz/utils'
|
47
|
-
include
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
47
|
+
include GraphViz::Utils
|
48
|
+
test_files = FileList['test/test_*.rb'].exclude('test/test_dot_script.rb')
|
49
|
+
test_files.unshift('test/test_dot_script.rb')
|
50
|
+
test_files.exclude("test/test_examples.rb") unless find_executable("dot", nil)
|
51
|
+
t.test_files = test_files
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Generate man pages"
|
55
|
+
task :man do
|
56
|
+
require 'ronn'
|
57
|
+
chdir 'man' do
|
58
|
+
sh "ronn -r *.ronn"
|
52
59
|
end
|
53
60
|
end
|
54
61
|
|
data/bin/dot2ruby
CHANGED
@@ -30,7 +30,7 @@ def usage
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def version
|
33
|
-
puts "Dot2Ruby v#{Constants::RGV_VERSION}, (c) 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
33
|
+
puts "Dot2Ruby v#{GraphViz::Constants::RGV_VERSION}, (c) 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
34
34
|
puts ""
|
35
35
|
puts "This program is free software; you can redistribute it and/or modify"
|
36
36
|
puts "it under the terms of the GNU General Public License as published by"
|
@@ -76,7 +76,7 @@ begin
|
|
76
76
|
exit
|
77
77
|
end
|
78
78
|
end
|
79
|
-
rescue GetoptLong::InvalidOption
|
79
|
+
rescue GetoptLong::InvalidOption
|
80
80
|
usage( )
|
81
81
|
exit
|
82
82
|
end
|
data/bin/gem2gv
CHANGED
@@ -96,7 +96,7 @@ def usage
|
|
96
96
|
end
|
97
97
|
|
98
98
|
def version
|
99
|
-
puts "Gem2GraphViz v#{Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
99
|
+
puts "Gem2GraphViz v#{GraphViz::Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
100
100
|
puts ""
|
101
101
|
puts "This program is free software; you can redistribute it and/or modify"
|
102
102
|
puts "it under the terms of the GNU General Public License as published by"
|
@@ -117,7 +117,6 @@ xOutFormat = "png"
|
|
117
117
|
xOutFile = nil
|
118
118
|
xGVPath = ""
|
119
119
|
xUse = "dot"
|
120
|
-
xStops = []
|
121
120
|
|
122
121
|
oOpt = GetoptLong.new(
|
123
122
|
['--output-format', '-T', GetoptLong::REQUIRED_ARGUMENT],
|
@@ -147,7 +146,7 @@ begin
|
|
147
146
|
exit
|
148
147
|
end
|
149
148
|
end
|
150
|
-
rescue GetoptLong::InvalidOption
|
149
|
+
rescue GetoptLong::InvalidOption
|
151
150
|
usage( )
|
152
151
|
exit
|
153
152
|
end
|
data/bin/git2gv
CHANGED
@@ -108,7 +108,7 @@ def usage
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def version
|
111
|
-
puts "Git2GraphViz v#{Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
111
|
+
puts "Git2GraphViz v#{GraphViz::Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
112
112
|
puts ""
|
113
113
|
puts "This program is free software; you can redistribute it and/or modify"
|
114
114
|
puts "it under the terms of the GNU General Public License as published by"
|
@@ -158,12 +158,10 @@ begin
|
|
158
158
|
exit
|
159
159
|
end
|
160
160
|
end
|
161
|
-
rescue GetoptLong::InvalidOption
|
161
|
+
rescue GetoptLong::InvalidOption
|
162
162
|
usage( )
|
163
163
|
exit
|
164
164
|
end
|
165
165
|
|
166
|
-
xFile = ARGV[0]
|
167
|
-
|
168
166
|
Git2Gv.new( xGVPath, xOutFile, xOutFormat, bNothugly ).run
|
169
167
|
|
data/bin/ruby2gv
CHANGED
@@ -78,7 +78,7 @@ class Rb2Gv
|
|
78
78
|
|
79
79
|
# Search in "standard" paths
|
80
80
|
xPath.each do |xDir|
|
81
|
-
xCurrentPath =
|
81
|
+
xCurrentPath = RbConfig::expand( RbConfig::CONFIG[xDir] )
|
82
82
|
xFileFound = File.join( xCurrentPath, xRbFileWithExt )
|
83
83
|
if File.exist?( xFileFound )
|
84
84
|
return xFileFound
|
@@ -86,16 +86,17 @@ class Rb2Gv
|
|
86
86
|
end
|
87
87
|
|
88
88
|
# Search in "rubygems" :: This is not utile but...
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
89
|
+
Gem::Specification.find_all do |spec|
|
90
|
+
if spec == xLib
|
91
|
+
spec.require_paths.unshift spec.bindir if spec.bindir
|
92
|
+
xPath = spec.require_paths.map do |path|
|
93
|
+
File.join spec.full_gem_path, path
|
94
|
+
end
|
95
|
+
xPath.each do |xCurrentPath|
|
96
|
+
xFileFound = File.join( xCurrentPath, xRbFileWithExt )
|
97
|
+
if File.exist?( xFileFound )
|
98
|
+
return xFileFound
|
99
|
+
end
|
99
100
|
end
|
100
101
|
end
|
101
102
|
end
|
@@ -112,11 +113,7 @@ class Rb2Gv
|
|
112
113
|
puts "Parse #{xFile} :" if DEBUG
|
113
114
|
end
|
114
115
|
|
115
|
-
|
116
|
-
xData = fp.read()
|
117
|
-
fp.close
|
118
|
-
|
119
|
-
xData.each do |xLine|
|
116
|
+
File.open(xFile, 'r').each_line do |xLine|
|
120
117
|
if lxLineMatch = REQUIRE.match( xLine )
|
121
118
|
xRequiredLib = lxLineMatch[2].gsub( /\.(rb|so)$/, "" )
|
122
119
|
|
@@ -132,7 +129,7 @@ class Rb2Gv
|
|
132
129
|
@hxNodes[xRequiredLib] = gv_newNode( xRequiredLib, "invhouse", "deepskyblue" )
|
133
130
|
end
|
134
131
|
else
|
135
|
-
if
|
132
|
+
if getLibraryPath( xRequiredLib, ["so", "bundle", "dll"] ) == nil
|
136
133
|
@hxNodes[xRequiredLib] = gv_newNode( xRequiredLib, "box", "red" )
|
137
134
|
else
|
138
135
|
@hxNodes[xRequiredLib] = gv_newNode( xRequiredLib, "box", "grey" )
|
@@ -165,7 +162,7 @@ def usage
|
|
165
162
|
end
|
166
163
|
|
167
164
|
def version
|
168
|
-
puts "Ruby2GraphViz v#{Constants::RGV_VERSION}, (c)2005, 2009, 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
165
|
+
puts "Ruby2GraphViz v#{GraphViz::Constants::RGV_VERSION}, (c)2005, 2009, 2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
169
166
|
puts ""
|
170
167
|
puts "This program is free software; you can redistribute it and/or modify"
|
171
168
|
puts "it under the terms of the GNU General Public License as published by"
|
@@ -219,7 +216,7 @@ begin
|
|
219
216
|
exit
|
220
217
|
end
|
221
218
|
end
|
222
|
-
rescue GetoptLong::InvalidOption
|
219
|
+
rescue GetoptLong::InvalidOption
|
223
220
|
usage( )
|
224
221
|
exit
|
225
222
|
end
|
data/bin/xml2gv
CHANGED
@@ -30,7 +30,7 @@ def usage
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def version
|
33
|
-
puts "XML2GraphViz v#{Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
33
|
+
puts "XML2GraphViz v#{GraphViz::Constants::RGV_VERSION}, (c)2010 Gregoire Lejeune <gregoire.lejeune@free.fr>"
|
34
34
|
puts ""
|
35
35
|
puts "This program is free software; you can redistribute it and/or modify"
|
36
36
|
puts "it under the terms of the GNU General Public License as published by"
|
@@ -80,7 +80,7 @@ begin
|
|
80
80
|
exit
|
81
81
|
end
|
82
82
|
end
|
83
|
-
rescue GetoptLong::InvalidOption
|
83
|
+
rescue GetoptLong::InvalidOption
|
84
84
|
usage( )
|
85
85
|
exit
|
86
86
|
end
|
data/examples/sample38.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
$:.unshift( "../lib" )
|
3
3
|
require "graphviz"
|
4
4
|
|
5
|
-
g = GraphViz::new( :G ) { |
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
g = GraphViz::new( :G ) { |_g|
|
6
|
+
_g.a[:label => "ε"]
|
7
|
+
_g.add_nodes( "b", :label => "ε" )
|
8
|
+
_g.c[:label => 'ε']
|
9
|
+
_g.add_nodes( "d", :label => 'ε' )
|
10
10
|
}
|
11
11
|
|
12
12
|
puts g.output( :none => String, :png => "#{$0}.png", :path => "/usr/local/bin" )
|
data/lib/graphviz.rb
CHANGED
@@ -26,6 +26,7 @@ require 'graphviz/edge'
|
|
26
26
|
require 'graphviz/attrs'
|
27
27
|
require 'graphviz/constants'
|
28
28
|
require 'graphviz/elements'
|
29
|
+
require 'graphviz/dot_script'
|
29
30
|
|
30
31
|
require 'graphviz/dot2ruby'
|
31
32
|
require 'graphviz/types'
|
@@ -36,38 +37,38 @@ if /^1.8/.match RUBY_VERSION
|
|
36
37
|
end
|
37
38
|
|
38
39
|
class GraphViz
|
39
|
-
include Constants
|
40
|
-
include
|
40
|
+
include GraphViz::Constants
|
41
|
+
include GraphViz::Utils
|
41
42
|
|
42
43
|
public
|
43
44
|
|
44
45
|
## Var: Output format (dot, png, jpeg, ...)
|
45
46
|
@@format = nil #"canon"
|
46
|
-
@format
|
47
|
+
@format = nil
|
47
48
|
## Var: Output file name
|
48
|
-
@filename
|
49
|
+
@filename = nil
|
49
50
|
## Var: Output format and file
|
50
|
-
@output
|
51
|
+
@output = nil
|
51
52
|
## Var: program to use (dot|twopi)
|
52
53
|
@@prog = "dot"
|
53
|
-
@prog
|
54
|
+
@prog = nil
|
54
55
|
## Var: program path
|
55
56
|
@@path = []
|
56
|
-
@path
|
57
|
+
@path = nil
|
57
58
|
## Var: Error level
|
58
59
|
@@errors = 1
|
59
|
-
@errors
|
60
|
+
@errors = nil
|
60
61
|
## Var: External libraries
|
61
62
|
@@extlibs = []
|
62
|
-
@extlibs
|
63
|
+
@extlibs = nil
|
63
64
|
|
64
65
|
## Var: Graph name
|
65
|
-
@name
|
66
|
+
@name = nil
|
66
67
|
|
67
68
|
## Var: defined attributes
|
68
|
-
@graph
|
69
|
-
@node
|
70
|
-
@edge
|
69
|
+
@graph = nil
|
70
|
+
@node = nil
|
71
|
+
@edge = nil
|
71
72
|
|
72
73
|
# This accessor allow you to set global graph attributes
|
73
74
|
attr_accessor :graph
|
@@ -81,12 +82,13 @@ class GraphViz
|
|
81
82
|
attr_accessor :edge
|
82
83
|
alias_method :edge_attrs, :edge
|
83
84
|
|
84
|
-
@elements_order
|
85
|
+
@elements_order = nil
|
85
86
|
|
86
|
-
#<b>DEPRECATED</b> please use GraphViz#add_nodes
|
87
87
|
def add_node( xNodeName, hOpts = {} )
|
88
|
-
|
89
|
-
|
88
|
+
if xNodeName.kind_of? Array
|
89
|
+
raise ArgumentError, "use `add_nodes' to add several nodes at the same time"
|
90
|
+
end
|
91
|
+
return add_nodes(xNodeName, hOpts)
|
90
92
|
end
|
91
93
|
|
92
94
|
# Create a new node
|
@@ -179,10 +181,11 @@ class GraphViz
|
|
179
181
|
@hoNodes.size
|
180
182
|
end
|
181
183
|
|
182
|
-
#<b>DEPRECATED</b> please use GraphViz#add_edges
|
183
184
|
def add_edge( oNodeOne, oNodeTwo, hOpts = {} )
|
184
|
-
|
185
|
-
|
185
|
+
if oNodeTwo.kind_of? Array or oNodeOne.kind_of? Array
|
186
|
+
raise ArgumentError, "use `add_edges' to add several edges at the same time"
|
187
|
+
end
|
188
|
+
add_edges(oNodeOne, oNodeTwo, hOpts)
|
186
189
|
end
|
187
190
|
|
188
191
|
# Create a new edge
|
@@ -409,9 +412,9 @@ class GraphViz
|
|
409
412
|
# Generate the graph
|
410
413
|
#
|
411
414
|
# Options :
|
412
|
-
# * :output : Output format (Constants::FORMATS)
|
415
|
+
# * :output : Output format (GraphViz::Constants::FORMATS)
|
413
416
|
# * :file : Output file name
|
414
|
-
# * :use : Program to use (Constants::PROGRAMS)
|
417
|
+
# * :use : Program to use (GraphViz::Constants::PROGRAMS)
|
415
418
|
# * :path : Program PATH
|
416
419
|
# * :<format> => <file> : <file> can be
|
417
420
|
# * a file name
|
@@ -423,86 +426,15 @@ class GraphViz
|
|
423
426
|
# * 2 = none
|
424
427
|
#
|
425
428
|
def output( hOpts = {} )
|
426
|
-
xDOTScript =
|
427
|
-
xLastType = nil
|
428
|
-
xSeparator = ""
|
429
|
-
xData = ""
|
429
|
+
xDOTScript = DOTScript.new
|
430
430
|
lNotHugly = []
|
431
431
|
|
432
|
-
|
433
|
-
if xLastType.nil? or xLastType != kElement["type"]
|
434
|
-
|
435
|
-
if xData.length > 0
|
436
|
-
case xLastType
|
437
|
-
when "graph_attr"
|
438
|
-
xDOTScript << " " + xData + ";\n"
|
439
|
-
|
440
|
-
when "node_attr"
|
441
|
-
xDOTScript << " node [" + xData + "];\n"
|
442
|
-
|
443
|
-
when "edge_attr"
|
444
|
-
xDOTScript << " edge [" + xData + "];\n"
|
445
|
-
end
|
446
|
-
end
|
447
|
-
|
448
|
-
xSeparator = ""
|
449
|
-
xData = ""
|
450
|
-
end
|
451
|
-
|
452
|
-
xLastType = kElement["type"]
|
453
|
-
|
454
|
-
#Modified by
|
455
|
-
#Brandon Coleman
|
456
|
-
#verify value is NOT NULL
|
457
|
-
if kElement["value"] == nil then
|
458
|
-
raise ArgumentError, "#{kElement["name"]} has a nil value!"
|
459
|
-
end
|
460
|
-
|
461
|
-
case kElement["type"]
|
462
|
-
when "graph_attr"
|
463
|
-
xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
|
464
|
-
xSeparator = "; "
|
465
|
-
|
466
|
-
when "node_attr"
|
467
|
-
xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
|
468
|
-
xSeparator = ", "
|
469
|
-
|
470
|
-
when "edge_attr"
|
471
|
-
xData << xSeparator + kElement["name"] + " = " + kElement["value"].to_gv
|
472
|
-
xSeparator = ", "
|
473
|
-
|
474
|
-
when "node"
|
475
|
-
xDOTScript << " " + kElement["value"].output() + "\n"
|
476
|
-
|
477
|
-
when "edge"
|
478
|
-
xDOTScript << " " + kElement["value"].output( @oGraphType ) + "\n"
|
479
|
-
|
480
|
-
when "graph"
|
481
|
-
xDOTScript << kElement["value"].output() + "\n"
|
482
|
-
|
483
|
-
else
|
484
|
-
raise ArgumentError, "Don't know what to do with element type '#{kElement['type']}'"
|
485
|
-
end
|
486
|
-
}
|
487
|
-
|
488
|
-
if xData.length > 0
|
489
|
-
case xLastType
|
490
|
-
when "graph_attr"
|
491
|
-
xDOTScript << " " + xData + ";\n"
|
432
|
+
append_attributes_and_types(xDOTScript)
|
492
433
|
|
493
|
-
when "node_attr"
|
494
|
-
xDOTScript << " node [" + xData + "];\n"
|
495
|
-
|
496
|
-
when "edge_attr"
|
497
|
-
xDOTScript << " edge [" + xData + "];\n"
|
498
|
-
end
|
499
|
-
end
|
500
434
|
xDOTScript << "}"
|
501
435
|
|
502
|
-
if
|
503
|
-
xDOTScript
|
504
|
-
|
505
|
-
return( xDOTScript )
|
436
|
+
if has_parent_graph?
|
437
|
+
xDOTScript.make_subgraph("#{GraphViz.escape(@name, :unquote_empty => true)}")
|
506
438
|
else
|
507
439
|
hOutput = {}
|
508
440
|
|
@@ -554,7 +486,7 @@ class GraphViz
|
|
554
486
|
begin
|
555
487
|
require 'graphviz/nothugly'
|
556
488
|
@nothugly = true
|
557
|
-
rescue LoadError
|
489
|
+
rescue LoadError
|
558
490
|
warn "You must install ruby-xslt or libxslt-ruby to use nothugly option!"
|
559
491
|
@nothugly = false
|
560
492
|
end
|
@@ -569,7 +501,9 @@ class GraphViz
|
|
569
501
|
@output = hOutput if hOutput.size > 0
|
570
502
|
|
571
503
|
xStict = ((@strict && @oGraphType == "digraph") ? "strict " : "")
|
572
|
-
xDOTScript
|
504
|
+
xDOTScript.prepend(
|
505
|
+
"#{xStict}#{@oGraphType} #{GraphViz.escape(@name, :unquote_empty => true)} {"
|
506
|
+
)
|
573
507
|
|
574
508
|
xOutputString = (@filename == String ||
|
575
509
|
@output.any? {|format, file| file == String })
|
@@ -633,7 +567,7 @@ class GraphViz
|
|
633
567
|
xOtherOptions += " -x" if @reduce_graph
|
634
568
|
xOtherOptions += " -Lg" if @Lg
|
635
569
|
xOtherOptions += " -LO" if @LO
|
636
|
-
xOtherOptions += " -Ln#{@Ln}" unless @
|
570
|
+
xOtherOptions += " -Ln#{@Ln}" unless @Ln.nil?
|
637
571
|
xOtherOptions += " -LU#{@LU}" unless @LU.nil?
|
638
572
|
xOtherOptions += " -LC#{@LC}" unless @LC.nil?
|
639
573
|
xOtherOptions += " -LT#{@LT}" unless @LT.nil?
|
@@ -671,9 +605,37 @@ class GraphViz
|
|
671
605
|
end
|
672
606
|
end
|
673
607
|
end
|
674
|
-
|
675
608
|
alias :save :output
|
676
609
|
|
610
|
+
def append_attributes_and_types(script)
|
611
|
+
script_data = DOTScriptData.new
|
612
|
+
|
613
|
+
@elements_order.each { |kElement|
|
614
|
+
is_new_type = script_data.type != kElement["type"]
|
615
|
+
if is_new_type
|
616
|
+
unless script_data.type.nil? or script_data.empty?
|
617
|
+
script << script_data
|
618
|
+
end
|
619
|
+
script_data = DOTScriptData.new(kElement["type"])
|
620
|
+
end
|
621
|
+
|
622
|
+
# Modified by Brandon Coleman verify value is NOT NULL
|
623
|
+
kElement["value"] or raise ArgumentError, "#{kElement["name"]} is nil!"
|
624
|
+
|
625
|
+
case kElement["type"]
|
626
|
+
when "graph_attr", "node_attr", "edge_attr"
|
627
|
+
script_data.add_attribute(kElement["name"], kElement["value"].to_gv)
|
628
|
+
when "node", "graph"
|
629
|
+
script << kElement["value"].output()
|
630
|
+
when "edge"
|
631
|
+
script << " " + kElement["value"].output( @oGraphType )
|
632
|
+
else
|
633
|
+
raise ArgumentError,
|
634
|
+
"Don't know what to do with element type '#{kElement['type']}'"
|
635
|
+
end
|
636
|
+
}
|
637
|
+
end
|
638
|
+
|
677
639
|
def to_s
|
678
640
|
self.output(:none => String)
|
679
641
|
end
|
@@ -755,7 +717,7 @@ class GraphViz
|
|
755
717
|
when "extlibs"
|
756
718
|
@@extlibs = v.split( "," ).map{ |x| x.strip }
|
757
719
|
else
|
758
|
-
warn "
|
720
|
+
warn "Invalid option #{k}!"
|
759
721
|
end
|
760
722
|
end
|
761
723
|
end
|
@@ -769,9 +731,9 @@ class GraphViz
|
|
769
731
|
# Create a new graph from a GraphViz File
|
770
732
|
#
|
771
733
|
# Options :
|
772
|
-
# * :output : Output format (Constants::FORMATS) (default : dot)
|
734
|
+
# * :output : Output format (GraphViz::Constants::FORMATS) (default : dot)
|
773
735
|
# * :file : Output file name (default : none)
|
774
|
-
# * :use : Program to use (Constants::PROGRAMS) (default : dot)
|
736
|
+
# * :use : Program to use (GraphViz::Constants::PROGRAMS) (default : dot)
|
775
737
|
# * :path : Program PATH
|
776
738
|
#
|
777
739
|
def self.parse( xFile, hOpts = {}, &block )
|
@@ -783,9 +745,9 @@ class GraphViz
|
|
783
745
|
# Create a new graph from a GraphViz File
|
784
746
|
#
|
785
747
|
# Options :
|
786
|
-
# * :output : Output format (Constants::FORMATS) (default : dot)
|
748
|
+
# * :output : Output format (GraphViz::Constants::FORMATS) (default : dot)
|
787
749
|
# * :file : Output file name (default : none)
|
788
|
-
# * :use : Program to use (Constants::PROGRAMS) (default : dot)
|
750
|
+
# * :use : Program to use (GraphViz::Constants::PROGRAMS) (default : dot)
|
789
751
|
# * :path : Program PATH
|
790
752
|
#
|
791
753
|
def self.parse_string( str, hOpts = {}, &block )
|
@@ -807,33 +769,37 @@ class GraphViz
|
|
807
769
|
|
808
770
|
# Return true if the graph is directed.
|
809
771
|
def directed?
|
810
|
-
|
772
|
+
not((/digraph/ =~ "bla digraph bla").nil?)
|
773
|
+
end
|
774
|
+
|
775
|
+
def has_parent_graph?
|
776
|
+
@oParentGraph
|
811
777
|
end
|
812
778
|
## ----------------------------------------------------------------------------
|
813
779
|
|
814
780
|
private
|
815
781
|
|
816
782
|
## Var: Nodes, Edges and Graphs tables
|
817
|
-
@hoNodes
|
818
|
-
@loEdges
|
819
|
-
@hoGraphs
|
783
|
+
@hoNodes = nil
|
784
|
+
@loEdges = nil
|
785
|
+
@hoGraphs = nil
|
820
786
|
|
821
787
|
## Var: Parent graph
|
822
|
-
@oParentGraph
|
788
|
+
@oParentGraph = nil
|
823
789
|
|
824
790
|
## Var: Type de graphe (orienté ou non)
|
825
|
-
@oGraphType
|
791
|
+
@oGraphType = nil
|
826
792
|
|
827
793
|
#
|
828
794
|
# Create a new graph object
|
829
795
|
#
|
830
796
|
# Options :
|
831
|
-
# * :output : Output format (Constants::FORMATS) (default : dot)
|
797
|
+
# * :output : Output format (GraphViz::Constants::FORMATS) (default : dot)
|
832
798
|
# * :file : Output file name (default : nil)
|
833
|
-
# * :use : Program to use (Constants::PROGRAMS) (default : dot)
|
799
|
+
# * :use : Program to use (GraphViz::Constants::PROGRAMS) (default : dot)
|
834
800
|
# * :path : Program PATH
|
835
801
|
# * :parent : Parent graph (default : nil)
|
836
|
-
# * :type : Graph type (Constants::GRAPHTYPE) (default : digraph)
|
802
|
+
# * :type : Graph type (GraphViz::Constants::GRAPHTYPE) (default : digraph)
|
837
803
|
# * :errors : DOT error level (default 1)
|
838
804
|
# * 0 = Error + Warning
|
839
805
|
# * 1 = Error
|
@@ -953,7 +919,7 @@ class GraphViz
|
|
953
919
|
end
|
954
920
|
|
955
921
|
nodes = (1..num_nodes).map{ |e| e.to_s }
|
956
|
-
|
922
|
+
g.add_nodes(nodes)
|
957
923
|
|
958
924
|
edges = []
|
959
925
|
nodes.each do |head|
|