pry-shell 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -1
- data/bin/console +16 -2
- data/lib/pry/shell.rb +10 -0
- data/lib/pry/shell/logger.rb +1 -1
- data/lib/pry/shell/patches/object.rb +2 -2
- data/lib/pry/shell/patches/pry_byebug.rb +63 -12
- data/lib/pry/shell/session.rb +13 -5
- data/lib/pry/shell/ui/about.rb +1 -1
- data/lib/pry/shell/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68f90c4cdfe746f83fe8d18649b1141a901b5ba38d1a200b74556c066dd6fa6f
|
4
|
+
data.tar.gz: a1849f725f15e7f639968d7145c5a48efb72b351118e745b3e804c0b0d37062d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e7468ba04ac804e48428f95cf9ac1ffc6301dfef9c28d1b76d83d1e9816b2159f39a512c18a139f1aba8b79ae48929cb7b14d4daf65143e5a87f645e80b1889
|
7
|
+
data.tar.gz: 2f96b7544443dc1f2699d6e6da2e8165243e3d5617bbcc27493fe3d5da9d65c9d86a840f000c3aa2ef277e904aab6b0eba595e11a34f7b5396ad8e712640ccd2
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pry-shell (0.
|
4
|
+
pry-shell (0.4.0)
|
5
5
|
pry (~> 0.13.0)
|
6
6
|
tty-markdown
|
7
7
|
tty-prompt
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
ast (2.4.2)
|
13
|
+
byebug (11.1.3)
|
13
14
|
coderay (1.1.3)
|
14
15
|
diff-lcs (1.4.4)
|
15
16
|
kramdown (2.3.1)
|
@@ -23,6 +24,9 @@ GEM
|
|
23
24
|
pry (0.13.1)
|
24
25
|
coderay (~> 1.1)
|
25
26
|
method_source (~> 1.0)
|
27
|
+
pry-byebug (3.9.0)
|
28
|
+
byebug (~> 11.0)
|
29
|
+
pry (~> 0.13.0)
|
26
30
|
rainbow (3.0.0)
|
27
31
|
rake (13.0.3)
|
28
32
|
regexp_parser (2.1.1)
|
@@ -83,6 +87,7 @@ PLATFORMS
|
|
83
87
|
x86_64-darwin-19
|
84
88
|
|
85
89
|
DEPENDENCIES
|
90
|
+
pry-byebug
|
86
91
|
pry-shell!
|
87
92
|
rake (~> 13.0)
|
88
93
|
rspec (~> 3.0)
|
data/bin/console
CHANGED
@@ -11,6 +11,20 @@ require "pry/shell"
|
|
11
11
|
# require "pry"
|
12
12
|
# Pry.start
|
13
13
|
|
14
|
-
|
14
|
+
def foo1
|
15
|
+
binding.pry_shell(with_byebug: true)
|
15
16
|
|
16
|
-
|
17
|
+
foo2
|
18
|
+
end
|
19
|
+
|
20
|
+
def foo2
|
21
|
+
foo3
|
22
|
+
end
|
23
|
+
|
24
|
+
def foo3
|
25
|
+
5
|
26
|
+
end
|
27
|
+
|
28
|
+
a = 5 + foo1
|
29
|
+
|
30
|
+
puts a
|
data/lib/pry/shell.rb
CHANGED
@@ -31,6 +31,8 @@ class Pry
|
|
31
31
|
def run
|
32
32
|
run_server
|
33
33
|
draw_ui
|
34
|
+
rescue TTY::Reader::InputInterrupt, Interrupt
|
35
|
+
exit
|
34
36
|
end
|
35
37
|
|
36
38
|
def active_shell_options(thread: Thread.current)
|
@@ -41,6 +43,14 @@ class Pry
|
|
41
43
|
Thread.current[:active_shell_options] = value
|
42
44
|
end
|
43
45
|
|
46
|
+
def clear_shell_options!
|
47
|
+
self.active_shell_options = nil
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_active_connection!
|
51
|
+
active_shell_options&.fetch(:remove_connection)&.call
|
52
|
+
end
|
53
|
+
|
44
54
|
def configuration
|
45
55
|
@configuration ||= Configuration.new
|
46
56
|
end
|
data/lib/pry/shell/logger.rb
CHANGED
@@ -4,8 +4,8 @@ class Pry
|
|
4
4
|
class Shell
|
5
5
|
module Patches
|
6
6
|
module Object
|
7
|
-
def pry_shell(host: DEFAULT_HOST, port: DEFAULT_PORT)
|
8
|
-
Session.run(self, host: host, port: port)
|
7
|
+
def pry_shell(host: DEFAULT_HOST, port: DEFAULT_PORT, with_byebug: false)
|
8
|
+
Session.run(self, host: host, port: port, with_byebug: with_byebug)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
@@ -1,22 +1,73 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
3
|
+
begin
|
4
|
+
require "pry-byebug"
|
5
|
+
require "pry-byebug/pry_ext"
|
6
|
+
|
7
|
+
module Byebug
|
8
|
+
class PryShellProcessor < PryProcessor
|
9
|
+
class << self
|
10
|
+
def start
|
11
|
+
Byebug.start
|
12
|
+
Setting[:autolist] = false
|
13
|
+
Context.processor = self
|
14
|
+
Byebug.current_context.step_out(7, true)
|
15
|
+
at_exit { teardown! }
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def teardown!
|
21
|
+
Pry::Shell.remove_active_connection!
|
22
|
+
Pry::Shell.clear_shell_options!
|
11
23
|
end
|
12
24
|
end
|
25
|
+
|
26
|
+
def resume_pry
|
27
|
+
run do
|
28
|
+
pry_started? ? start_new_pry_repl : start_new_pry_session
|
29
|
+
end
|
30
|
+
rescue DRb::DRbConnError
|
31
|
+
puts "DRb connection failed!"
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def pry_started?
|
37
|
+
defined?(@pry) && @pry
|
38
|
+
end
|
39
|
+
|
40
|
+
def start_new_pry_session
|
41
|
+
@pry = Pry.start_without_pry_byebug(frame._binding, Pry::Shell.active_shell_options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def start_new_pry_repl
|
45
|
+
Pry::Shell::Repl.new(@pry, target: frame._binding).start
|
46
|
+
end
|
13
47
|
end
|
14
48
|
end
|
15
|
-
end
|
16
49
|
|
17
|
-
|
18
|
-
|
19
|
-
|
50
|
+
class Pry
|
51
|
+
class Shell
|
52
|
+
module Patches
|
53
|
+
module PryByebug
|
54
|
+
def start_with_pry_byebug(target = nil, options = {})
|
55
|
+
return start_with_pry_shell(target) if Shell.active_shell_options
|
56
|
+
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def start_with_pry_shell(target)
|
61
|
+
if Shell.active_shell_options[:with_byebug]
|
62
|
+
::Byebug::PryShellProcessor.start
|
63
|
+
else
|
64
|
+
start_without_pry_byebug(target, Shell.active_shell_options)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
20
71
|
|
21
72
|
Pry.singleton_class.prepend(Pry::Shell::Patches::PryByebug)
|
22
73
|
Pry.singleton_class.alias_method(:start, :start_with_pry_byebug)
|
data/lib/pry/shell/session.rb
CHANGED
@@ -13,15 +13,16 @@ class Pry
|
|
13
13
|
class Shell
|
14
14
|
class Session
|
15
15
|
class << self
|
16
|
-
def run(object, host:, port:)
|
17
|
-
new(object, host, port).run
|
16
|
+
def run(object, host:, port:, with_byebug:)
|
17
|
+
new(object, host, port, with_byebug).run
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def initialize(object, host, port)
|
21
|
+
def initialize(object, host, port, with_byebug)
|
22
22
|
@object = object
|
23
23
|
@host = host
|
24
24
|
@port = port
|
25
|
+
@with_byebug = with_byebug
|
25
26
|
end
|
26
27
|
|
27
28
|
def run
|
@@ -31,15 +32,22 @@ class Pry
|
|
31
32
|
rescue DRb::DRbConnError
|
32
33
|
puts "DRb connection failed!"
|
33
34
|
ensure
|
34
|
-
|
35
|
+
# Since we run `Byebug.current_context.step_out` this ensure
|
36
|
+
# block already runs and clears the options which are necessary
|
37
|
+
# to setup the Byebug.
|
38
|
+
# We are clearing this options in `PryShellProcessor` to ensure
|
39
|
+
# they do not leak.
|
40
|
+
Shell.clear_shell_options! unless with_byebug
|
35
41
|
end
|
36
42
|
|
37
43
|
private
|
38
44
|
|
39
|
-
attr_reader :object, :host, :port
|
45
|
+
attr_reader :object, :host, :port, :with_byebug
|
40
46
|
|
41
47
|
def pry_options
|
42
48
|
{
|
49
|
+
remove_connection: -> { registry.remove(client) },
|
50
|
+
with_byebug: with_byebug,
|
43
51
|
driver: Pry::Shell::Repl,
|
44
52
|
pager: false,
|
45
53
|
input: client.input,
|
data/lib/pry/shell/ui/about.rb
CHANGED
@@ -9,7 +9,7 @@ class Pry
|
|
9
9
|
pry-shell version "#{VERSION}"
|
10
10
|
|
11
11
|
Pry-shell provides you a standalone shell for accessing multiple `pry` sessions running on different processes.
|
12
|
-
You can switch between sessions by using the "\\
|
12
|
+
You can switch between sessions by going back to the menu using the "\\m" command.
|
13
13
|
|
14
14
|
Written by Mehmet Emin INAC.
|
15
15
|
MARKDOWN
|
data/lib/pry/shell/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-shell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mehmet Emin INAC
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|