Sha256: ad22234badbd09177b260eb1ca7ae7af8579bdbfaf45ce75e1bf20774fcf61c0

Contents?: true

Size: 1.2 KB

Versions: 29

Compression:

Stored size: 1.2 KB

Contents

require 'pry' unless defined? Pry
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-moves knows this is a remote session, and not kill
    # the server right away
    def run
      if PryMoves.current_remote_server
        raise 'Already running a pry-remote session!'
      else
        PryMoves.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
      PryMoves.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
# PryMoves::Tracer#run doesn't have a chance to cleanup.
at_exit do
  set_trace_func nil
  if PryMoves.current_remote_server
    PryMoves.current_remote_server.teardown
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
pry-moves-1.0.15 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.14 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.13 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.12 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.11 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.10 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.9 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.8 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.7 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.6 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.5 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.4 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.3 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.2 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.1 lib/pry-moves/pry_remote_ext.rb
pry-moves-1.0.0 lib/pry-moves/pry_remote_ext.rb
pry-moves-0.1.13 lib/pry-moves/pry_remote_ext.rb
pry-moves-0.1.12 lib/pry-moves/pry_remote_ext.rb
pry-moves-0.1.10 lib/pry-moves/pry_remote_ext.rb
pry-moves-0.1.9 lib/pry-moves/pry_remote_ext.rb