Class: Cs_Sln_Graph

Inherits:
Object
  • Object
show all
Defined in:
lib/cs_sln_graph.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, output, format) ⇒ Cs_Sln_Graph

initialize the graph class



8
9
10
11
12
13
14
# File 'lib/cs_sln_graph.rb', line 8

def initialize(input, output, format)
	@input_path = input
	@output_path = output
	@format = format
	@graph = GraphViz.new("G")
	format_graph
end

Instance Method Details

#format_graphObject

set up the default format for the graph



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/cs_sln_graph.rb', line 17

def format_graph
	# set global node options
	@graph.node[:color]    = "#ddaa66"
	@graph.node[:style]    = "filled"
	@graph.node[:shape]    = "box"
	@graph.node[:penwidth] = "1"
	@graph.node[:fontname] = "Trebuchet MS"
	@graph.node[:fontsize] = "8"
	@graph.node[:fillcolor]= "#ffeecc"
	@graph.node[:fontcolor]= "#666666"
	@graph.node[:margin]   = "0.0"

	# set global edge options
	@graph.edge[:color]    = "#999999"
	@graph.edge[:weight]   = "1"
	@graph.edge[:fontsize] = "6"
	@graph.edge[:fontcolor]= "#444444"
	@graph.edge[:fontname] = "Verdana"
	@graph.edge[:dir]      = "forward"
	@graph.edge[:arrowsize]= "0.5"
end

#graph_projObject

graph a project file



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/cs_sln_graph.rb', line 70

def graph_proj
	projects = []
	projects << Project.new(nil, File.basename(@input_path, File.extname(@input_path)), @input_path)
	dependencies = VSFile_Reader.read_proj(@input_path)
	dependencies.each do |dep|
		if dep.class == Project
			projects << dep
		end
	end
	projects.each do |proj|
		p_node = @graph.add_node(proj.name)
		dependencies = VSFile_Reader.read_proj(proj.path)
		dependencies.each do |dep|
			if dep.class == Project
				d_node = @graph.get_node(dep.name)
				if d_node.nil?
					d_node = @graph.add_node(dep.name)
				end
				@graph.add_edge(d_node, p_node)
			else
				if not dep.start_with?("System")
					d_node = @graph.get_node(dep)
					if d_node.nil?
						d_node = @graph.add_node(dep)
						d_node[:color] = "#66ddaa"
						d_node[:fillcolor] = "#ccffee"
					end
					@graph.add_edge(d_node, p_node)
				end
			end
		end
	end
	@graph.output(@format => @output_path)
end

#graph_slnObject

graph a solution file



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cs_sln_graph.rb', line 40

def graph_sln
	projects = VSFile_Reader.read_sln(@input_path)
	projects.each do |project|
		p_node = @graph.add_node(project.name)
		dependencies = VSFile_Reader.read_proj(project.path)
		dependencies.each do |dep|
			if dep.class == Project
				d_node = @graph.get_node(dep.name)
				if d_node.nil?
					d_node = @graph.add_node(dep.name)
				end
				@graph.add_edge(d_node, p_node)
			else
				if dep.start_with?("System.") || dep == "System"
					next
				end
				d_node = @graph.get_node(dep)
				if d_node.nil?
					d_node = @graph.add_node(dep)
					d_node[:color] = "#66ddaa"
					d_node[:fillcolor] = "#ccffee"
				end
				@graph.add_edge(d_node, p_node)
			end
		end
	end
	@graph.output(@format => @output_path)
end