codegraph 0.7.5 → 0.7.7
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 +7 -0
- data/gemspec +2 -2
- data/lib/codegraph.rb +9 -13
- metadata +4 -4
data/bin/codegraph
CHANGED
@@ -54,6 +54,7 @@ end
|
|
54
54
|
# Which options are availabile ------------------------------------------------
|
55
55
|
options = GetoptLong.new(
|
56
56
|
["--help", "-h", GetoptLong::NO_ARGUMENT],
|
57
|
+
["--debug", "-y", GetoptLong::NO_ARGUMENT],
|
57
58
|
# ["--local", "-l", GetoptLong::NO_ARGUMENT],
|
58
59
|
# ["--source", "-s", GetoptLong::NO_ARGUMENT],
|
59
60
|
# ["--with-internal", "-w", GetoptLong::NO_ARGUMENT],
|
@@ -83,6 +84,7 @@ function = ""
|
|
83
84
|
depth = nil
|
84
85
|
exclude = Array.new
|
85
86
|
files = Array.new
|
87
|
+
debug = false
|
86
88
|
# option parsing --------------------------------------------------------------
|
87
89
|
options.each do |opt, arg|
|
88
90
|
case opt
|
@@ -122,6 +124,8 @@ options.each do |opt, arg|
|
|
122
124
|
output = "txt"
|
123
125
|
when "--exclude"
|
124
126
|
exclude = arg.split(/ /)
|
127
|
+
when "--debug"
|
128
|
+
debug = true
|
125
129
|
else
|
126
130
|
show_usage
|
127
131
|
exit
|
@@ -148,6 +152,9 @@ case mode
|
|
148
152
|
g = FunctionGraph.new
|
149
153
|
end
|
150
154
|
|
155
|
+
# Set debug mode
|
156
|
+
g.debug = debug
|
157
|
+
|
151
158
|
# Include the internal functions of the language?
|
152
159
|
g.internal = internal
|
153
160
|
|
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.7"
|
6
6
|
s.date = Time.new.to_s
|
7
7
|
s.platform = Gem::Platform::RUBY
|
8
8
|
s.bindir = 'bin'
|
@@ -12,7 +12,7 @@ spec = Gem::Specification.new do |s|
|
|
12
12
|
s.add_dependency('asciify')
|
13
13
|
s.rubyforge_project = "codegraph"
|
14
14
|
s.description = "Display functional dependencies in source code (C, Fortran, PHP, Perl).\n" +
|
15
|
-
"Changes (#{s.version}):
|
15
|
+
"Changes (#{s.version}): --debug opton added"
|
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
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'pp'
|
3
2
|
require 'rgl/adjacency'
|
4
3
|
require 'rgl/dot'
|
@@ -7,11 +6,8 @@ require 'rgl/traversal'
|
|
7
6
|
require 'thread'
|
8
7
|
require 'asciify'
|
9
8
|
|
10
|
-
|
11
|
-
DEBUG = false
|
12
|
-
|
13
9
|
class FunctionGraph < RGL::DirectedAdjacencyGraph
|
14
|
-
attr_accessor :funx, :internal
|
10
|
+
attr_accessor :funx, :internal, :debug
|
15
11
|
|
16
12
|
# Theses Parameters are used by interactive representation and for the file
|
17
13
|
# generation function to_dot and to_type. They can only be given for the
|
@@ -51,12 +47,12 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
51
47
|
|
52
48
|
def initialize
|
53
49
|
super
|
50
|
+
@debug = false
|
54
51
|
# the following attribute will hold the functionnames and their bodies
|
55
52
|
@funx = Hash.new
|
56
53
|
@lock = Mutex.new
|
57
54
|
# Should the internal functions be displayed?
|
58
55
|
@internal = false
|
59
|
-
|
60
56
|
end
|
61
57
|
|
62
58
|
# Generates the necessary files:
|
@@ -71,7 +67,7 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
71
67
|
funxFile = "funxnames"
|
72
68
|
ctagsKinds = '--c-kinds=f --fortran-kinds=fsp --php-kinds=f --perl-kinds=f'
|
73
69
|
|
74
|
-
puts "Processing #{file} ..." if
|
70
|
+
puts "Processing #{file} ..." if @debug
|
75
71
|
basefile = File.basename(file)
|
76
72
|
temfile = "_" + basefile
|
77
73
|
case File.extname(file)
|
@@ -89,14 +85,14 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
89
85
|
gen4ctags = "ctags -x #{ctagsKinds} #{codehomedir}/#{basefile} | sort -n -k 3"
|
90
86
|
command = [cppCommand,grep].join(";")
|
91
87
|
|
92
|
-
puts command if
|
88
|
+
puts command if @debug
|
93
89
|
system(command)
|
94
90
|
|
95
91
|
code = open(codehomedir+'/'+ File.basename(file)).readlines
|
96
92
|
funxLocations = IO.popen(gen4ctags).readlines.map {|l| l.split[0,4]}
|
97
93
|
funxLocations.each_with_index {|ary,i|
|
98
94
|
name, kind, line, file = ary
|
99
|
-
puts name if
|
95
|
+
puts name if @debug
|
100
96
|
line = line.to_i
|
101
97
|
startLineIndex = line - 1
|
102
98
|
endLineIndex = (i+1 < funxLocations.size) ? funxLocations[i+1][2].to_i - 2 : -1
|
@@ -126,10 +122,10 @@ class FunctionGraph < RGL::DirectedAdjacencyGraph
|
|
126
122
|
names = @funx.keys
|
127
123
|
@funx.each_pair {|name,body|
|
128
124
|
# threads << Threads.new(name,body,names) {|name,body|
|
129
|
-
puts "Add func: #{name}" if
|
125
|
+
puts "Add func: #{name}" if @debug
|
130
126
|
add_vertex(name)
|
131
127
|
(names - [name] + @@internal_funx).each { |func|
|
132
|
-
puts body if
|
128
|
+
puts body if @debug
|
133
129
|
add_edge("#{name}","#{func}") if/#@@matchBeforFuncName#{func}#@@matchAfterFuncName/.match(body)
|
134
130
|
}
|
135
131
|
}
|
@@ -246,8 +242,8 @@ class UpperFunctionGraph < SingleFunctionGraph
|
|
246
242
|
graph.funx.each_pair {|g,gbody|
|
247
243
|
# dont scan a function for itself
|
248
244
|
next if g == func
|
249
|
-
puts g if
|
250
|
-
puts gbody if
|
245
|
+
puts g if @debug
|
246
|
+
puts gbody if @debug
|
251
247
|
if/#@@matchBeforFuncName#{func}#@@matchAfterFuncName/.match(Asciify.new(@@map).convert(gbody))
|
252
248
|
graph.add_edge(g,func)
|
253
249
|
scan(graph,g)
|
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
|
+
- 7
|
9
|
+
version: 0.7.7
|
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-
|
17
|
+
date: 2011-01-14 12:02:48 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -45,7 +45,7 @@ dependencies:
|
|
45
45
|
version_requirements: *id002
|
46
46
|
description: |-
|
47
47
|
Display functional dependencies in source code (C, Fortran, PHP, Perl).
|
48
|
-
Changes (0.7.
|
48
|
+
Changes (0.7.7): --debug opton added
|
49
49
|
email: stark.dreamdetective@gmail.com
|
50
50
|
executables:
|
51
51
|
- codegraph
|