lib/boson/inspectors/argument_inspector.rb in boson-0.2.5 vs lib/boson/inspectors/argument_inspector.rb in boson-0.3.0

- old
+ new

@@ -24,15 +24,19 @@ end params, values, arity, num_args = trace_method_args(meth, klass, object) return if local_variables == params # nothing new found format_arguments(params, values, arity, num_args) rescue Exception - # puts "#{klass}.#{meth}: #{$!.message}" + print_debug_message(klass, meth) if Boson::Runner.debug ensure set_trace_func(nil) end + def print_debug_message(klass, meth) #:nodoc: + warn "DEBUG: Error while scraping arguments from #{klass.to_s[/\w+$/]}##{meth}: #{$!.message}" + end + # process params + values to return array of argument arrays def format_arguments(params, values, arity, num_args) #:nodoc: params ||= [] params = params[0,num_args] params.inject([[], 0]) do |(a, i), x| @@ -53,14 +57,15 @@ arity = klass.instance_method(meth).arity set_trace_func lambda{|event, file, line, id, binding, classname| begin if event[/call/] && classname == klass && id == meth params = eval("local_variables", binding) - values = eval("local_variables.map{|x| eval(x)}", binding) + values = eval("local_variables.map{|x| eval(x.to_s)}", binding) throw :done end rescue Exception + print_debug_message(klass, meth) if Boson::Runner.debug end } if arity >= 0 num_args = arity catch(:done){ object.send(meth, *(0...arity)) } @@ -68,10 +73,10 @@ num_args = 0 # determine number of args (including splat & block) MAX_ARGS.downto(arity.abs - 1) do |i| catch(:done) do begin - object.send(meth, *(0...i)) + object.send(meth, *(0...i)) rescue Exception end end # all nils if there's no splat and we gave too many args next if !values || values.compact.empty? \ No newline at end of file