pryx 0.6.1 → 0.8.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/README.md +20 -7
- data/lib/break/binding_ext.rb +9 -0
- data/lib/break/command.rb +22 -0
- data/lib/break/commands/down_command.rb +19 -0
- data/lib/break/commands/next_command.rb +24 -0
- data/lib/break/commands/step_command.rb +25 -0
- data/lib/break/commands/tracepoint_command.rb +51 -0
- data/lib/break/commands/up_command.rb +19 -0
- data/lib/break/commands/where_command.rb +9 -0
- data/lib/break/commands.rb +6 -0
- data/lib/break/context.rb +21 -0
- data/lib/break/filter.rb +17 -0
- data/lib/break/irb/commands.rb +23 -0
- data/lib/break/irb/frontend.rb +67 -0
- data/lib/break/irb/overrides.rb +10 -0
- data/lib/break/irb.rb +13 -0
- data/lib/break/pry/commands.rb +92 -0
- data/lib/break/pry/frontend.rb +28 -0
- data/lib/break/pry.rb +37 -0
- data/lib/break/session.rb +39 -0
- data/lib/break/testing.rb +57 -0
- data/lib/break/version.rb +5 -0
- data/lib/break.rb +15 -0
- data/lib/pryx/common_plugins.rb +23 -4
- data/lib/pryx/pry_hack.rb +15 -13
- data/lib/pryx/pry_plugins.rb +6 -4
- data/lib/pryx/version.rb +1 -1
- data/lib/pryx.rb +1 -1
- metadata +57 -37
- data/lib/pryx/ap_hack.rb +0 -15
- data/lib/pryx/break_hack.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201316b55fb222f72cfdddd561767a135fe203d749e3c0bdbb27498141063120
|
4
|
+
data.tar.gz: ebe0d7afe5b5a6b1aa38c615538fc316e3a2b7a8b6460010f9d5bf7437739000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b8b8fa86de79e7a8527790e32a74ba42a9277d30c73a7f678c18e5fa5f05a05537d1762d0327eb2545a204749bf25b25c8c4f94cc15b371d18ed34ce717dc1
|
7
|
+
data.tar.gz: a05a4acd097aa02fb00a0db9fa5e7e27789944126ce2902a11d051658d5bdaeff0fbfc450cc5e6448670ab9d007141a787b53e4bb3b486664ceb6b837194b084
|
data/README.md
CHANGED
@@ -55,6 +55,18 @@ use http connection.
|
|
55
55
|
Until now, you've only seen the tip of the iceberg, please have a try.
|
56
56
|
|
57
57
|
|
58
|
+
If you prefer to use IRB over Pry, use can add following code instead.
|
59
|
+
|
60
|
+
```sh
|
61
|
+
$: export RUBYOPT+=' -rpryx_irb'
|
62
|
+
$: ruby your_file.rb # add pry! in your_file for start pry session
|
63
|
+
```
|
64
|
+
|
65
|
+
__WARN__: `require 'pryx_irb'` will enable many gems by default in your's ruby code.
|
66
|
+
so, prefer to use `require 'pryx'`, because latter almost not affect your's code,
|
67
|
+
only several methods added into Kernel#, and gems only be require if you run invoke
|
68
|
+
those added methods.
|
69
|
+
|
58
70
|
## useful command which added directly to Kernel#
|
59
71
|
|
60
72
|
### Kernel#pry!
|
@@ -70,7 +82,7 @@ $: RUBYOPT+='-rpryx_irb' ruby your_file.rb # add irb! in your_file for start pry
|
|
70
82
|
|
71
83
|
Following feature both available when start a Pry or IRB session:
|
72
84
|
|
73
|
-
1. Add `next/step/up/down` command for debug, use [break](https://github.com/gsamokovarov/break)
|
85
|
+
1. Add `next/step/up/down` command for debug, use [break](https://github.com/gsamokovarov/break) [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)
|
74
86
|
2. Add `Kernel#ls1`(use ls1 to avoid conflict with pry builtin ls command), see [looksee](https://github.com/oggy/looksee)
|
75
87
|
3. Use `ap` for pretty print. see [awesome-print](https://github.com/awesome-print/awesome_print)
|
76
88
|
4. Use `Clipboard.copy` or `Clipboard.paste` to interactive with system clipboard. see [clipboard](https://github.com/janlelis/clipboard)
|
@@ -86,7 +98,8 @@ Following is pry command available only after start a Pry session:
|
|
86
98
|
5. Add `pry-aa_ancestors` command for print the class hierarchy, see [pry-aa_ancestors](https://github.com/tbpgr/pry-aa_ancestors)
|
87
99
|
6. Add `up/down/frame/stack` command, see [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)
|
88
100
|
7. Add `yes` or `y` command, see [pry-yes](https://github.com/christofferh/pry-yes)
|
89
|
-
8. Add `
|
101
|
+
8. Add `reload!` command , see [pry-reload](https://github.com/runa/pry-reload)
|
102
|
+
9. Add `pry-disam`, Check following screenshot for a example:
|
90
103
|
|
91
104
|

|
92
105
|
|
@@ -119,11 +132,12 @@ pryx is same as pry, but, with plugins and libraries correct configured.
|
|
119
132
|
|
120
133
|
irbx is same things for irb.
|
121
134
|
|
122
|
-
pry
|
123
|
-
you can
|
135
|
+
`pry!` just a alias to `binding.pry`, but, if process is running on background, it a alias to `binding.remote_pry('0.0.0.0', 9876)`,
|
136
|
+
you can specify host or port manually, like this: `pry!(host: '192.168.1.100')`.
|
137
|
+
in another terminal, you can run `pry!` directly to connect to it use IP + port.
|
124
138
|
|
125
|
-
|
126
|
-
|
139
|
+
e.g. assume your's pry-remote server started background on another host(192.168.1.100), port 9876
|
140
|
+
It maybe in container, you can connect remote pry like this:
|
127
141
|
|
128
142
|
```sh
|
129
143
|
$: pry! -s 192.168.1.100 -p 9876
|
@@ -138,7 +152,6 @@ namespace/variables etc.
|
|
138
152
|
|
139
153
|
But, you should only use it in development, though, it was tested is run in container(alpine) too.
|
140
154
|
|
141
|
-
|
142
155
|
## Limit
|
143
156
|
|
144
157
|
1. `break` not work well if you add more than one break point, but still use `next` goto the next break point,
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "forwardable"
|
4
|
+
|
5
|
+
module Break
|
6
|
+
class Command
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
def initialize(session)
|
10
|
+
@session = session
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
attr_reader :session
|
20
|
+
def_delegators :session, :context, :context!, :frontend
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class DownCommand < TracePointCommand
|
5
|
+
def execute(*)
|
6
|
+
if context.depth >= 0
|
7
|
+
frontend.notify("Cannot go further down the stack")
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute_trace(trace, *)
|
14
|
+
trace.disable
|
15
|
+
|
16
|
+
context!(*context.bindings, depth: context.depth + 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class NextCommand < TracePointCommand
|
5
|
+
trace :line, :call, :return, :class, :end, :b_call, :b_return
|
6
|
+
|
7
|
+
def execute_trace(trace, *)
|
8
|
+
case trace.event
|
9
|
+
when :call, :class, :b_call
|
10
|
+
context.bindings << trace.binding
|
11
|
+
context.depth += 1
|
12
|
+
when :return, :end, :b_return
|
13
|
+
context.bindings.pop
|
14
|
+
context.depth -= 1
|
15
|
+
when :line
|
16
|
+
return if context.depth.positive?
|
17
|
+
|
18
|
+
trace.disable
|
19
|
+
|
20
|
+
context!(*context.bindings[0...-1], trace.binding)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class StepCommand < TracePointCommand
|
5
|
+
trace :line, :call, :return, :class, :end, :b_call, :b_return
|
6
|
+
|
7
|
+
def execute_trace(trace, *)
|
8
|
+
case trace.event
|
9
|
+
when :call, :class, :b_call
|
10
|
+
trace.disable
|
11
|
+
|
12
|
+
context!(*context.bindings, trace.binding)
|
13
|
+
when :return, :end, :b_return
|
14
|
+
context.bindings.pop
|
15
|
+
context.depth -= 1
|
16
|
+
when :line
|
17
|
+
return if context.depth.positive?
|
18
|
+
|
19
|
+
trace.disable
|
20
|
+
|
21
|
+
context!(*context.bindings[0...-1], trace.binding)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class TracePointCommand < Command
|
5
|
+
class << self
|
6
|
+
attr_reader :trace_events
|
7
|
+
|
8
|
+
def trace(*events)
|
9
|
+
@trace_events = events
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(*)
|
14
|
+
super
|
15
|
+
|
16
|
+
@delayed_context = Fiber.new do |*args|
|
17
|
+
session.context!(*args)
|
18
|
+
|
19
|
+
loop do
|
20
|
+
session.context!(*Fiber.yield)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute(*args)
|
26
|
+
TracePoint.trace(*trace_events) do |trace|
|
27
|
+
next if Filter.internal?(trace.path)
|
28
|
+
|
29
|
+
execute_trace(trace, *args)
|
30
|
+
end
|
31
|
+
|
32
|
+
session.leave
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute_trace
|
36
|
+
raise NotImplementedError
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def context!(*args)
|
42
|
+
@delayed_context.resume(*args)
|
43
|
+
rescue FiberError
|
44
|
+
session.context!(*args)
|
45
|
+
end
|
46
|
+
|
47
|
+
def trace_events
|
48
|
+
self.class.trace_events
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class UpCommand < TracePointCommand
|
5
|
+
def execute(*)
|
6
|
+
if context.bindings[context.depth - 2]
|
7
|
+
super
|
8
|
+
else
|
9
|
+
frontend.notify("Cannot go further up the stack")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute_trace(trace, *)
|
14
|
+
trace.disable
|
15
|
+
|
16
|
+
context!(*context.bindings, depth: context.depth - 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class Context
|
5
|
+
attr_accessor :bindings
|
6
|
+
attr_accessor :depth
|
7
|
+
|
8
|
+
def initialize(*bindings, depth: 0)
|
9
|
+
@bindings = bindings
|
10
|
+
@depth = depth
|
11
|
+
end
|
12
|
+
|
13
|
+
def binding
|
14
|
+
@bindings[@depth - 1]
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect
|
18
|
+
"#{path}:#{lineno}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/break/filter.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
module Filter
|
5
|
+
extend self
|
6
|
+
|
7
|
+
attr_reader :internal
|
8
|
+
|
9
|
+
def register_internal(*paths)
|
10
|
+
(@internal ||= []).concat(paths)
|
11
|
+
end
|
12
|
+
|
13
|
+
def internal?(path)
|
14
|
+
@internal.any? { |location| path.include?(location) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
module Break::IRB
|
6
|
+
class Commands < Module
|
7
|
+
def initialize(session)
|
8
|
+
define_command session, :next, Break::NextCommand
|
9
|
+
define_command session, :step, Break::StepCommand
|
10
|
+
define_command session, :up, Break::UpCommand
|
11
|
+
define_command session, :down, Break::DownCommand
|
12
|
+
define_command session, :whereami, Break::WhereCommand
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def define_command(session, name, cls)
|
18
|
+
define_method(name) do |*args|
|
19
|
+
cls.new(session).execute(*args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "irb"
|
4
|
+
|
5
|
+
module Break::IRB
|
6
|
+
class Frontend
|
7
|
+
def initialize
|
8
|
+
IRB.setup caller_locations.first.path, argv: []
|
9
|
+
end
|
10
|
+
|
11
|
+
def attach(session)
|
12
|
+
@workspace = IRB::WorkSpace.new(session.context.binding)
|
13
|
+
@irb = safely_build_irb_instance(session, @workspace)
|
14
|
+
|
15
|
+
where
|
16
|
+
|
17
|
+
@irb.suspend_context special_case_next_eval(@irb.context) do
|
18
|
+
@irb.run(IRB.conf)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def detach
|
23
|
+
@irb&.context&.exit
|
24
|
+
end
|
25
|
+
|
26
|
+
def where
|
27
|
+
puts @workspace.code_around_binding if @workspace
|
28
|
+
end
|
29
|
+
|
30
|
+
def notify(message)
|
31
|
+
puts message
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Evaling `next` is a `SyntaxError` in Ruby. Since IRB does not have
|
37
|
+
# commands support in the lexer level, we need to call the `next` command
|
38
|
+
# in syntactically correct way.
|
39
|
+
def special_case_next_eval(irb_context)
|
40
|
+
def irb_context.evaluate(line, line_no, *args, **kwargs)
|
41
|
+
line = "self.next\n" if line == "next\n"
|
42
|
+
super(line, line_no, *args, **kwargs)
|
43
|
+
end
|
44
|
+
|
45
|
+
irb_context
|
46
|
+
end
|
47
|
+
|
48
|
+
# Trying to instantiate an `IRB:Irb` object with a workspace having a
|
49
|
+
# binding coming from `BasicObject`.
|
50
|
+
def safely_build_irb_instance(session, workspace)
|
51
|
+
irb = IRB::Irb.allocate
|
52
|
+
irb.instance_variable_set :@context, IRB::Context.new(irb, workspace, nil)
|
53
|
+
irb.instance_variable_set :@signal_status, :IN_IRB
|
54
|
+
irb.instance_variable_set :@scanner, RubyLex.new
|
55
|
+
|
56
|
+
begin
|
57
|
+
irb.context.main.extend IRB::ExtendCommandBundle
|
58
|
+
rescue NameError, TypeError
|
59
|
+
# Potential `NameError`: undefined method `irb_print_working_workspace' for class `#<Class:#420>'.
|
60
|
+
# Ignore it.
|
61
|
+
end
|
62
|
+
|
63
|
+
irb.context.main.extend Commands.new(session)
|
64
|
+
irb
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/break/irb.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "irb/frontend"
|
4
|
+
require_relative "irb/commands"
|
5
|
+
require_relative "irb/overrides"
|
6
|
+
|
7
|
+
require "open-uri"
|
8
|
+
|
9
|
+
Break::Filter.register_internal IRB.method(:start).source_location.first.chomp(".rb")
|
10
|
+
Break::Filter.register_internal URI.method(:open).source_location.first.chomp(".rb")
|
11
|
+
Break::Filter.register_internal "(irb)"
|
12
|
+
|
13
|
+
Binding.prepend Break::IRB::Overrides
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break::Pry
|
4
|
+
Commands = Pry::CommandSet.new do
|
5
|
+
create_command "next", "Go to the next line." do
|
6
|
+
group "Break"
|
7
|
+
|
8
|
+
banner <<-BANNER
|
9
|
+
Usage: next
|
10
|
+
|
11
|
+
Step over within the same frame.
|
12
|
+
|
13
|
+
Examples:
|
14
|
+
next #=> Move a line forward.
|
15
|
+
BANNER
|
16
|
+
|
17
|
+
def process
|
18
|
+
pry = defined?(pry_instance) ? pry_instance : _pry_
|
19
|
+
pry.__break_session__[:pry_instance] = pry
|
20
|
+
|
21
|
+
|
22
|
+
command = Break::NextCommand.new(pry.__break_session__)
|
23
|
+
command.execute
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
create_command "step", "Step into the current line invocation." do
|
28
|
+
group "Break"
|
29
|
+
|
30
|
+
banner <<-BANNER
|
31
|
+
Usage: step
|
32
|
+
|
33
|
+
Step into a method call.
|
34
|
+
|
35
|
+
Examples:
|
36
|
+
step #=> Step into the method invocation.
|
37
|
+
BANNER
|
38
|
+
|
39
|
+
def process
|
40
|
+
pry = defined?(pry_instance) ? pry_instance : _pry_
|
41
|
+
pry.__break_session__[:pry_instance] = pry
|
42
|
+
|
43
|
+
command = Break::StepCommand.new(pry.__break_session__)
|
44
|
+
command.execute
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
create_command "up", "Go up a frame." do
|
49
|
+
group "Break"
|
50
|
+
|
51
|
+
banner <<-BANNER
|
52
|
+
Usage: up
|
53
|
+
|
54
|
+
Go to the frame that called the current one. Can be used only if the
|
55
|
+
command `step` was issued before.
|
56
|
+
|
57
|
+
Examples:
|
58
|
+
up #=> Step into the method invocation.
|
59
|
+
BANNER
|
60
|
+
|
61
|
+
def process
|
62
|
+
pry = defined?(pry_instance) ? pry_instance : _pry_
|
63
|
+
pry.__break_session__[:pry_instance] = pry
|
64
|
+
|
65
|
+
command = Break::UpCommand.new(pry.__break_session__)
|
66
|
+
command.execute
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
create_command "down", "Go down a frame." do
|
71
|
+
group "Break"
|
72
|
+
|
73
|
+
banner <<-BANNER
|
74
|
+
Usage: down
|
75
|
+
|
76
|
+
Go to the frame called from the current one. Can be used only if the
|
77
|
+
command `step` was issued before.
|
78
|
+
|
79
|
+
Examples:
|
80
|
+
down #=> Step to the previous frame.
|
81
|
+
BANNER
|
82
|
+
|
83
|
+
def process
|
84
|
+
pry = defined?(pry_instance) ? pry_instance : _pry_
|
85
|
+
pry.__break_session__[:pry_instance] = pry
|
86
|
+
|
87
|
+
command = Break::DownCommand.new(pry.__break_session__)
|
88
|
+
command.execute
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break::Pry
|
4
|
+
class Frontend
|
5
|
+
def attach(session)
|
6
|
+
previous_pry = session[:pry_instance]
|
7
|
+
|
8
|
+
@pry = Pry.start session.context.binding, __break_session__: session,
|
9
|
+
input: previous_pry.input,
|
10
|
+
output: previous_pry.output
|
11
|
+
where
|
12
|
+
end
|
13
|
+
|
14
|
+
def detach
|
15
|
+
throw :breakout
|
16
|
+
end
|
17
|
+
|
18
|
+
def where
|
19
|
+
@pry&.run_command "whereami".dup
|
20
|
+
rescue MethodSource::SourceNotFoundError
|
21
|
+
puts "Cannot find method code."
|
22
|
+
end
|
23
|
+
|
24
|
+
def notify(message)
|
25
|
+
puts message
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/break/pry.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "pry"
|
5
|
+
|
6
|
+
require_relative "pry/frontend"
|
7
|
+
require_relative "pry/commands"
|
8
|
+
require_relative "pry/extensions"
|
9
|
+
|
10
|
+
Break::Filter.register_internal MethodSource.method(:source_helper).source_location.first.chomp(".rb")
|
11
|
+
Break::Filter.register_internal CodeRay.method(:scan).source_location.first.chomp(".rb")
|
12
|
+
Break::Filter.register_internal Pry.method(:start).source_location.first.chomp("/pry_class.rb")
|
13
|
+
Break::Filter.register_internal Forwardable.instance_method(:def_delegator).source_location.first.chomp(".rb")
|
14
|
+
Break::Filter.register_internal "(pry)"
|
15
|
+
Break::Filter.register_internal __dir__
|
16
|
+
|
17
|
+
Pry.config.hooks.add_hook :before_session, :start_initial_break_session do |_, _, pry|
|
18
|
+
pry.__break_session__ ||= Break::Session.new(pry.current_binding, frontend: Break::Pry::Frontend.new)
|
19
|
+
end
|
20
|
+
|
21
|
+
Pry.config.commands.import Break::Pry::Commands
|
22
|
+
|
23
|
+
begin
|
24
|
+
require "pry-remote"
|
25
|
+
|
26
|
+
Break::Filter.register_internal binding.method(:remote_pry).source_location.first.chomp('.rb')
|
27
|
+
Break::Filter.register_internal DRb.method(:start_service).source_location.first.chomp('/drb.rb')
|
28
|
+
|
29
|
+
at_exit do
|
30
|
+
Break::Pry.current_remote_server&.teardown
|
31
|
+
end
|
32
|
+
rescue LoadError
|
33
|
+
# Do nothing if we cannot require pry-remote.
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
# Do nothing if we cannot require pry.
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Break
|
4
|
+
class Session
|
5
|
+
attr_reader :contexts
|
6
|
+
attr_reader :frontend
|
7
|
+
|
8
|
+
def initialize(binding, frontend:)
|
9
|
+
@contexts = [Context.new(binding)]
|
10
|
+
@frontend = frontend
|
11
|
+
@metadata = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def enter
|
15
|
+
frontend.attach(self)
|
16
|
+
end
|
17
|
+
|
18
|
+
def leave
|
19
|
+
frontend.detach
|
20
|
+
end
|
21
|
+
|
22
|
+
def context
|
23
|
+
contexts.last
|
24
|
+
end
|
25
|
+
|
26
|
+
def context!(*bindings, depth: 0)
|
27
|
+
contexts << Context.new(*bindings, depth: depth)
|
28
|
+
enter
|
29
|
+
end
|
30
|
+
|
31
|
+
def [](key)
|
32
|
+
@metadata[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
def []=(key, value)
|
36
|
+
@metadata[key] = value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "minitest"
|
4
|
+
|
5
|
+
module Break
|
6
|
+
class TestingFrontend
|
7
|
+
class << self
|
8
|
+
def build(&block)
|
9
|
+
Class.new(self, &block)
|
10
|
+
end
|
11
|
+
|
12
|
+
def stack
|
13
|
+
@stack ||= []
|
14
|
+
end
|
15
|
+
|
16
|
+
def [](index)
|
17
|
+
stack[index]
|
18
|
+
end
|
19
|
+
|
20
|
+
def last
|
21
|
+
stack.last
|
22
|
+
end
|
23
|
+
|
24
|
+
def clear
|
25
|
+
stack.clear
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
attr_reader :session
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
self.class.stack << self
|
33
|
+
end
|
34
|
+
|
35
|
+
def attach(session)
|
36
|
+
@session = session
|
37
|
+
end
|
38
|
+
|
39
|
+
def detach; end
|
40
|
+
|
41
|
+
def where; end
|
42
|
+
|
43
|
+
def notify(_message); end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Test < Minitest::Test
|
47
|
+
def self.test(name, &block)
|
48
|
+
define_method("test_#{name}", &block)
|
49
|
+
end
|
50
|
+
|
51
|
+
def pass
|
52
|
+
Kernel.binding.tap do |binding|
|
53
|
+
yield binding if block_given?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/break.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "break/version"
|
4
|
+
require_relative "break/session"
|
5
|
+
require_relative "break/context"
|
6
|
+
require_relative "break/command"
|
7
|
+
require_relative "break/commands"
|
8
|
+
require_relative "break/filter"
|
9
|
+
require_relative "break/binding_ext"
|
10
|
+
|
11
|
+
require_relative "break/irb"
|
12
|
+
require_relative "break/pry"
|
13
|
+
|
14
|
+
Break::Filter.register_internal __dir__
|
15
|
+
Break::Filter.register_internal "<internal:"
|
data/lib/pryx/common_plugins.rb
CHANGED
@@ -1,9 +1,28 @@
|
|
1
1
|
require 'binding_of_caller'
|
2
2
|
require 'clipboard'
|
3
3
|
|
4
|
-
#
|
4
|
+
# HACK: for ap 可以确保,当使用 irb! 时,looksee ls1 输出显示正确,同时不用关闭 irb :USE_COLORIZE 设置。
|
5
5
|
# See https://github.com/oggy/looksee/issues/57
|
6
6
|
# 但是,ap_hack 必须放到 break_hack 前面,调换顺序,上面的 hack 失效。
|
7
|
-
# WARN:
|
8
|
-
require '
|
9
|
-
|
7
|
+
# WARN: 下面两行 require 代码顺序不要换。
|
8
|
+
require 'awesome_print'
|
9
|
+
|
10
|
+
# AwesomePrint.defaults = {
|
11
|
+
# index: false
|
12
|
+
# }
|
13
|
+
|
14
|
+
if defined? AwesomePrint
|
15
|
+
if defined? Pry
|
16
|
+
AwesomePrint.pry!
|
17
|
+
else
|
18
|
+
AwesomePrint.irb!
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Add break gem into pryx for fix pry-remote issue.
|
23
|
+
# See https://github.com/gsamokovarov/break/issues/9
|
24
|
+
|
25
|
+
require_relative '../break'
|
26
|
+
Pry.commands.alias_command 'n', 'next'
|
27
|
+
Pry.commands.alias_command 's', 'step'
|
28
|
+
Pry.commands.alias_command 'w', 'watch' # watch is pry builtin
|
data/lib/pryx/pry_hack.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# 注意如果开启 pry-stack_explorer, 就不要使用 debugger, 因为进入新的上下文后, pry-stack_explorer 将失效.
|
2
2
|
|
3
3
|
class Binding
|
4
|
-
def _pry(host
|
4
|
+
def _pry(host: nil, port: nil, options: {})
|
5
5
|
if host
|
6
6
|
require 'pry-remote'
|
7
7
|
else
|
@@ -14,7 +14,7 @@ class Binding
|
|
14
14
|
if host
|
15
15
|
notify_send('loading remote pry ...')
|
16
16
|
# remote_pry(host, port, options) if Pry.initial_session?
|
17
|
-
remote_pry(host, port, options)
|
17
|
+
self.remote_pry(host, port, options)
|
18
18
|
else
|
19
19
|
warn '[1m[33mloading pry ...[0m'
|
20
20
|
self.pry
|
@@ -24,12 +24,14 @@ end
|
|
24
24
|
|
25
25
|
module Kernel
|
26
26
|
# 运行 pry! 会被拦截, 且只会被拦截一次.
|
27
|
-
def pry!(
|
28
|
-
|
27
|
+
def pry!(host: nil, port: 9876)
|
28
|
+
if Pryx::Background.foreground? and host.nil?
|
29
|
+
return unless ENV['Pry_was_started'].nil?
|
29
30
|
|
30
|
-
|
31
|
+
ENV['Pry_was_started'] = 'true'
|
32
|
+
end
|
31
33
|
|
32
|
-
pry3(2,
|
34
|
+
pry3(2, host: host, port: port)
|
33
35
|
|
34
36
|
# 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空.
|
35
37
|
end
|
@@ -41,13 +43,13 @@ module Kernel
|
|
41
43
|
|
42
44
|
# 和 pry! 的差别就是,pry? 使用 pry-state 插件输出当前 context 的很多变量内容。
|
43
45
|
# 注意:不需要总是开启 pry-state,因为有时候会输出太多内容,造成刷屏。
|
44
|
-
def pry?(
|
46
|
+
def pry?(host: nil, port: 9876)
|
45
47
|
return unless ENV['Pry_was_started'].nil?
|
46
48
|
|
47
49
|
require 'pry-state'
|
48
50
|
ENV['Pry_was_started'] = 'true'
|
49
51
|
|
50
|
-
pry3(2,
|
52
|
+
pry3(2, host: host, port: port)
|
51
53
|
|
52
54
|
# 这里如果有代码, 将会让 pry! 进入这个方法, 因此保持为空.
|
53
55
|
end
|
@@ -59,21 +61,21 @@ module Kernel
|
|
59
61
|
# 1. 单独运行 pry2, 永远不会被拦截,
|
60
62
|
# 2. 如果之前运行过 pry1, 此时 pry2 将被拦截, 且只会被拦截一次.
|
61
63
|
|
62
|
-
def pry2(
|
64
|
+
def pry2(host: nil, port: 9876)
|
63
65
|
if ENV['Pry2_should_start'] == 'true'
|
64
66
|
ENV['Pry2_should_start'] = nil
|
65
|
-
pry3(2,
|
67
|
+
pry3(2, host: host, port: port)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
69
71
|
# 等价于默认的 binding.pry, 会反复被拦截。
|
70
72
|
# 起成 pry3 这个名字,也是为了方便直接使用。
|
71
|
-
def pry3(caller=1,
|
72
|
-
|
73
|
+
def pry3(caller=1, host: nil, port: 9876)
|
74
|
+
host = '0.0.0.0' if Pryx::Background.background?
|
73
75
|
|
74
76
|
require 'binding_of_caller'
|
75
77
|
|
76
|
-
binding.of_caller(caller)._pry(
|
78
|
+
binding.of_caller(caller)._pry(host: host, port: port)
|
77
79
|
end
|
78
80
|
|
79
81
|
def notify_send(msg)
|
data/lib/pryx/pry_plugins.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
# power_assert is ruby 3 builtin gem
|
1
2
|
require 'pry-power_assert'
|
2
3
|
|
3
4
|
require 'pry-doc'
|
4
5
|
|
5
6
|
require 'pry-yes'
|
6
|
-
Pry.commands.alias_command 'y', 'yes'
|
7
7
|
|
8
8
|
require 'pry-hier'
|
9
9
|
|
@@ -12,11 +12,13 @@ require 'pry-disasm'
|
|
12
12
|
require 'pry-aa_ancestors'
|
13
13
|
Pry::Commands.alias_command 'aa', 'aa_ancestors'
|
14
14
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
require 'pry-stack_explorer'
|
15
|
+
# stack 显示 stack 的列表,
|
16
|
+
# frame 显示当前所在 stack, frame N 也可以根据数字跳转到 N
|
17
|
+
require 'pry-stack_explorer'
|
18
18
|
require 'pryx/pry-stack_explorer_hack'
|
19
19
|
|
20
|
+
require 'pry-reload'
|
21
|
+
|
20
22
|
Pry::Commands.block_command 'cc', 'Continue, but stop in pry! breakpoint' do
|
21
23
|
Pry.instance_variable_set(:@initial_session, true)
|
22
24
|
ENV['Pry_was_started'] = nil
|
data/lib/pryx/version.rb
CHANGED
data/lib/pryx.rb
CHANGED
@@ -9,7 +9,7 @@ require 'pryx/irb_hack'
|
|
9
9
|
|
10
10
|
# Add the non-bundler managermented gems back
|
11
11
|
# this step is necessory when install pryx in docker-compose
|
12
|
-
ENV['RUBYLIB'] = $LOAD_PATH.grep(/gems/).join(':')
|
12
|
+
ENV['RUBYLIB'] = "#{ENV['RUBYLIB']}:#{$LOAD_PATH.grep(/gems/).join(':')}"
|
13
13
|
|
14
14
|
# set export RUBYOPT+=" -rpryx" to work with pryx.
|
15
15
|
module Pryx
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pryx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Billy.Zheng(zw963)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: clipboard
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1.3'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '1.3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: looksee
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,33 +53,33 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0.14'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0.14'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
70
|
+
name: pry-aa_ancestors
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 0.0.1
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 0.0.1
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: pry-doc
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: pry-hier
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.1'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.1'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: pry-power_assert
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,33 +123,33 @@ dependencies:
|
|
109
123
|
- !ruby/object:Gem::Version
|
110
124
|
version: 0.0.2
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: pry-
|
126
|
+
name: pry-reload
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
131
|
+
version: '0.3'
|
118
132
|
type: :runtime
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0.
|
138
|
+
version: '0.3'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name: pry-
|
140
|
+
name: pry-rescue
|
127
141
|
requirement: !ruby/object:Gem::Requirement
|
128
142
|
requirements:
|
129
143
|
- - "~>"
|
130
144
|
- !ruby/object:Gem::Version
|
131
|
-
version:
|
145
|
+
version: '1.5'
|
132
146
|
type: :runtime
|
133
147
|
prerelease: false
|
134
148
|
version_requirements: !ruby/object:Gem::Requirement
|
135
149
|
requirements:
|
136
150
|
- - "~>"
|
137
151
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
152
|
+
version: '1.5'
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: pry-stack_explorer
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,19 +165,19 @@ dependencies:
|
|
151
165
|
- !ruby/object:Gem::Version
|
152
166
|
version: '0.6'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
168
|
+
name: m
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
156
170
|
requirements:
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
|
-
version: '1.
|
160
|
-
type: :
|
173
|
+
version: '1.6'
|
174
|
+
type: :development
|
161
175
|
prerelease: false
|
162
176
|
version_requirements: !ruby/object:Gem::Requirement
|
163
177
|
requirements:
|
164
178
|
- - "~>"
|
165
179
|
- !ruby/object:Gem::Version
|
166
|
-
version: '1.
|
180
|
+
version: '1.6'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: minitest
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,20 +192,6 @@ dependencies:
|
|
178
192
|
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: m
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '1.6'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '1.6'
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: ritual
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +221,29 @@ files:
|
|
221
221
|
- bin/irbx
|
222
222
|
- bin/pry!
|
223
223
|
- bin/pryx
|
224
|
+
- lib/break.rb
|
225
|
+
- lib/break/binding_ext.rb
|
226
|
+
- lib/break/command.rb
|
227
|
+
- lib/break/commands.rb
|
228
|
+
- lib/break/commands/down_command.rb
|
229
|
+
- lib/break/commands/next_command.rb
|
230
|
+
- lib/break/commands/step_command.rb
|
231
|
+
- lib/break/commands/tracepoint_command.rb
|
232
|
+
- lib/break/commands/up_command.rb
|
233
|
+
- lib/break/commands/where_command.rb
|
234
|
+
- lib/break/context.rb
|
235
|
+
- lib/break/filter.rb
|
236
|
+
- lib/break/irb.rb
|
237
|
+
- lib/break/irb/commands.rb
|
238
|
+
- lib/break/irb/frontend.rb
|
239
|
+
- lib/break/irb/overrides.rb
|
240
|
+
- lib/break/pry.rb
|
241
|
+
- lib/break/pry/commands.rb
|
224
242
|
- lib/break/pry/extensions.rb
|
243
|
+
- lib/break/pry/frontend.rb
|
244
|
+
- lib/break/session.rb
|
245
|
+
- lib/break/testing.rb
|
246
|
+
- lib/break/version.rb
|
225
247
|
- lib/pry-byebug.rb
|
226
248
|
- lib/pry-byebug/WARN
|
227
249
|
- lib/pry-byebug/base.rb
|
@@ -236,9 +258,7 @@ files:
|
|
236
258
|
- lib/pry-state/printer.rb
|
237
259
|
- lib/pry-yes.rb
|
238
260
|
- lib/pryx.rb
|
239
|
-
- lib/pryx/ap_hack.rb
|
240
261
|
- lib/pryx/background.rb
|
241
|
-
- lib/pryx/break_hack.rb
|
242
262
|
- lib/pryx/common_plugins.rb
|
243
263
|
- lib/pryx/drip.wav
|
244
264
|
- lib/pryx/irb_hack.rb
|
data/lib/pryx/ap_hack.rb
DELETED