Class: PryNav::Tracer
- Inherits:
-
Object
- Object
- PryNav::Tracer
- Defined in:
- lib/pry-nav/tracer.rb
Instance Method Summary collapse
-
#initialize(pry_start_options = {}, &block) ⇒ Tracer
constructor
A new instance of Tracer.
- #process_command(command = {}) ⇒ Object
- #run(&block) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(pry_start_options = {}, &block) ⇒ Tracer
Returns a new instance of Tracer.
5 6 7 8 9 10 |
# File 'lib/pry-nav/tracer.rb', line 5 def initialize( = {}, &block) @step_in_lines = -1 # Break after this many lines @frames_when_stepping = nil # Only break at this frame level @frames = 0 # Traced stack frame level @pry_start_options = # Options to use for Pry.start end |
Instance Method Details
#process_command(command = {}) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/pry-nav/tracer.rb', line 45 def process_command(command = {}) times = (command[:times] || 1).to_i times = 1 if times <= 0 case command[:action] when :step @step_in_lines = times @frames_when_stepping = nil true when :next @step_in_lines = times @frames_when_stepping = @frames true else false end end |
#run(&block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pry-nav/tracer.rb', line 12 def run(&block) # For performance, disable any tracers while in the console. # Unfortunately doesn't work in 1.9.2 because of # http://redmine.ruby-lang.org/issues/3921. Works fine in 1.8.7 and 1.9.3. stop unless RUBY_VERSION == '1.9.2' return_value = nil command = catch(:breakout_nav) do # Coordinates with PryNav::Commands return_value = yield {} # Nothing thrown == no navigational command end # Adjust tracer based on command if process_command(command) start else stop if RUBY_VERSION == '1.9.2' if @pry_start_options[:pry_remote] && PryNav.current_remote_server PryNav.current_remote_server.teardown end end return_value end |
#start ⇒ Object
37 38 39 |
# File 'lib/pry-nav/tracer.rb', line 37 def start set_trace_func method(:tracer).to_proc end |
#stop ⇒ Object
41 42 43 |
# File 'lib/pry-nav/tracer.rb', line 41 def stop set_trace_func nil end |