forked from deivid-rodriguez/pry-byebug
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hermann Mayer <[email protected]>
- Loading branch information
Showing
6 changed files
with
73 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# frozen_string_literal: true | ||
|
||
require "byebug/core" | ||
|
||
module Byebug | ||
# | ||
# Extends the PryProcessor to make it work with Pry-Remote | ||
# | ||
class PryRemoteProcessor < PryProcessor | ||
def self.start | ||
super | ||
|
||
Byebug.current_context.step_out(5, true) | ||
end | ||
|
||
def resume_pry | ||
new_binding = frame._binding | ||
|
||
run do | ||
return unless server | ||
|
||
if defined?(@pry) && @pry | ||
@pry.repl(new_binding) | ||
else | ||
@pry = Pry::REPL.start_without_pry_byebug(target: new_binding, | ||
input: input, | ||
output: output) | ||
end | ||
end | ||
rescue Errno::ECONNREFUSED | ||
nil | ||
end | ||
|
||
private | ||
|
||
def input | ||
server.client.input_proxy | ||
end | ||
|
||
def output | ||
server.client.output | ||
end | ||
|
||
def server | ||
PryByebug.current_remote_server | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
# frozen_string_literal: true | ||
|
||
require "byebug/processors/pry_processor" | ||
require "byebug/processors/pry_remote_processor" | ||
|
||
class << Pry::REPL | ||
alias start_without_pry_byebug start | ||
|
||
def start_with_pry_byebug(options = {}) | ||
target = options[:target] | ||
|
||
if target.is_a?(Binding) && PryByebug.file_context?(target) | ||
Byebug::PryProcessor.start unless ENV["DISABLE_PRY"] | ||
if target.is_a?(Binding) && PryByebug.file_context?(target) && !ENV["DISABLE_PRY"] | ||
if run_remote? | ||
Byebug::PryRemoteProcessor.start | ||
return start_without_pry_byebug(options) | ||
end | ||
|
||
Byebug::PryProcessor.start | ||
else | ||
# No need for the tracer unless we have a file context to step through | ||
start_without_pry_byebug(options) | ||
end | ||
end | ||
|
||
alias start start_with_pry_byebug | ||
|
||
def run_remote? | ||
PryByebug.current_remote_server | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters