Sha256: 56c5cbe9a6acffa20be53fbe437118b02fc03a65c3702539b76730b95e136735

Contents?: true

Size: 1.15 KB

Versions: 8

Compression:

Stored size: 1.15 KB

Contents

require 'pry-remote'

module PryRemote
  class Server
    # Override the call to Pry.start to save off current Server, pass a
    # pry_remote flag so pry-nav knows this is a remote session, and not kill
    # the server right away
    def run
      if PryNav.current_remote_server
        raise 'Already running a pry-remote session!'
      else
        PryNav.current_remote_server = self
      end

      setup
      Pry.start @object, {
        :input  => client.input_proxy,
        :output => client.output,
        :pry_remote => true
      }
    end

    # Override to reset our saved global current server session.
    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

# Ensure cleanup when a program finishes without another break. For example,
# 'next' on the last line of a program never hits the tracer proc, and thus
# PryNav::Tracer#run doesn't have a chance to cleanup.
at_exit do
  set_trace_func nil
  if PryNav.current_remote_server
    PryNav.current_remote_server.teardown
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
gameboard-3.1.0 vendor/bundle/ruby/2.3.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
gameboard-3.0.0 vendor/bundle/ruby/2.3.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/pry-nav-0.2.4/lib/pry-nav/pry_remote_ext.rb
pry-nav-0.2.4 lib/pry-nav/pry_remote_ext.rb
pry-nav-0.2.3 lib/pry-nav/pry_remote_ext.rb