ruby-codegraph 0.0.1 → 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.
- data/README.markdown +10 -3
- data/bin/codegraph +11 -1
- data/lib/codegraph/inheritance.rb +17 -8
- data/lib/codegraph/version.rb +1 -1
- data/lib/codegraph.rb +6 -0
- metadata +1 -1
data/README.markdown
CHANGED
@@ -3,20 +3,27 @@ Graph For Your Ruby Code
|
|
3
3
|
|
4
4
|
Use `graphviz` to generate class inheritance graph for your ruby code.
|
5
5
|
|
6
|
+
Install
|
7
|
+
-------
|
8
|
+
|
9
|
+
```shell
|
10
|
+
gem install ruby-codegraph
|
11
|
+
```
|
12
|
+
|
6
13
|
Usage
|
7
14
|
-----
|
8
15
|
|
9
16
|
Basic usage:
|
10
17
|
|
11
18
|
```shell
|
12
|
-
|
13
|
-
|
19
|
+
codegraph <dir>
|
20
|
+
open output.png
|
14
21
|
```
|
15
22
|
|
16
23
|
Get help:
|
17
24
|
|
18
25
|
```shell
|
19
|
-
|
26
|
+
codegraph -h
|
20
27
|
```
|
21
28
|
|
22
29
|
Copyright
|
data/bin/codegraph
CHANGED
@@ -10,7 +10,9 @@ options = {
|
|
10
10
|
engine: 'dot',
|
11
11
|
type: 'inheritance',
|
12
12
|
output: 'output',
|
13
|
-
format: 'png'
|
13
|
+
format: 'png',
|
14
|
+
label: true,
|
15
|
+
label_footer: true
|
14
16
|
}
|
15
17
|
|
16
18
|
OptionParser.new do |opts|
|
@@ -43,6 +45,14 @@ USAGE
|
|
43
45
|
options[:engine] = v
|
44
46
|
end
|
45
47
|
|
48
|
+
opts.on("--no-label", "Disable graph label") do |v|
|
49
|
+
options[:no_label] = true
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("--no-label-footer", "Disable graph label footer (an url to codegraph repo)") do |v|
|
53
|
+
options[:no_label_footer] = true
|
54
|
+
end
|
55
|
+
|
46
56
|
opts.on("-v", "--version", "Show version") do |v|
|
47
57
|
puts "CodeGraph v#{CodeGraph::VERSION}"
|
48
58
|
end
|
@@ -7,16 +7,11 @@ module CodeGraph
|
|
7
7
|
def initialize(dir, options={})
|
8
8
|
@dir = dir
|
9
9
|
@options = options
|
10
|
+
|
10
11
|
@nodes = {}
|
11
12
|
@edges = {}
|
12
13
|
|
13
|
-
@g = GraphViz.new(
|
14
|
-
@options[:graph_name],
|
15
|
-
label: label,
|
16
|
-
type: :digraph,
|
17
|
-
use: @options[:engine],
|
18
|
-
rankdir: 'RL'
|
19
|
-
)
|
14
|
+
@g = GraphViz.new(@options[:graph_name], graphviz_options)
|
20
15
|
end
|
21
16
|
|
22
17
|
def generate
|
@@ -26,8 +21,22 @@ module CodeGraph
|
|
26
21
|
|
27
22
|
private
|
28
23
|
|
24
|
+
def graphviz_options
|
25
|
+
options = {
|
26
|
+
type: :digraph,
|
27
|
+
use: @options[:engine],
|
28
|
+
rankdir: 'RL'
|
29
|
+
}
|
30
|
+
|
31
|
+
options[:label] = label unless @options[:no_label]
|
32
|
+
options
|
33
|
+
end
|
34
|
+
|
29
35
|
def label
|
30
|
-
"#{@options[:graph_name]}
|
36
|
+
strs = ["", "#{@options[:graph_name]} at #{File.expand_path @dir}"]
|
37
|
+
strs << Time.now
|
38
|
+
strs << LABEL_FOOTER unless @options[:no_label_footer]
|
39
|
+
strs.join("\n")
|
31
40
|
end
|
32
41
|
|
33
42
|
def directory_scan
|
data/lib/codegraph/version.rb
CHANGED
data/lib/codegraph.rb
CHANGED