Sha256: bb0927b0d6fe8568d2f9b560a24f24f5554afdfb404f04009de7e466321bfd0c

Contents?: true

Size: 1.08 KB

Versions: 10

Compression:

Stored size: 1.08 KB

Contents

require 'pry-remote'

module PryRemote
  #
  # Overrides PryRemote::Server
  #
  class Server
    #
    # Override the call to Pry.start to save off current Server, and not
    # teardown the server right after Pry.start finishes.
    #
    def run
      raise('Already running a pry-remote session!') if
        PryByebug.current_remote_server

      PryByebug.current_remote_server = self

      setup
      Pry.start @object, input: client.input_proxy, output: client.output
    end

    #
    # Override to reset our saved global current server session.
    #
    alias teardown_without_pry_byebug teardown
    def teardown_with_pry_byebug
      return if @torn

      teardown_without_pry_byebug
      PryByebug.current_remote_server = nil
      @torn = true
    end
    alias teardown teardown_with_pry_byebug
  end
end

# Ensure cleanup when a program finishes without another break. For example,
# 'next' on the last line of a program won't hit Byebug::PryProcessor#run,
# which normally handles cleanup.
at_exit do
  PryByebug.current_remote_server.teardown if PryByebug.current_remote_server
end

Version data entries

10 entries across 9 versions & 2 rubygems

Version Path
pry-byebug-3.5.1 lib/pry-byebug/pry_remote_ext.rb
tdiary-5.0.6 vendor/bundle/gems/pry-byebug-3.5.0/lib/pry-byebug/pry_remote_ext.rb
pry-byebug-3.5.0 lib/pry-byebug/pry_remote_ext.rb
pry-byebug-3.4.3 lib/pry-byebug/pry_remote_ext.rb
tdiary-5.0.5 vendor/bundle/gems/pry-byebug-3.4.2/lib/pry-byebug/pry_remote_ext.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/pry-byebug-3.4.2/lib/pry-byebug/pry_remote_ext.rb
tdiary-5.0.4 vendor/bundle/gems/pry-byebug-3.4.2/lib/pry-byebug/pry_remote_ext.rb
pry-byebug-3.4.2 lib/pry-byebug/pry_remote_ext.rb
pry-byebug-3.4.1 lib/pry-byebug/pry_remote_ext.rb
pry-byebug-3.4.0 lib/pry-byebug/pry_remote_ext.rb