Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Safer monkey-patching of Pry.start/.teardown

Allows other plugins to do the same without triggering a
SystemStackError.
  • Loading branch information...
commit 3795bc0156d7480c9bed589afec631a73bac9dc6 1 parent 1f7321a
Benjamin R. Haskell authored
Showing with 10 additions and 7 deletions.
  1. +6 −4 lib/pry-nav/pry_ext.rb
  2. +4 −3 lib/pry-nav/pry_remote_ext.rb
10 lib/pry-nav/pry_ext.rb
View
@@ -2,19 +2,21 @@
require 'pry-nav/tracer'
class << Pry
- alias_method :start_existing, :start
+ alias_method :start_without_pry_nav, :start
- def start(target = TOPLEVEL_BINDING, options = {})
+ def start_with_pry_nav(target = TOPLEVEL_BINDING, options = {})
old_options = options.reject { |k, _| k == :pry_remote }
if target.is_a?(Binding) && PryNav.check_file_context(target)
# Wrap the tracer around the usual Pry.start
PryNav::Tracer.new(options).run do
- start_existing(target, old_options)
+ start_without_pry_nav(target, old_options)
end
else
# No need for the tracer unless we have a file context to step through
- start_existing(target, old_options)
+ start_without_pry_nav(target, old_options)
end
end
+
+ alias_method :start, :start_with_pry_nav
end
7 lib/pry-nav/pry_remote_ext.rb
View
@@ -21,11 +21,12 @@ def run
end
# Override to reset our saved global current server session.
- alias_method :teardown_existing, :teardown
- def teardown
- teardown_existing
+ alias_method :teardown_without_pry_nav, :teardown
+ def teardown_with_pry_nav
+ teardown_without_pry_nav
PryNav.current_remote_server = nil
end
+ alias_method :teardown, :teardown_with_pry_nav
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.