Class: TraceGraph::Tracer
- Inherits:
-
Object
- Object
- TraceGraph::Tracer
- Defined in:
- lib/trace_graph/tracer.rb
Instance Method Summary collapse
- #call_trace ⇒ Object
-
#initialize(options) ⇒ Tracer
constructor
A new instance of Tracer.
- #node_count ⇒ Object
- #trace ⇒ Object
Constructor Details
#initialize(options) ⇒ Tracer
Returns a new instance of Tracer.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/trace_graph/tracer.rb', line 5 def initialize() @options = # We check included paths differently than excluded ones to allow nil to be bassed, to include everyting @included_paths = .key?(:included_paths) ? [:included_paths] : [] @excluded_paths = [:excluded_paths] || [] @include_protected = [:include_protected] || false @mark_duplicate_calls = .key?(:mark_duplicate_calls) ? [:mark_duplicate_calls] : true @show_arguments = [:show_arguments] || false @show_return_values = [:show_return_values] || false @only_class_transitions = [:only_class_transitions] || false @trace_point = build_trace_point @top_node = TraceGraph::TraceNode.new("trace") @stack = [] @all_nodes = [@top_node] @edge_count = 0 @unique_node_counts = {} end |
Instance Method Details
#call_trace ⇒ Object
41 42 43 |
# File 'lib/trace_graph/tracer.rb', line 41 def call_trace @top_node end |
#node_count ⇒ Object
45 46 47 |
# File 'lib/trace_graph/tracer.rb', line 45 def node_count @all_nodes.length - 1 # should top_node count as a node? end |
#trace ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/trace_graph/tracer.rb', line 24 def trace unless block_given? raise Error.new "You must pass a block to the tracer." end @edge_count = 0 @unique_node_counts = {} @trace_point.enable yield @trace_point.disable # TODO : Maybe outputting this should be an options, or a different tracer? puts @top_node.tree_graph if @options[:png] write_png @options[:png] end end |