# File lib/method_analyzer.rb, line 58
58: def self.at_exit__output_marshal
59: at_exit do
60: set_trace_func nil
61: dbfile = "method_analysis"
62: old = Marshal.load(File.read(dbfile)) rescue {}
63: open(dbfile, "wb") do |io|
64: # Because Marshal.dump cannot handle hashes with default_proc
65: @@methods.default = nil
66: @@methods.each_value{ |v| v.default=nil; v.each_value{ |vv| vv.uniq! } }
67: Marshal.dump(@@methods.merge(old), io)
68: end
69: end
70: end
# File lib/method_analyzer.rb, line 73
73: def self.at_exit__output_text
74: at_exit do
75: set_trace_func nil
76: puts "method fullnames"
77: @@methods.sort.each do |file, lines|
78: lines.sort.each do |line, methods|
79: printf "%s:%s:%s\n", file, line, methods.uniq.join(" ")
80: end
81: end
82:
83: puts
84: puts "method definitions"
85: @@whereis.sort.uniq.each do |file, line, fullname |
86: printf "%s:%s:%s\n", file, line, fullname
87: end
88:
89: end
90: end
# File lib/method_analyzer.rb, line 92
92: def self.set_at_exit
93: case ENV['METHOD_ANALYZER_FORMAT']
94: when 'marshal'
95: at_exit__output_marshal
96: else
97: at_exit__output_text
98: end
99: end
# File lib/method_analyzer.rb, line 32
32: def self.trace_func(event, file, line, id, binding, klass, *rest)
33: return if file == __FILE__
34: return if (event != 'call' and event != 'c-call')
35: return if klass == Class and id == :inherited
36: return if klass == Module and id == :method_added
37: return if klass == Kernel and id == :singleton_method_added
38: saved_crit = Thread.critical
39: Thread.critical = true
40:
41: the_self = eval("self",binding)
42: flag = Class === the_self ? "." : "#"
43: #klass = klass == Kernel ? Object : klass
44: fullname = "#{klass}#{flag}#{id}"
45: file.replace @@expand_path[file]
46: if event == 'call'
47: @@whereis << [file, line, fullname] if file !~ /\(eval\)$/
48: file, line, rest = caller(4)[0].split(/:/)
49: file.replace @@expand_path[file] # DRY
50: p caller(0) if $DEBUG
51: line = line.to_i
52: end
53: @@methods[file][line] << fullname if event =~ /call/
54:
55: Thread.critical = saved_crit
56: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.