arquanator 0.0.2

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 (58) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +2 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +36 -0
  7. data/Rakefile +7 -0
  8. data/arquanator.gemspec +22 -0
  9. data/bin/arquanator +5 -0
  10. data/lib/arquanator.rb +25 -0
  11. data/lib/arquanator/version.rb +3 -0
  12. data/lib/arquanator_options.rb +47 -0
  13. data/lib/generators/dependency_list/dependency_list_generator.rb +31 -0
  14. data/lib/generators/generator_factory.rb +18 -0
  15. data/lib/generators/graphviz/collection_drawer.rb +93 -0
  16. data/lib/generators/graphviz/empty_collection_drawer.rb +26 -0
  17. data/lib/generators/graphviz/empty_drawer.rb +11 -0
  18. data/lib/generators/graphviz/file_leaf_drawer.rb +24 -0
  19. data/lib/generators/graphviz/folder_leaf_drawer.rb +19 -0
  20. data/lib/generators/graphviz/function_leaf_drawer.rb +15 -0
  21. data/lib/generators/graphviz/graph_drawer.rb +67 -0
  22. data/lib/generators/graphviz/graph_drawer_factory.rb +36 -0
  23. data/lib/generators/graphviz/graphviz_generator.rb +19 -0
  24. data/lib/generators/nil_generator.rb +8 -0
  25. data/lib/generators/smell_list/smell_list_generator.rb +51 -0
  26. data/lib/model/base_node.rb +62 -0
  27. data/lib/model/collection_node.rb +120 -0
  28. data/lib/model/file_node.rb +56 -0
  29. data/lib/model/folder_node.rb +36 -0
  30. data/lib/model/function_node.rb +49 -0
  31. data/lib/providers/c_gcc_file_provider.rb +36 -0
  32. data/lib/providers/c_gcc_provider.rb +13 -0
  33. data/lib/providers/folder_provider.rb +29 -0
  34. data/lib/providers/java_provider.rb +23 -0
  35. data/lib/providers/jruby_file_provider.rb +38 -0
  36. data/lib/providers/jruby_provider.rb +13 -0
  37. data/lib/providers/llvm_c_obj_c_file_provider.rb +59 -0
  38. data/lib/providers/llvm_c_obj_c_provider.rb +13 -0
  39. data/lib/providers/nil_provider.rb +7 -0
  40. data/lib/providers/provider_factory.rb +20 -0
  41. data/spec/arquanator_options_spec.rb +83 -0
  42. data/spec/c_gcc_file_provider_spec.rb +59 -0
  43. data/spec/c_gcc_provider_spec.rb +13 -0
  44. data/spec/dependency_list_generator_spec.rb +27 -0
  45. data/spec/file_spec.rb +207 -0
  46. data/spec/folder_provider_spec.rb +20 -0
  47. data/spec/folder_spec.rb +215 -0
  48. data/spec/function_spec.rb +73 -0
  49. data/spec/generator_factory_spec.rb +32 -0
  50. data/spec/graphviz_generator_spec.rb +462 -0
  51. data/spec/java_provider_spec.rb +31 -0
  52. data/spec/llvm_c_obj_c_file_provider_spec.rb +76 -0
  53. data/spec/llvm_c_obj_c_provider_spec.rb +14 -0
  54. data/spec/nil_generator_spec.rb +44 -0
  55. data/spec/provider_factory_spec.rb +34 -0
  56. data/spec/smell_list_generator_spec.rb +33 -0
  57. data/spec/spec_helper.rb +21 -0
  58. metadata +145 -0
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+ require 'model/function_node'
3
+
4
+ describe FunctionNode do
5
+ it "should have a name" do
6
+ function = FunctionNode.new "functionname", "location", :public, 1
7
+ function.name.should eq "functionname"
8
+ function.location.should eq "location"
9
+ end
10
+
11
+ it "should have a location" do
12
+ function = FunctionNode.new "functionname", "location", :public, 1
13
+ function.location.should eq "location"
14
+ end
15
+
16
+ it "should be public" do
17
+ function = FunctionNode.new "functionname", "location", :public, 1
18
+ function.private?.should eq false
19
+ end
20
+
21
+ it "should be private when creating a private function" do
22
+ function = FunctionNode.new "functionname", "location", :private, 1
23
+ function.private?.should eq true
24
+ end
25
+
26
+ it "should have a location" do
27
+ function = FunctionNode.new "functionname", "location", :public, 1
28
+ function.location.should eq "location"
29
+ end
30
+
31
+ it "should have a path" do
32
+ function = FunctionNode.new "functionname", "location", :public, 1
33
+ function.path.should eq "location/functionname"
34
+ end
35
+
36
+ it "should have 0 smells without nodes" do
37
+ function = FunctionNode.new "functionname", "location", :public, 1
38
+ function.smells.should eq 0
39
+ end
40
+
41
+ it "should have 0 size without nodes" do
42
+ function = FunctionNode.new "functionname", "location", :public, 1
43
+ function.size.should eq 0
44
+ end
45
+
46
+ it "should have 100% quality without nodes" do
47
+ function = FunctionNode.new "functionname", "location", :public, 1
48
+ function.quality.should eq 1
49
+ end
50
+
51
+ it "should have one function" do
52
+ function = FunctionNode.new "functionname", "location", :public, 1
53
+ function.functions[0].should eq "functionname"
54
+ end
55
+
56
+ it "should increase it's size" do
57
+ function = FunctionNode.new "functionname", "location", :public, 1
58
+ function.increase_size
59
+ function.increase_size
60
+ function.size.should eq 2
61
+ end
62
+
63
+ it "should calculate cyclomatic complexity" do
64
+ function = FunctionNode.new "functionname", "location", :public, 1
65
+ function.increase_edges
66
+ function.increase_edges
67
+ function.increase_edges
68
+ function.increase_nodes
69
+ function.increase_nodes
70
+ function.complexity.should eq 3
71
+ end
72
+ end
73
+
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+ require 'generators/generator_factory'
3
+ require 'generators/dependency_list/dependency_list_generator'
4
+ require 'generators/graphviz/graphviz_generator'
5
+ require 'generators/smell_list/smell_list_generator'
6
+ require 'generators/nil_generator'
7
+
8
+ describe GeneratorFactory do
9
+ it "should return a dependency list generator" do
10
+ generator = GeneratorFactory.create_generator(
11
+ {:generator => "dependencies"})
12
+ generator.class.should == DependencyListGenerator
13
+ end
14
+
15
+ it "should return a graphviz generator" do
16
+ generator = GeneratorFactory.create_generator(
17
+ {:generator => "graphviz"})
18
+ generator.class.should == GraphvizGenerator
19
+ end
20
+
21
+ it "should return a smell list generator" do
22
+ generator = GeneratorFactory.create_generator(
23
+ {:generator => "smells"})
24
+ generator.class.should == SmellListGenerator
25
+ end
26
+
27
+ it "should return a nil generator for unknown strings" do
28
+ generator = GeneratorFactory.create_generator(
29
+ {:generator => "test"})
30
+ generator.class.should == NilGenerator
31
+ end
32
+ end
@@ -0,0 +1,462 @@
1
+ require 'spec_helper'
2
+ require 'model/folder_node'
3
+ require 'generators/graphviz/graphviz_generator'
4
+
5
+ describe GraphvizGenerator do
6
+ it "should generate a graphviz report without folders" do
7
+ root = FolderNode.new "root", "location", :public, 1
8
+ folder1 = root.add_public_folder "folder1"
9
+ folder2 = root.add_public_folder "folder2"
10
+ file1 = folder1.add_public_file "file1"
11
+ file2 = folder1.add_public_file "file2"
12
+ file3 = folder2.add_public_file "file3"
13
+ file4 = root.add_public_file "file4"
14
+ function1 = file1.add_public_function "function1"
15
+ function2 = file1.add_public_function "function2"
16
+ function3 = file2.add_public_function "function3"
17
+ function4 = file3.add_public_function "function4"
18
+ function5 = file4.add_public_function "function5"
19
+ file1.add_dependency "function1", "function2"
20
+ file1.add_dependency "function2", "function1"
21
+ file2.add_dependency "function3", "function1"
22
+ file2.add_dependency "function3", "function2"
23
+ file2.add_dependency "function3", "function2"
24
+ file3.add_dependency "function4", "function2"
25
+ file4.add_dependency "function5", "function2"
26
+ (1..100).each do
27
+ function1.increase_edges
28
+ function2.increase_edges
29
+ function1.increase_size
30
+ function2.increase_size
31
+ end
32
+ config = {
33
+ :url => false,
34
+ :levels => 0,
35
+ :functions => true,
36
+ :files => true,
37
+ :folders => false
38
+ }
39
+ generator = GraphvizGenerator.new config
40
+ report = generator.generate(root)
41
+ report.should == <<EOF
42
+ digraph system {
43
+ compound=true;
44
+ subgraph "cluster_location/root/folder1/file1" {
45
+ fontcolor="black";fillcolor="/greens9/7";style=filled;label="file1\\nQ=43% T=100%";
46
+ "location/root/folder1/file1" [shape=none, label="", width=0, style=invisible];
47
+ "location/root/folder1/file1/function1"->"location/root/folder1/file1/function2" [label="1", color=crimson, fontcolor=crimson, style=bold];
48
+ "location/root/folder1/file1/function2"->"location/root/folder1/file1/function1" [label="1", color=crimson, fontcolor=crimson, style=bold];
49
+ "location/root/folder1/file1/function1" [style=filled, label="function1\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
50
+ "location/root/folder1/file1/function2" [style=filled, label="function2\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
51
+ }
52
+ subgraph "cluster_location/root/folder1/file2" {
53
+ fontcolor="black";fillcolor="white";style=filled;label="file2";
54
+ "location/root/folder1/file2" [shape=none, label="", width=0, style=invisible];
55
+ "location/root/folder1/file2/function3" [style=filled, label="function3" fontcolor="black",fillcolor="white"];
56
+ }
57
+ subgraph "cluster_location/root/folder2/file3" {
58
+ fontcolor="black";fillcolor="white";style=filled;label="file3";
59
+ "location/root/folder2/file3" [shape=none, label="", width=0, style=invisible];
60
+ "location/root/folder2/file3/function4" [style=filled, label="function4" fontcolor="black",fillcolor="white"];
61
+ }
62
+ subgraph "cluster_location/root/file4" {
63
+ fontcolor="black";fillcolor="white";style=filled;label="file4";
64
+ "location/root/file4" [shape=none, label="", width=0, style=invisible];
65
+ "location/root/file4/function5" [style=filled, label="function5" fontcolor="black",fillcolor="white"];
66
+ }
67
+ }
68
+ EOF
69
+ end
70
+
71
+ it "should generate a graphviz report with root setting" do
72
+ root = FolderNode.new "root", "", :public, 1
73
+ folder1 = root.add_public_folder "folder1"
74
+ folder2 = root.add_public_folder "folder2"
75
+ file1 = folder1.add_public_file "file1"
76
+ file2 = folder1.add_public_file "file2"
77
+ file3 = folder2.add_public_file "file3"
78
+ file4 = root.add_public_file "file4"
79
+ function1 = file1.add_public_function "function1"
80
+ function2 = file1.add_public_function "function2"
81
+ function3 = file2.add_public_function "function3"
82
+ function4 = file3.add_public_function "function4"
83
+ function5 = file4.add_public_function "function5"
84
+ file1.add_dependency "function1", "function2"
85
+ file1.add_dependency "function2", "function1"
86
+ file2.add_dependency "function3", "function1"
87
+ file2.add_dependency "function3", "function2"
88
+ file2.add_dependency "function3", "function2"
89
+ file3.add_dependency "function4", "function2"
90
+ file4.add_dependency "function5", "function2"
91
+ (1..100).each do
92
+ function1.increase_edges
93
+ function2.increase_edges
94
+ function1.increase_size
95
+ function2.increase_size
96
+ end
97
+ config = {
98
+ :url => false,
99
+ :levels => 0,
100
+ :functions => true,
101
+ :files => true,
102
+ :folders => false,
103
+ :root => "root/folder1"
104
+ }
105
+ generator = GraphvizGenerator.new config
106
+ report = generator.generate(root)
107
+ report.should == <<EOF
108
+ digraph system {
109
+ compound=true;
110
+ subgraph "cluster_root/folder1/file1" {
111
+ fontcolor="black";fillcolor="/greens9/7";style=filled;label="file1\\nQ=43% T=100%";
112
+ "root/folder1/file1" [shape=none, label="", width=0, style=invisible];
113
+ "root/folder1/file1/function1"->"root/folder1/file1/function2" [label="1", color=crimson, fontcolor=crimson, style=bold];
114
+ "root/folder1/file1/function2"->"root/folder1/file1/function1" [label="1", color=crimson, fontcolor=crimson, style=bold];
115
+ "root/folder1/file1/function1" [style=filled, label="function1\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
116
+ "root/folder1/file1/function2" [style=filled, label="function2\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
117
+ }
118
+ subgraph "cluster_root/folder1/file2" {
119
+ fontcolor="black";fillcolor="white";style=filled;label="file2";
120
+ "root/folder1/file2" [shape=none, label="", width=0, style=invisible];
121
+ "root/folder1/file2/function3" [style=filled, label="function3" fontcolor="black",fillcolor="white"];
122
+ }
123
+ }
124
+ EOF
125
+ end
126
+
127
+ it "should generate a graphviz report with functions files and folders and all levels" do
128
+ root = FolderNode.new "root", "location", :public, 1
129
+ folder1 = root.add_public_folder "folder1"
130
+ folder2 = root.add_public_folder "folder2"
131
+ file1 = folder1.add_public_file "file1"
132
+ file2 = folder1.add_public_file "file2"
133
+ file3 = folder2.add_public_file "file3"
134
+ file4 = root.add_public_file "file4"
135
+ function1 = file1.add_public_function "function1"
136
+ function2 = file1.add_public_function "function2"
137
+ function3 = file2.add_public_function "function3"
138
+ function4 = file3.add_public_function "function4"
139
+ function5 = file4.add_public_function "function5"
140
+ file1.add_dependency "function1", "function2"
141
+ file1.add_dependency "function2", "function1"
142
+ file2.add_dependency "function3", "function1"
143
+ file2.add_dependency "function3", "function2"
144
+ file2.add_dependency "function3", "function2"
145
+ file3.add_dependency "function4", "function2"
146
+ file4.add_dependency "function5", "function2"
147
+ (1..100).each do
148
+ function1.increase_edges
149
+ function2.increase_edges
150
+ function1.increase_size
151
+ function2.increase_size
152
+ end
153
+ config = {
154
+ :url => false,
155
+ :levels => 0,
156
+ :functions => true,
157
+ :files => true,
158
+ :folders => true
159
+ }
160
+ generator = GraphvizGenerator.new config
161
+ report = generator.generate(root)
162
+ report.should == <<EOF
163
+ digraph system {
164
+ compound=true;
165
+ subgraph "cluster_location/root" {
166
+ fontcolor="black";fillcolor="/greens9/4";style=filled;label="root\\nQ=76%";
167
+ "location/root" [shape=none, label="", width=0, style=invisible];
168
+ "location/root/folder2"->"location/root/folder1" [label="1", ltail="cluster_location/root/folder2", lhead="cluster_location/root/folder1"];
169
+ "location/root/file4"->"location/root/folder1" [label="1", ltail="cluster_location/root/file4", lhead="cluster_location/root/folder1"];
170
+ subgraph "cluster_location/root/folder1" {
171
+ fontcolor="black";fillcolor="/greens9/5";style=filled;label="folder1\\nQ=66%";
172
+ "location/root/folder1" [shape=none, label="", width=0, style=invisible];
173
+ "location/root/folder1/file2"->"location/root/folder1/file1" [label="3", ltail="cluster_location/root/folder1/file2", lhead="cluster_location/root/folder1/file1"];
174
+ subgraph "cluster_location/root/folder1/file1" {
175
+ fontcolor="black";fillcolor="/greens9/7";style=filled;label="file1\\nQ=43% T=100%";
176
+ "location/root/folder1/file1" [shape=none, label="", width=0, style=invisible];
177
+ "location/root/folder1/file1/function1"->"location/root/folder1/file1/function2" [label="1", color=crimson, fontcolor=crimson, style=bold];
178
+ "location/root/folder1/file1/function2"->"location/root/folder1/file1/function1" [label="1", color=crimson, fontcolor=crimson, style=bold];
179
+ "location/root/folder1/file1/function1" [style=filled, label="function1\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
180
+ "location/root/folder1/file1/function2" [style=filled, label="function2\\nQ=29% C=71%" fontcolor="white",fillcolor="/greens9/8"];
181
+ }
182
+ subgraph "cluster_location/root/folder1/file2" {
183
+ fontcolor="black";fillcolor="white";style=filled;label="file2";
184
+ "location/root/folder1/file2" [shape=none, label="", width=0, style=invisible];
185
+ "location/root/folder1/file2/function3" [style=filled, label="function3" fontcolor="black",fillcolor="white"];
186
+ }
187
+ }
188
+ subgraph "cluster_location/root/folder2" {
189
+ fontcolor="black";fillcolor="white";style=filled;label="folder2";
190
+ "location/root/folder2" [shape=none, label="", width=0, style=invisible];
191
+ subgraph "cluster_location/root/folder2/file3" {
192
+ fontcolor="black";fillcolor="white";style=filled;label="file3";
193
+ "location/root/folder2/file3" [shape=none, label="", width=0, style=invisible];
194
+ "location/root/folder2/file3/function4" [style=filled, label="function4" fontcolor="black",fillcolor="white"];
195
+ }
196
+ }
197
+ subgraph "cluster_location/root/file4" {
198
+ fontcolor="black";fillcolor="white";style=filled;label="file4";
199
+ "location/root/file4" [shape=none, label="", width=0, style=invisible];
200
+ "location/root/file4/function5" [style=filled, label="function5" fontcolor="black",fillcolor="white"];
201
+ }
202
+ }
203
+ }
204
+ EOF
205
+ end
206
+
207
+ it "should generate a graphviz report with two levels without files and functions" do
208
+ root = FolderNode.new "root", "location", :public, 1
209
+ folder1 = root.add_public_folder "folder1"
210
+ folder2 = root.add_public_folder "folder2"
211
+ file1 = folder1.add_public_file "file1"
212
+ file2 = folder1.add_public_file "file2"
213
+ file3 = folder2.add_public_file "file3"
214
+ file4 = root.add_public_file "file4"
215
+ function1 = file1.add_public_function "function1"
216
+ function2 = file1.add_public_function "function2"
217
+ function3 = file2.add_public_function "function3"
218
+ function4 = file3.add_public_function "function4"
219
+ function5 = file4.add_public_function "function5"
220
+ file1.add_dependency "function1", "function2"
221
+ file1.add_dependency "function2", "function1"
222
+ file2.add_dependency "function3", "function1"
223
+ file3.add_dependency "function4", "function2"
224
+ file4.add_dependency "function5", "function2"
225
+ (1..100).each do
226
+ function1.increase_edges
227
+ function2.increase_edges
228
+ function1.increase_size
229
+ function2.increase_size
230
+ end
231
+ config = {
232
+ :url => false,
233
+ :levels => 2,
234
+ :functions => false,
235
+ :files => false,
236
+ :folders => true
237
+ }
238
+ generator = GraphvizGenerator.new config
239
+ report = generator.generate(root)
240
+ report.should == <<EOF
241
+ digraph system {
242
+ compound=true;
243
+ subgraph "cluster_location/root" {
244
+ fontcolor="black";fillcolor="/greens9/4";style=filled;label="root\\nQ=76%";
245
+ "location/root" [shape=none, label="", width=0, style=invisible];
246
+ "location/root/folder2"->"location/root/folder1" [label="1"];
247
+ "location/root/folder1" [fontcolor="black", fillcolor="/greens9/5", label="folder1\\nQ=66%", shape=tab, style=filled];
248
+ "location/root/folder2" [fontcolor="black", fillcolor="white", label="folder2", shape=tab, style=filled];
249
+ }
250
+ }
251
+ EOF
252
+ end
253
+
254
+ it "should generate a graphviz report with all levels without functions" do
255
+ root = FolderNode.new "root", "location", :public, 1
256
+ folder1 = root.add_public_folder "folder1"
257
+ folder2 = root.add_public_folder "folder2"
258
+ file1 = folder1.add_public_file "file1"
259
+ file2 = folder1.add_public_file "file2"
260
+ file3 = folder2.add_public_file "file3"
261
+ file4 = root.add_public_file "file4"
262
+ function1 = file1.add_public_function "function1"
263
+ function2 = file1.add_public_function "function2"
264
+ function3 = file2.add_public_function "function3"
265
+ function4 = file3.add_public_function "function4"
266
+ function5 = file4.add_public_function "function5"
267
+ file1.add_dependency "function1", "function2"
268
+ file1.add_dependency "function2", "function1"
269
+ file2.add_dependency "function3", "function1"
270
+ file3.add_dependency "function4", "function2"
271
+ file4.add_dependency "function5", "function2"
272
+ (1..100).each do
273
+ function1.increase_edges
274
+ function2.increase_edges
275
+ function1.increase_size
276
+ function2.increase_size
277
+ end
278
+ config = {
279
+ :url => false,
280
+ :levels => 0,
281
+ :functions => false,
282
+ :files => true,
283
+ :folders => true
284
+ }
285
+ generator = GraphvizGenerator.new config
286
+ report = generator.generate(root)
287
+ report.should == <<EOF
288
+ digraph system {
289
+ compound=true;
290
+ subgraph "cluster_location/root" {
291
+ fontcolor="black";fillcolor="/greens9/4";style=filled;label="root\\nQ=76%";
292
+ "location/root" [shape=none, label="", width=0, style=invisible];
293
+ "location/root/folder2"->"location/root/folder1" [label="1", ltail="cluster_location/root/folder2", lhead="cluster_location/root/folder1"];
294
+ "location/root/file4"->"location/root/folder1" [label="1", lhead="cluster_location/root/folder1"];
295
+ subgraph "cluster_location/root/folder1" {
296
+ fontcolor="black";fillcolor="/greens9/5";style=filled;label="folder1\\nQ=66%";
297
+ "location/root/folder1" [shape=none, label="", width=0, style=invisible];
298
+ "location/root/folder1/file2"->"location/root/folder1/file1" [label="1"];
299
+ "location/root/folder1/file1" [fontcolor="black", fillcolor="/greens9/7", label="{file1|Q=43% T=100%|}", shape=record, style=filled];
300
+ "location/root/folder1/file2" [fontcolor="black", fillcolor="white", label="{file2||}", shape=record, style=filled];
301
+ }
302
+ subgraph "cluster_location/root/folder2" {
303
+ fontcolor="black";fillcolor="white";style=filled;label="folder2";
304
+ "location/root/folder2" [shape=none, label="", width=0, style=invisible];
305
+ "location/root/folder2/file3" [fontcolor="black", fillcolor="white", label="{file3||}", shape=record, style=filled];
306
+ }
307
+ "location/root/file4" [fontcolor="black", fillcolor="white", label="{file4||}", shape=record, style=filled];
308
+ }
309
+ }
310
+ EOF
311
+ end
312
+
313
+ it "should generate a graphviz report with two levels" do
314
+ folder = FolderNode.new "foldername", "location", :public, 1
315
+ file1 = folder.add_public_file "file1"
316
+ file2 = folder.add_public_file "file2"
317
+ function1 = file1.add_public_function "function1"
318
+ function2 = file1.add_public_function "function2"
319
+ file1.add_dependency "function1", "function2"
320
+ file1.add_dependency "function2", "function1"
321
+ (1..100).each do
322
+ function1.increase_edges
323
+ function2.increase_edges
324
+ function1.increase_size
325
+ function2.increase_size
326
+ end
327
+ config = {
328
+ :url => false,
329
+ :levels => 2,
330
+ :functions => true,
331
+ :files => true,
332
+ :folders => true
333
+ }
334
+ generator = GraphvizGenerator.new config
335
+ report = generator.generate(folder)
336
+ report.should == <<EOF
337
+ digraph system {
338
+ compound=true;
339
+ subgraph "cluster_location/foldername" {
340
+ fontcolor="black";fillcolor="/greens9/5";style=filled;label="foldername\\nQ=66%";
341
+ "location/foldername" [shape=none, label="", width=0, style=invisible];
342
+ "location/foldername/file1" [fontcolor="black", fillcolor="/greens9/7", label="{file1|Q=43% T=100%|}", shape=record, style=filled];
343
+ "location/foldername/file2" [fontcolor="black", fillcolor="white", label="{file2||}", shape=record, style=filled];
344
+ }
345
+ }
346
+ EOF
347
+ end
348
+
349
+ it "should generate a graphviz report with three levels" do
350
+ root = FolderNode.new "root", "location", :public, 1
351
+ folder = root.add_public_folder "folder1"
352
+ file1 = folder.add_public_file "file1"
353
+ file2 = folder.add_public_file "file2"
354
+ function1 = file1.add_public_function "function1"
355
+ function2 = file1.add_public_function "function2"
356
+ file1.add_dependency "function1", "function2"
357
+ file1.add_dependency "function2", "function1"
358
+ (1..100).each do
359
+ function1.increase_edges
360
+ function2.increase_edges
361
+ function1.increase_size
362
+ function2.increase_size
363
+ end
364
+ config = {
365
+ :url => false,
366
+ :levels => 3,
367
+ :functions => true,
368
+ :files => true,
369
+ :folders => true
370
+ }
371
+ generator = GraphvizGenerator.new config
372
+ report = generator.generate(root)
373
+ report.should == <<EOF
374
+ digraph system {
375
+ compound=true;
376
+ subgraph "cluster_location/root" {
377
+ fontcolor="black";fillcolor="/greens9/4";style=filled;label="root\\nQ=76%";
378
+ "location/root" [shape=none, label="", width=0, style=invisible];
379
+ subgraph "cluster_location/root/folder1" {
380
+ fontcolor="black";fillcolor="/greens9/5";style=filled;label="folder1\\nQ=66%";
381
+ "location/root/folder1" [shape=none, label="", width=0, style=invisible];
382
+ "location/root/folder1/file1" [fontcolor="black", fillcolor="/greens9/7", label="{file1|Q=43% T=100%|}", shape=record, style=filled];
383
+ "location/root/folder1/file2" [fontcolor="black", fillcolor="white", label="{file2||}", shape=record, style=filled];
384
+ }
385
+ }
386
+ }
387
+ EOF
388
+ end
389
+
390
+ it "should generate a graphviz report with one level" do
391
+ folder = FolderNode.new "foldername", "location", :public, 1
392
+ file1 = folder.add_public_file "file1"
393
+ file2 = folder.add_public_file "file2"
394
+ function1 = file1.add_public_function "function1"
395
+ function2 = file1.add_public_function "function2"
396
+ file1.add_dependency "function1", "function2"
397
+ file1.add_dependency "function2", "function1"
398
+ (1..100).each do
399
+ function1.increase_edges
400
+ function2.increase_edges
401
+ function1.increase_size
402
+ function2.increase_size
403
+ end
404
+ config = {
405
+ :url => false,
406
+ :levels => 1,
407
+ :functions => true,
408
+ :files => true,
409
+ :folders => true
410
+ }
411
+ generator = GraphvizGenerator.new config
412
+ report = generator.generate(folder)
413
+ report.should == <<EOF
414
+ digraph system {
415
+ compound=true;
416
+ "location/foldername" [fontcolor="black", fillcolor="/greens9/5", label="foldername\\nQ=66%", shape=tab, style=filled];
417
+ }
418
+ EOF
419
+ end
420
+
421
+ it "should generate a graphviz report with three levels and url" do
422
+ root = FolderNode.new "root", "location", :public, 1
423
+ folder = root.add_public_folder "folder1"
424
+ file1 = folder.add_public_file "file1"
425
+ file2 = folder.add_public_file "file2"
426
+ function1 = file1.add_public_function "function1"
427
+ function2 = file1.add_public_function "function2"
428
+ file1.add_dependency "function1", "function2"
429
+ file1.add_dependency "function2", "function1"
430
+ (1..100).each do
431
+ function1.increase_edges
432
+ function2.increase_edges
433
+ function1.increase_size
434
+ function2.increase_size
435
+ end
436
+ config = {
437
+ :url => true,
438
+ :root => "location/root",
439
+ :levels => 0,
440
+ :functions => false,
441
+ :files => true,
442
+ :folders => true
443
+ }
444
+ generator = GraphvizGenerator.new config
445
+ report = generator.generate(root)
446
+ report.should == <<EOF
447
+ digraph system {
448
+ compound=true;
449
+ subgraph "cluster_location/root" {
450
+ fontcolor="black";fillcolor="/greens9/4";URL="/index.svg";style=filled;label="root\\nQ=76%";
451
+ "location/root" [shape=none, label="", width=0, style=invisible];
452
+ subgraph "cluster_location/root/folder1" {
453
+ fontcolor="black";fillcolor="/greens9/5";URL="folder1/index.svg";style=filled;label="folder1\\nQ=66%";
454
+ "location/root/folder1" [shape=none, label="", width=0, style=invisible];
455
+ "location/root/folder1/file1" [URL="folder1/file1.svg" , fontcolor="black", fillcolor="/greens9/7", label="{file1|Q=43% T=100%|}", shape=record, style=filled];
456
+ "location/root/folder1/file2" [URL="folder1/file2.svg" , fontcolor="black", fillcolor="white", label="{file2||}", shape=record, style=filled];
457
+ }
458
+ }
459
+ }
460
+ EOF
461
+ end
462
+ end