cs_sln_graph 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +6 -2
- data/VERSION +1 -1
- data/bin/cs_sln_graph +16 -9
- data/cs_sln_graph.gemspec +2 -2
- data/lib/cs_sln_graph.rb +43 -6
- data/lib/vsfile_reader.rb +4 -2
- metadata +13 -13
data/README.rdoc
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
= cs_sln_graph
|
2
2
|
|
3
|
-
cs_sln_graph is a small utility gem I wrote to generate dependency graphs for
|
3
|
+
cs_sln_graph is a small utility gem I wrote to generate dependency graphs for
|
4
|
+
C# solution and project files using GraphViz. It's not extremely robust, I just whipped it up real quick
|
5
|
+
for some research at work.
|
4
6
|
|
5
7
|
You will need to install GraphViz before using this gem.
|
6
8
|
|
@@ -10,13 +12,15 @@ To install, use gem
|
|
10
12
|
|
11
13
|
% gem install cs_sln_graph
|
12
14
|
|
13
|
-
The -i argument specifies the path to your solution.
|
15
|
+
The -i argument specifies the path to your solution or project.
|
14
16
|
|
15
17
|
The -o argument specifies the path to your output file (it will default to the directory your solution is in).
|
16
18
|
|
17
19
|
-f specifies the format the output file should be in (default is png).
|
18
20
|
|
19
21
|
== History
|
22
|
+
* 0.0.5 - Now can take project files as input.
|
23
|
+
* 0.0.4 - OK, really fix it now
|
20
24
|
* 0.0.3 - Fix dependencies on ruby-graphviz
|
21
25
|
* 0.0.2 - Don't display System libraries, color external dependencies as green.
|
22
26
|
* 0.0.1 - Initial version
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/bin/cs_sln_graph
CHANGED
@@ -6,13 +6,13 @@ options = { :format => "png" }
|
|
6
6
|
op = OptionParser.new do |x|
|
7
7
|
x.banner = "cs_sln_graph <options>"
|
8
8
|
x.separator ""
|
9
|
-
x.on("-i <
|
10
|
-
options[:
|
9
|
+
x.on("-i <input>", String, "Solution or project file to generate a graph for.") do |i|
|
10
|
+
options[:input] = i
|
11
11
|
end
|
12
12
|
x.on("-o <output_path>", String, "Output path.") do |o|
|
13
13
|
options[:output] = o
|
14
14
|
end
|
15
|
-
x.on("-f <format>", String, "Format to output") do |f|
|
15
|
+
x.on("-f <format>", String, "Format to output (defaults to png)") do |f|
|
16
16
|
options[:format] = f
|
17
17
|
end
|
18
18
|
x.on("-h", "Show this message") do
|
@@ -32,15 +32,22 @@ end
|
|
32
32
|
# exit
|
33
33
|
#end
|
34
34
|
|
35
|
-
if not options.has_key?(:
|
36
|
-
puts "No
|
35
|
+
if not options.has_key?(:input)
|
36
|
+
puts "No input file given."
|
37
37
|
exit
|
38
38
|
end
|
39
39
|
|
40
40
|
if not options.has_key?(:output)
|
41
|
-
puts "No output file given. Defaulting to 'graph' in the
|
42
|
-
options[:output] = File.join(File.dirname(options[:
|
41
|
+
puts "No output file given. Defaulting to 'graph' in the input path."
|
42
|
+
options[:output] = File.join(File.dirname(options[:input]), "graph." + options[:format])
|
43
43
|
end
|
44
44
|
|
45
|
-
g = Cs_Sln_Graph.new(options[:
|
46
|
-
|
45
|
+
g = Cs_Sln_Graph.new(options[:input], options[:output], options[:format])
|
46
|
+
|
47
|
+
if options[:input].end_with?(".sln")
|
48
|
+
g.graph_sln
|
49
|
+
elsif options[:input].end_with?("proj")
|
50
|
+
g.graph_proj
|
51
|
+
else
|
52
|
+
puts "Invalid input file."
|
53
|
+
end
|
data/cs_sln_graph.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{cs_sln_graph}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Chris ONeal"]
|
12
|
-
s.date = %q{2011-06-
|
12
|
+
s.date = %q{2011-06-24}
|
13
13
|
s.default_executable = %q{cs_sln_graph}
|
14
14
|
s.description = %q{Generates dependency graphs using GraphViz from C# solution files}
|
15
15
|
s.email = %q{ctoneal@gmail.com}
|
data/lib/cs_sln_graph.rb
CHANGED
@@ -4,6 +4,7 @@ require 'rubygems'
|
|
4
4
|
require 'graphviz'
|
5
5
|
|
6
6
|
class Cs_Sln_Graph
|
7
|
+
# initialize the graph class
|
7
8
|
def initialize(input, output, format)
|
8
9
|
@input_path = input
|
9
10
|
@output_path = output
|
@@ -11,10 +12,9 @@ class Cs_Sln_Graph
|
|
11
12
|
@graph = GraphViz.new("G")
|
12
13
|
format_graph
|
13
14
|
end
|
14
|
-
|
15
|
-
def format_graph
|
16
|
-
#@graph[:rankdir] = "LR"
|
17
15
|
|
16
|
+
# set up the default format for the graph
|
17
|
+
def format_graph
|
18
18
|
# set global node options
|
19
19
|
@graph.node[:color] = "#ddaa66"
|
20
20
|
@graph.node[:style] = "filled"
|
@@ -36,12 +36,49 @@ class Cs_Sln_Graph
|
|
36
36
|
@graph.edge[:arrowsize]= "0.5"
|
37
37
|
end
|
38
38
|
|
39
|
-
|
39
|
+
# graph a solution file
|
40
|
+
def graph_sln
|
40
41
|
projects = VSFile_Reader.read_sln(@input_path)
|
41
42
|
projects.each do |project|
|
42
43
|
p_node = @graph.add_node(project.name)
|
43
|
-
|
44
|
-
dependencies
|
44
|
+
dependencies = VSFile_Reader.read_proj(project.path)
|
45
|
+
dependencies.each do |dep|
|
46
|
+
if dep.class == Project
|
47
|
+
d_node = @graph.get_node(dep.name)
|
48
|
+
if d_node.nil?
|
49
|
+
d_node = @graph.add_node(dep.name)
|
50
|
+
end
|
51
|
+
@graph.add_edge(d_node, p_node)
|
52
|
+
else
|
53
|
+
if dep.start_with?("System.") || dep == "System"
|
54
|
+
next
|
55
|
+
end
|
56
|
+
d_node = @graph.get_node(dep)
|
57
|
+
if d_node.nil?
|
58
|
+
d_node = @graph.add_node(dep)
|
59
|
+
d_node[:color] = "#66ddaa"
|
60
|
+
d_node[:fillcolor] = "#ccffee"
|
61
|
+
end
|
62
|
+
@graph.add_edge(d_node, p_node)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
@graph.output(@format => @output_path)
|
67
|
+
end
|
68
|
+
|
69
|
+
# graph a project file
|
70
|
+
def graph_proj
|
71
|
+
projects = []
|
72
|
+
projects << Project.new(nil, File.basename(@input_path, File.extname(@input_path)), @input_path)
|
73
|
+
dependencies = VSFile_Reader.read_proj(@input_path)
|
74
|
+
dependencies.each do |dep|
|
75
|
+
if dep.class == Project
|
76
|
+
projects << dep
|
77
|
+
end
|
78
|
+
end
|
79
|
+
projects.each do |proj|
|
80
|
+
p_node = @graph.add_node(proj.name)
|
81
|
+
dependencies = VSFile_Reader.read_proj(proj.path)
|
45
82
|
dependencies.each do |dep|
|
46
83
|
if dep.class == Project
|
47
84
|
d_node = @graph.get_node(dep.name)
|
data/lib/vsfile_reader.rb
CHANGED
@@ -2,6 +2,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), "project.rb"))
|
|
2
2
|
require 'rexml/document'
|
3
3
|
|
4
4
|
class VSFile_Reader
|
5
|
+
# get a list of projects from the solution file
|
5
6
|
def self.read_sln(path)
|
6
7
|
lines = []
|
7
8
|
projects = []
|
@@ -9,7 +10,7 @@ class VSFile_Reader
|
|
9
10
|
file.each_line do |line|
|
10
11
|
match_data = line.match(/^\s*Project\s*\(\s*\"\{[A-F0-9\-]{36}\}\"\s*\)\s*=\s*\"(\S+)\"\s*,\s*\"(.*\.(vcproj|csproj))\"\s*,\s*\"\{([A-F0-9\-]{36})\}\"\s*$/i)
|
11
12
|
if not match_data.nil?
|
12
|
-
proj = Project.new(match_data[4], match_data[1], match_data[2])
|
13
|
+
proj = Project.new(match_data[4], match_data[1], File.join(File.dirname(path), match_data[2]))
|
13
14
|
projects << proj
|
14
15
|
end
|
15
16
|
end
|
@@ -19,6 +20,7 @@ class VSFile_Reader
|
|
19
20
|
return projects
|
20
21
|
end
|
21
22
|
|
23
|
+
# get a list of dependencies for the given project
|
22
24
|
def self.read_proj(path)
|
23
25
|
dependencies = []
|
24
26
|
file = File.open(path) { |f| f.read }
|
@@ -31,7 +33,7 @@ class VSFile_Reader
|
|
31
33
|
end
|
32
34
|
# find project dependencies
|
33
35
|
document.elements.each('//Project/ItemGroup/ProjectReference') do |element|
|
34
|
-
path = element.attributes["Include"]
|
36
|
+
path = File.join(File.dirname(path), element.attributes["Include"])
|
35
37
|
name = ""
|
36
38
|
element.elements.each('Name') do |e|
|
37
39
|
name = e.text
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cs_sln_graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-06-
|
12
|
+
date: 2011-06-24 00:00:00.000000000 -05:00
|
13
13
|
default_executable: cs_sln_graph
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: shoulda
|
17
|
-
requirement: &
|
17
|
+
requirement: &5798580 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *5798580
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: bundler
|
28
|
-
requirement: &
|
28
|
+
requirement: &5797356 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 1.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *5797356
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: jeweler
|
39
|
-
requirement: &
|
39
|
+
requirement: &5796336 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.5.2
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *5796336
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rcov
|
50
|
-
requirement: &
|
50
|
+
requirement: &5793384 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *5793384
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: ruby-graphviz
|
61
|
-
requirement: &
|
61
|
+
requirement: &5792412 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :runtime
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *5792412
|
70
70
|
description: Generates dependency graphs using GraphViz from C# solution files
|
71
71
|
email: ctoneal@gmail.com
|
72
72
|
executables:
|
@@ -106,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
segments:
|
108
108
|
- 0
|
109
|
-
hash:
|
109
|
+
hash: 270288659
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|