lib/gestalt.rb in gestalt-0.0.9 vs lib/gestalt.rb in gestalt-0.0.10
- old
+ new
@@ -3,13 +3,13 @@
require 'rubygems'
require 'formatador'
class Gestalt
- VERSION = '0.0.9'
+ VERSION = '0.0.10'
- attr_accessor :calls
+ attr_accessor :bindings, :calls
def initialize(options = {})
options = {
'call' => true,
'c-call' => false,
@@ -25,10 +25,11 @@
if options ['c-call']
@traceable_calls << 'c-call'
@traceable_returns << 'c-return'
end
+ @bindings = []
@calls = []
@formatador = options['formatador']
@stack = []
@totals = {}
end
@@ -71,15 +72,15 @@
end
def run(&block)
Kernel.set_trace_func(
lambda do |event, file, line, id, binding, classname|
+ @bindings << binding
case event
when *@traceable_calls
call = Gestalt::Call.new(
:action => "#{classname}##{id}",
- :binding => binding,
:location => "#{file}:#{line}"
)
unless @stack.empty?
@stack.last.children.push(call)
end
@@ -99,9 +100,11 @@
value = yield
rescue StandardError, Interrupt
# noop
end
Kernel.set_trace_func(nil)
+ @bindings.pop # pop Kernel#set_trace_func(nil)
+ @bindings.pop # pop Gestalt.run
@stack.pop # pop Kernel#set_trace_func(nil)
unless @stack.empty?
@stack.last.children.pop # pop Kernel#set_trace_func(nil)
end
while call = @stack.pop # leftovers, not sure why...