ruby-graphviz 0.9.10 → 0.9.11
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 +5 -0
- data/examples/maketest.bat +6 -0
- data/examples/maketest.sh +6 -0
- data/examples/sample30.rb.ps +923 -0
- data/examples/sample37.rb +87 -0
- data/examples/sample37.rb.dot +50 -0
- data/examples/sample37.rb.png +0 -0
- data/examples/sample38.rb +11 -0
- data/lib/graphviz.rb +34 -17
- data/lib/graphviz/constants.rb +1 -1
- data/lib/graphviz/core_ext.rb +23 -0
- data/lib/graphviz/family_tree.rb +23 -4
- data/lib/graphviz/family_tree/couple.rb +3 -2
- data/lib/graphviz/family_tree/generation.rb +4 -4
- data/lib/graphviz/family_tree/person.rb +27 -3
- 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 +268 -0
- data/test/output/sample31.rb.png +0 -0
- data/test/output/sample32.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/sample40.rb.png +0 -0
- data/test/support.rb +100 -0
- data/test/test_examples.rb +130 -0
- metadata +47 -5
- data/examples/sample13b.rb +0 -48
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__),'support.rb')
|
|
2
|
+
|
|
3
|
+
class GraphVizTest < Test::Unit::TestCase
|
|
4
|
+
|
|
5
|
+
#
|
|
6
|
+
# you can run a subset of all the samples like this:
|
|
7
|
+
# ruby test/test_examples.rb --name='/sample3[6-9]/'
|
|
8
|
+
#
|
|
9
|
+
# The above will run samples 36, 37, 38, and 39
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
include IoHack
|
|
14
|
+
|
|
15
|
+
RootDir = File.expand_path('../..', __FILE__)
|
|
16
|
+
ExampleDir = File.join(RootDir,'examples')
|
|
17
|
+
OutputDir = File.join(File.dirname(__FILE__),'output')
|
|
18
|
+
# OutputDir = File.join(RootDir,'test','output')
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# the below tests write to stdout. the other tests write to filesystem
|
|
22
|
+
|
|
23
|
+
Skips = {
|
|
24
|
+
'35' => 'hanging for me',
|
|
25
|
+
'36' => 'hangs for me'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def test_sample07
|
|
30
|
+
assert_output_pattern(/\Adigraph structs \{.+\}\n\Z/m, '07')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def test_sample22
|
|
34
|
+
assert_output_pattern(/\Adigraph mainmap \{.+\}\n\Z/m, '22')
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def test_sample23
|
|
38
|
+
assert_output_pattern(%r{\A<map.+</map>\n\Z}m, '23')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def test_sample27
|
|
42
|
+
assert_output_pattern(/\Adigraph G \{.*\}\n\Z/m, '27')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def test_sample33
|
|
46
|
+
assert_output_pattern(/\Adigraph FamilyTree \{.+\}\n\Z/m, '33')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def test_sample38
|
|
50
|
+
assert_output_pattern(/\Adigraph G \{.*\}\n\Z/m, '38')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
# for every sample file in the examples directory that matches the
|
|
56
|
+
# pattern ("sample01.rb, sample02.rb, etc) make a corresponding
|
|
57
|
+
# test method: test_sample01(), test_sample02(), etc. To actually define
|
|
58
|
+
# this methods in this way instead of just iterating over the list of files
|
|
59
|
+
# will make it easier to use command-line options to isolate certain
|
|
60
|
+
# tests,
|
|
61
|
+
# (for example: ruby test/test_examples.rb --name '/sample0[1-5]/' )
|
|
62
|
+
# and to integrate better with certain kinds of test output and
|
|
63
|
+
# reporting tools.
|
|
64
|
+
#
|
|
65
|
+
# we will skip over any methods already defined
|
|
66
|
+
#
|
|
67
|
+
|
|
68
|
+
@last_image_path = nil
|
|
69
|
+
@number_to_path = {}
|
|
70
|
+
class << self
|
|
71
|
+
def make_sample_test_method path
|
|
72
|
+
fail("failed match: #{path}") unless
|
|
73
|
+
matches = %r{/(sample(\d\d))\.rb\Z}.match(path)
|
|
74
|
+
basename, number = matches.captures
|
|
75
|
+
number_to_path[number] = path
|
|
76
|
+
meth = "test_#{basename}"
|
|
77
|
+
return if method_defined?(meth) # if we hand-write one
|
|
78
|
+
if Skips[number]
|
|
79
|
+
puts "skipping #{basename} - #{Skips[number]}"
|
|
80
|
+
return
|
|
81
|
+
end
|
|
82
|
+
define_method(meth){ assert_sample_file_has_no_output(path) }
|
|
83
|
+
end
|
|
84
|
+
attr_accessor :last_image_path, :number_to_path
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
samples = Dir[File.join(ExampleDir,'sample*.rb')].sort
|
|
88
|
+
samples.each {|path| make_sample_test_method(path) }
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
private
|
|
92
|
+
|
|
93
|
+
def assert_output_pattern tgt_regexp, number
|
|
94
|
+
path = self.class.number_to_path[number]
|
|
95
|
+
setup_sample path
|
|
96
|
+
out, err = fake_popen2(path)
|
|
97
|
+
assert_equal "", err, "no errors"
|
|
98
|
+
assert_match tgt_regexp, out, "output for sample#{number} should match regexp"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def assert_sample_file_has_no_output path
|
|
102
|
+
setup_sample(path)
|
|
103
|
+
begin
|
|
104
|
+
out, err = fake_popen2(path)
|
|
105
|
+
assert_equal(0, out.length, "expecting empty output")
|
|
106
|
+
assert_equal(0, err.length, "expecting empty errorput")
|
|
107
|
+
msg = "maybe generated #{self.class.last_image_path}"
|
|
108
|
+
print "\n", msg
|
|
109
|
+
rescue Exception => e
|
|
110
|
+
assert(false, "got exception on #{File.basename(path)}: #{e.message}")
|
|
111
|
+
puts "out: ", out.inspect, "err:", err.inspect
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def setup_sample path
|
|
116
|
+
unless File.directory? OutputDir
|
|
117
|
+
FileUtils.mkdir_p(OutputDir, :verbose => true)
|
|
118
|
+
end
|
|
119
|
+
ARGV[0] = nil if ARGV.any? # hack trigger searching for 'dot' executable
|
|
120
|
+
hack_output_path path
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def hack_output_path path
|
|
124
|
+
# hack $0 to change where the output image is written to
|
|
125
|
+
fake_example_path = File.join(OutputDir, File.basename(path))
|
|
126
|
+
$0 = fake_example_path.dup
|
|
127
|
+
fail("hack failed") if ($0 != fake_example_path)
|
|
128
|
+
self.class.last_image_path = "#{$0}.png"
|
|
129
|
+
end
|
|
130
|
+
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 9
|
|
8
|
-
-
|
|
9
|
-
version: 0.9.
|
|
8
|
+
- 11
|
|
9
|
+
version: 0.9.11
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Gregoire Lejeune
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-
|
|
17
|
+
date: 2010-05-02 00:00:00 +02:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -89,7 +89,6 @@ files:
|
|
|
89
89
|
- examples/sample11.rb
|
|
90
90
|
- examples/sample12.rb
|
|
91
91
|
- examples/sample13.rb
|
|
92
|
-
- examples/sample13b.rb
|
|
93
92
|
- examples/sample14.rb
|
|
94
93
|
- examples/sample15.rb
|
|
95
94
|
- examples/sample16.rb
|
|
@@ -107,12 +106,17 @@ files:
|
|
|
107
106
|
- examples/sample28.rb
|
|
108
107
|
- examples/sample29.rb
|
|
109
108
|
- examples/sample30.rb
|
|
109
|
+
- examples/sample30.rb.ps
|
|
110
110
|
- examples/sample31.rb
|
|
111
111
|
- examples/sample32.rb
|
|
112
112
|
- examples/sample33.rb
|
|
113
113
|
- examples/sample34.rb
|
|
114
114
|
- examples/sample35.rb
|
|
115
115
|
- examples/sample36.rb
|
|
116
|
+
- examples/sample37.rb
|
|
117
|
+
- examples/sample37.rb.dot
|
|
118
|
+
- examples/sample37.rb.png
|
|
119
|
+
- examples/sample38.rb
|
|
116
120
|
- examples/sample40.rb
|
|
117
121
|
- examples/sdlshapes/README
|
|
118
122
|
- examples/sdlshapes/sdl.ps
|
|
@@ -138,6 +142,45 @@ files:
|
|
|
138
142
|
- lib/graphviz/types.rb
|
|
139
143
|
- lib/graphviz/xml.rb
|
|
140
144
|
- lib/graphviz.rb
|
|
145
|
+
- test/output/sample01.rb.png
|
|
146
|
+
- test/output/sample02.rb.png
|
|
147
|
+
- test/output/sample03.rb.png
|
|
148
|
+
- test/output/sample04.rb.png
|
|
149
|
+
- test/output/sample05.rb.png
|
|
150
|
+
- test/output/sample06.rb.png
|
|
151
|
+
- test/output/sample07.rb.png
|
|
152
|
+
- test/output/sample08.rb.png
|
|
153
|
+
- test/output/sample09.rb.png
|
|
154
|
+
- test/output/sample10.rb.png
|
|
155
|
+
- test/output/sample11.rb.png
|
|
156
|
+
- test/output/sample12.rb.png
|
|
157
|
+
- test/output/sample13.rb.png
|
|
158
|
+
- test/output/sample14.rb.png
|
|
159
|
+
- test/output/sample15.rb.png
|
|
160
|
+
- test/output/sample16.rb.png
|
|
161
|
+
- test/output/sample17.rb.png
|
|
162
|
+
- test/output/sample18.rb.png
|
|
163
|
+
- test/output/sample19.rb.png
|
|
164
|
+
- test/output/sample20.rb.png
|
|
165
|
+
- test/output/sample21.rb.html
|
|
166
|
+
- test/output/sample21.rb.png
|
|
167
|
+
- test/output/sample22.rb.html
|
|
168
|
+
- test/output/sample22.rb.png
|
|
169
|
+
- test/output/sample23.rb.png
|
|
170
|
+
- test/output/sample24.rb.png
|
|
171
|
+
- test/output/sample25.rb.png
|
|
172
|
+
- test/output/sample26.rb.png
|
|
173
|
+
- test/output/sample28.rb.png
|
|
174
|
+
- test/output/sample29.rb.svg
|
|
175
|
+
- test/output/sample30.rb.ps
|
|
176
|
+
- test/output/sample31.rb.png
|
|
177
|
+
- test/output/sample32.rb.png
|
|
178
|
+
- test/output/sample37.rb.dot
|
|
179
|
+
- test/output/sample37.rb.png
|
|
180
|
+
- test/output/sample38.rb.png
|
|
181
|
+
- test/output/sample40.rb.png
|
|
182
|
+
- test/support.rb
|
|
183
|
+
- test/test_examples.rb
|
|
141
184
|
- test/test_init.rb
|
|
142
185
|
has_rdoc: true
|
|
143
186
|
homepage: http://raa.ruby-lang.org/project/ruby-graphviz/
|
|
@@ -155,7 +198,6 @@ rdoc_options:
|
|
|
155
198
|
- Ruby/GraphViz
|
|
156
199
|
- --main
|
|
157
200
|
- README.rdoc
|
|
158
|
-
- --line-numbers
|
|
159
201
|
require_paths:
|
|
160
202
|
- lib
|
|
161
203
|
required_ruby_version: !ruby/object:Gem::Requirement
|
data/examples/sample13b.rb
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/ruby
|
|
2
|
-
|
|
3
|
-
$:.unshift( "../lib" );
|
|
4
|
-
require "graphviz"
|
|
5
|
-
|
|
6
|
-
puts GraphViz::new( "G" ) { |graph|
|
|
7
|
-
graph.node[:shape] = "ellipse"
|
|
8
|
-
graph.node[:color] = "black"
|
|
9
|
-
|
|
10
|
-
graph[:color] = "black"
|
|
11
|
-
|
|
12
|
-
graph.cluster0( ) do |cluster|
|
|
13
|
-
cluster[:label] = "process #1"
|
|
14
|
-
cluster[:style] = "filled"
|
|
15
|
-
cluster[:color] = "lightgrey"
|
|
16
|
-
|
|
17
|
-
cluster.a0 :style => "filled", :color => "white"
|
|
18
|
-
cluster.a1 :style => "filled", :color => "white"
|
|
19
|
-
cluster.a2 :style => "filled", :color => "white"
|
|
20
|
-
cluster.a3 :style => "filled", :color => "white"
|
|
21
|
-
|
|
22
|
-
cluster.a0 << cluster.a1
|
|
23
|
-
cluster.a1 << cluster.a2
|
|
24
|
-
cluster.a2 << cluster.a3
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
graph.cluster1( :label => "process #2" ) do |cluster|
|
|
28
|
-
cluster.b0 :style => "filled", :color => "blue"
|
|
29
|
-
cluster.b1 :style => "filled", :color => "blue"
|
|
30
|
-
cluster.b2 :style => "filled", :color => "blue"
|
|
31
|
-
cluster.b3 :style => "filled", :color => "blue"
|
|
32
|
-
|
|
33
|
-
cluster.b0 << cluster.b1
|
|
34
|
-
cluster.b1 << cluster.b2
|
|
35
|
-
cluster.b2 << cluster.b3
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
graph.start :shape => "Mdiamond"
|
|
39
|
-
graph.endn :shape => "Msquare", :label => "end"
|
|
40
|
-
|
|
41
|
-
graph.start << graph.cluster0.a0
|
|
42
|
-
graph.start << graph.cluster1.b0
|
|
43
|
-
graph.cluster0.a1 << graph.cluster1.b3
|
|
44
|
-
graph.cluster1.b2 << graph.cluster0.a3
|
|
45
|
-
graph.cluster0.a3 << graph.cluster0.a0
|
|
46
|
-
graph.cluster0.a3 << graph.endn
|
|
47
|
-
graph.cluster1.b3 << graph.endn
|
|
48
|
-
}.output( :path => '/usr/local/bin/', :none => String )
|