2

中規模のライブラリを理解しようとしています。テスト スクリプトを実行して、処理中のコマンドを確認したいと考えています。

出来ますか?

ありがとう!

4

1 に答える 1

4

Kernel#set_trace_funcを使用して、すべてのcallイベントをトレースできます。

class Foo
  def bar
  end
end

set_trace_func proc { |event, file, line, id, binding, classname|
  if event == "call"
    printf "%8s %s:%-2d %10s %8s\n", event, file, line, id, classname
  end
}

Foo.new.bar

# =>    call foo.rb:2         bar      Foo
于 2012-10-20T21:18:12.353 に答える