codegraph 0.7.7 → 0.7.8
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/bin/codegraph +14 -20
- data/gemspec +3 -3
- data/lib/codegraph.rb +6 -10
- metadata +5 -5
data/bin/codegraph
CHANGED
@@ -4,8 +4,7 @@ require "getoptlong"
|
|
4
4
|
|
5
5
|
def show_usage
|
6
6
|
puts <<-END
|
7
|
-
Usage:
|
8
|
-
--help, -h guess what
|
7
|
+
Usage: codegraph --help, -h guess what
|
9
8
|
|
10
9
|
--file-list, -F "<list>"
|
11
10
|
fill the graph with every function,
|
@@ -14,9 +13,6 @@ Usage: #{__FILE__}:
|
|
14
13
|
--function, -f "<funcname>"
|
15
14
|
take the given func as the root knode
|
16
15
|
|
17
|
-
--show-body, -s "<funcname>"
|
18
|
-
display the function code in the terminal
|
19
|
-
|
20
16
|
--upper-funx, -u "<funcname>"
|
21
17
|
scan for all funx, which depends directly or
|
22
18
|
indirectly on <funcname>
|
@@ -26,9 +22,6 @@ Usage: #{__FILE__}:
|
|
26
22
|
<funcname> AND which call <funcname>
|
27
23
|
(in)directly
|
28
24
|
|
29
|
-
--exclude, -x "<list>"
|
30
|
-
exclude a list of functions from the graph
|
31
|
-
|
32
25
|
--depth, -d <integer>
|
33
26
|
Set maximal Graph depth
|
34
27
|
|
@@ -54,12 +47,10 @@ end
|
|
54
47
|
# Which options are availabile ------------------------------------------------
|
55
48
|
options = GetoptLong.new(
|
56
49
|
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
57
|
-
["--debug",
|
58
|
-
# ["--
|
59
|
-
# ["--source", "-s", GetoptLong::NO_ARGUMENT],
|
60
|
-
# ["--with-internal", "-w", GetoptLong::NO_ARGUMENT],
|
50
|
+
["--debug", "-y", GetoptLong::NO_ARGUMENT],
|
51
|
+
# ["--add", "-a", GetoptLong::REQUIRED_ARGUMENT],
|
61
52
|
["--function", "-f", GetoptLong::REQUIRED_ARGUMENT],
|
62
|
-
["--show-body", "-s", GetoptLong::REQUIRED_ARGUMENT],
|
53
|
+
# ["--show-body", "-s", GetoptLong::REQUIRED_ARGUMENT],
|
63
54
|
["--upper-funx", "-u", GetoptLong::REQUIRED_ARGUMENT],
|
64
55
|
["--8-funx", "-8", GetoptLong::REQUIRED_ARGUMENT],
|
65
56
|
["--file-list", "-F", GetoptLong::REQUIRED_ARGUMENT],
|
@@ -69,8 +60,8 @@ options = GetoptLong.new(
|
|
69
60
|
["--to-png", "-P", GetoptLong::REQUIRED_ARGUMENT],
|
70
61
|
["--to-jpg", "-J", GetoptLong::REQUIRED_ARGUMENT],
|
71
62
|
["--to-dot", "-D", GetoptLong::REQUIRED_ARGUMENT],
|
72
|
-
["--to-txt", "-T", GetoptLong::NO_ARGUMENT]
|
73
|
-
["--exclude", "-x", GetoptLong::REQUIRED_ARGUMENT],
|
63
|
+
["--to-txt", "-T", GetoptLong::NO_ARGUMENT]
|
64
|
+
# ["--exclude", "-x", GetoptLong::REQUIRED_ARGUMENT],
|
74
65
|
)
|
75
66
|
options.ordering = GetoptLong::RETURN_IN_ORDER
|
76
67
|
# Default values --------------------------------------------------------------
|
@@ -81,8 +72,9 @@ internal = false
|
|
81
72
|
filename = ""
|
82
73
|
dotfile = ""
|
83
74
|
function = ""
|
84
|
-
depth
|
85
|
-
|
75
|
+
depth = nil
|
76
|
+
adds = Array.new
|
77
|
+
excludes = Array.new
|
86
78
|
files = Array.new
|
87
79
|
debug = false
|
88
80
|
# option parsing --------------------------------------------------------------
|
@@ -122,8 +114,10 @@ options.each do |opt, arg|
|
|
122
114
|
filename = arg
|
123
115
|
when "--to-txt"
|
124
116
|
output = "txt"
|
117
|
+
when "--add"
|
118
|
+
adds = arg.split(/ /)
|
125
119
|
when "--exclude"
|
126
|
-
|
120
|
+
excludes = arg.split(/ /)
|
127
121
|
when "--debug"
|
128
122
|
debug = true
|
129
123
|
else
|
@@ -156,10 +150,10 @@ end
|
|
156
150
|
g.debug = debug
|
157
151
|
|
158
152
|
# Include the internal functions of the language?
|
159
|
-
g.
|
153
|
+
g.adds = adds
|
160
154
|
|
161
155
|
# Creates the Knodes/Edges of the graph
|
162
|
-
g.fill(files,
|
156
|
+
g.fill(files,excludes)
|
163
157
|
|
164
158
|
# Remove edges
|
165
159
|
g.limit(depth) if depth
|
data/gemspec
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = "codegraph"
|
5
|
-
s.version = "0.7.
|
5
|
+
s.version = "0.7.8"
|
6
6
|
s.date = Time.new.to_s
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.bindir = 'bin'
|
@@ -11,8 +11,8 @@ spec = Gem::Specification.new do |s|
|
|
11
11
|
s.add_dependency('rgl')
|
12
12
|
s.add_dependency('asciify')
|
13
13
|
s.rubyforge_project = "codegraph"
|
14
|
-
s.description = "Display functional dependencies in source code (C, Fortran, PHP, Perl).\n"
|
15
|
-
"Changes (#{s.version}):
|
14
|
+
s.description = "Display functional dependencies in source code (C, Fortran, PHP, Perl).\n"
|
15
|
+
# "Changes (#{s.version}):"
|
16
16
|
s.summary = "Display functional dependencies in source code (C, Fortran, PHP, Perl)"
|
17
17
|
s.author = "Ralf Mueller"
|
18
18
|
s.email = "stark.dreamdetective@gmail.com"
|
data/lib/codegraph.rb
CHANGED
@@ -7,7 +7,7 @@ require 'thread'
|
|
7
7
|
require 'asciify'
|
8
8
|
|
9
9
|
class FunctionGraph < RGL::DirectedAdjacencyGraph
|
10
|
-
attr_accessor :funx, :
|
10
|
+
attr_accessor :funx, :adds, :excludes, :debug
|
11
11
|
|
12
12
|
# Theses Parameters are used by interactive representation and for the file
|
13
13
|
# generation function to_dot and to_type. They can only be given for the
|
@@ -35,7 +35,6 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
35
35
|
|
36
36
|
@@home = `echo $HOME`.chomp
|
37
37
|
@@codehomedir = "#{@@home}/.codegraph"
|
38
|
-
@@internal_funx = []
|
39
38
|
@@matchBeforFuncName = '[^A-z0-9_]\s*'
|
40
39
|
@@matchAfterFuncName = ' *\('
|
41
40
|
@@map = Asciify::Mapping.new(:default)
|
@@ -51,8 +50,6 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
51
50
|
# the following attribute will hold the functionnames and their bodies
|
52
51
|
@funx = Hash.new
|
53
52
|
@lock = Mutex.new
|
54
|
-
# Should the internal functions be displayed?
|
55
|
-
@internal = false
|
56
53
|
end
|
57
54
|
|
58
55
|
# Generates the necessary files:
|
@@ -124,7 +121,7 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
124
121
|
# threads << Threads.new(name,body,names) {|name,body|
|
125
122
|
puts "Add func: #{name}" if @debug
|
126
123
|
add_vertex(name)
|
127
|
-
(names - [name] +
|
124
|
+
(names - [name] + @adds).each { |func|
|
128
125
|
puts body if @debug
|
129
126
|
add_edge("#{name}","#{func}") if/#@@matchBeforFuncName#{func}#@@matchAfterFuncName/.match(body)
|
130
127
|
}
|
@@ -213,10 +210,10 @@ class SingleFunctionGraph < FunctionGraph
|
|
213
210
|
@scannednames << f
|
214
211
|
body = graph.funx[f]
|
215
212
|
# scan for any other function in the body of f
|
216
|
-
(names - [f] +
|
213
|
+
(names - [f] + @adds).each {|g|
|
217
214
|
if /#@@matchBeforFuncName#{g}#@@matchAfterFuncName/.match(body)
|
218
215
|
graph.add_edge(f,g)
|
219
|
-
#
|
216
|
+
# go downstairs for all functions from the scanned files
|
220
217
|
scan(graph,g) if names.include?(g)
|
221
218
|
end
|
222
219
|
}
|
@@ -231,11 +228,10 @@ class UpperFunctionGraph < SingleFunctionGraph
|
|
231
228
|
def scan(graph,func)
|
232
229
|
if @scannednames.include?(func)
|
233
230
|
else
|
234
|
-
if not (graph.funx.keys +
|
235
|
-
|
231
|
+
if not (graph.funx.keys + @adds).include?(func)
|
232
|
+
warn "Function '#{func}' not found. If this is an internal function, " +
|
236
233
|
"please try again with the '-w' option to include the internal " +
|
237
234
|
"funx before scanning."
|
238
|
-
#system("rm ~/.codegraph/all.#{ng} ~/.codegraph/code-names")
|
239
235
|
exit
|
240
236
|
end
|
241
237
|
@scannednames << func
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 7
|
8
|
-
-
|
9
|
-
version: 0.7.
|
8
|
+
- 8
|
9
|
+
version: 0.7.8
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ralf Mueller
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-14
|
17
|
+
date: 2011-01-18 14:41:19 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -43,9 +43,9 @@ dependencies:
|
|
43
43
|
version: "0"
|
44
44
|
type: :runtime
|
45
45
|
version_requirements: *id002
|
46
|
-
description:
|
46
|
+
description: |
|
47
47
|
Display functional dependencies in source code (C, Fortran, PHP, Perl).
|
48
|
-
|
48
|
+
|
49
49
|
email: stark.dreamdetective@gmail.com
|
50
50
|
executables:
|
51
51
|
- codegraph
|