ruby-codegraph 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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
- > codegraph <dir>
13
- > open output.png
19
+ codegraph <dir>
20
+ open output.png
14
21
  ```
15
22
 
16
23
  Get help:
17
24
 
18
25
  ```shell
19
- > codegraph -h
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]} for #{File.expand_path @dir} at #{Time.now}"
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
@@ -1,3 +1,3 @@
1
1
  module CodeGraph
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/codegraph.rb CHANGED
@@ -1,3 +1,9 @@
1
1
  require 'graphviz'
2
2
  require 'codegraph/version'
3
3
  require 'codegraph/inheritance'
4
+
5
+ module CodeGraph
6
+
7
+ LABEL_FOOTER = "https://github.com/janx/codegraph"
8
+
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-codegraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: