Skip to content
This repository

Safer monkey-patching of Pry.start/.teardown #18

Merged
merged 1 commit into from over 1 year ago

2 participants

Benjamin R. Haskell John Mair
Benjamin R. Haskell

Allows other plugins to do the same without triggering a SystemStackError.

Safer monkey-patching of Pry.start/.teardown
Allows other plugins to do the same without triggering a
SystemStackError.
3795bc0
Benjamin R. Haskell benizi referenced this pull request in pry/pry October 25, 2012
Closed

Stack Level Too Deep when running pry #694

John Mair
Collaborator

thanks

John Mair banister merged commit 7e78c9b into from October 26, 2012
John Mair banister closed this October 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Oct 25, 2012
Safer monkey-patching of Pry.start/.teardown
Allows other plugins to do the same without triggering a
SystemStackError.
3795bc0
This page is out of date. Refresh to see the latest.
10  lib/pry-nav/pry_ext.rb
@@ -2,19 +2,21 @@
2 2
 require 'pry-nav/tracer'
3 3
 
4 4
 class << Pry
5  
-  alias_method :start_existing, :start
  5
+  alias_method :start_without_pry_nav, :start
6 6
 
7  
-  def start(target = TOPLEVEL_BINDING, options = {})
  7
+  def start_with_pry_nav(target = TOPLEVEL_BINDING, options = {})
8 8
     old_options = options.reject { |k, _| k == :pry_remote }
9 9
 
10 10
     if target.is_a?(Binding) && PryNav.check_file_context(target)
11 11
       # Wrap the tracer around the usual Pry.start
12 12
       PryNav::Tracer.new(options).run do
13  
-        start_existing(target, old_options)
  13
+        start_without_pry_nav(target, old_options)
14 14
       end
15 15
     else
16 16
       # No need for the tracer unless we have a file context to step through
17  
-      start_existing(target, old_options)
  17
+      start_without_pry_nav(target, old_options)
18 18
     end
19 19
   end
  20
+
  21
+  alias_method :start, :start_with_pry_nav
20 22
 end
7  lib/pry-nav/pry_remote_ext.rb
@@ -21,11 +21,12 @@ def run
21 21
     end
22 22
 
23 23
     # Override to reset our saved global current server session.
24  
-    alias_method :teardown_existing, :teardown
25  
-    def teardown
26  
-      teardown_existing
  24
+    alias_method :teardown_without_pry_nav, :teardown
  25
+    def teardown_with_pry_nav
  26
+      teardown_without_pry_nav
27 27
       PryNav.current_remote_server = nil
28 28
     end
  29
+    alias_method :teardown, :teardown_with_pry_nav
29 30
   end
30 31
 end
31 32
 
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.