pryx 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pryx/common_plugins.rb +1 -4
- data/lib/pryx/version.rb +1 -1
- metadata +16 -25
- data/lib/break/binding_ext.rb +0 -9
- data/lib/break/command.rb +0 -22
- data/lib/break/commands/down_command.rb +0 -19
- data/lib/break/commands/next_command.rb +0 -24
- data/lib/break/commands/step_command.rb +0 -25
- data/lib/break/commands/tracepoint_command.rb +0 -51
- data/lib/break/commands/up_command.rb +0 -19
- data/lib/break/commands/where_command.rb +0 -9
- data/lib/break/commands.rb +0 -6
- data/lib/break/context.rb +0 -21
- data/lib/break/filter.rb +0 -17
- data/lib/break/irb/commands.rb +0 -23
- data/lib/break/irb/frontend.rb +0 -67
- data/lib/break/irb/overrides.rb +0 -10
- data/lib/break/irb.rb +0 -13
- data/lib/break/pry/commands.rb +0 -92
- data/lib/break/pry/extensions.rb +0 -56
- data/lib/break/pry/frontend.rb +0 -28
- data/lib/break/pry.rb +0 -37
- data/lib/break/session.rb +0 -39
- data/lib/break/testing.rb +0 -57
- data/lib/break/version.rb +0 -5
- data/lib/break.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f103fdc3949130cba0098bf43e28c8de891a98a45ba2cc47a39e3acceae96ba4
|
4
|
+
data.tar.gz: f923206b67cba8f0c8c6932a6f4ebcbb69348ecca558b1a255eac233de74ebab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f315016c8cebcefc7cb0c3de0c24ca16018c42f0dbdf63595138ada13152cc5ccfdc0ce80349265ed0a4e45d949c0ac421780fd5e0dc347983eceaf0bade22a
|
7
|
+
data.tar.gz: df142f61ddb4d41660c1f895a1ba5c4371be097166b991c71016f3a1b54ef77f16824716c88aa02763dcfda770cfb41e9c33f16afe8b0b54929da4a5f8c7d7a8
|
data/lib/pryx/common_plugins.rb
CHANGED
@@ -19,10 +19,7 @@ if defined? AwesomePrint
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
|
-
# See https://github.com/gsamokovarov/break/issues/9
|
24
|
-
|
25
|
-
require_relative '../break'
|
22
|
+
require 'break'
|
26
23
|
Pry.commands.alias_command 'n', 'next'
|
27
24
|
Pry.commands.alias_command 's', 'step'
|
28
25
|
Pry.commands.alias_command 'w', 'watch' # watch is pry builtin
|
data/lib/pryx/version.rb
CHANGED
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.8.
|
4
|
+
version: 0.8.1
|
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-05-
|
11
|
+
date: 2022-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: break
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.40.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.40.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: clipboard
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,29 +235,6 @@ files:
|
|
221
235
|
- bin/irbx
|
222
236
|
- bin/pry!
|
223
237
|
- 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
|
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
|
247
238
|
- lib/pry-byebug.rb
|
248
239
|
- lib/pry-byebug/WARN
|
249
240
|
- lib/pry-byebug/base.rb
|
data/lib/break/binding_ext.rb
DELETED
data/lib/break/command.rb
DELETED
@@ -1,22 +0,0 @@
|
|
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
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,24 +0,0 @@
|
|
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
|
@@ -1,25 +0,0 @@
|
|
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
|
@@ -1,51 +0,0 @@
|
|
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
|
@@ -1,19 +0,0 @@
|
|
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
|
data/lib/break/commands.rb
DELETED
data/lib/break/context.rb
DELETED
@@ -1,21 +0,0 @@
|
|
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
DELETED
@@ -1,17 +0,0 @@
|
|
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
|
data/lib/break/irb/commands.rb
DELETED
@@ -1,23 +0,0 @@
|
|
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
|
data/lib/break/irb/frontend.rb
DELETED
@@ -1,67 +0,0 @@
|
|
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/overrides.rb
DELETED
data/lib/break/irb.rb
DELETED
@@ -1,13 +0,0 @@
|
|
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
|
data/lib/break/pry/commands.rb
DELETED
@@ -1,92 +0,0 @@
|
|
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
|
data/lib/break/pry/extensions.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Break::Pry
|
4
|
-
module PryExtensions
|
5
|
-
attr_accessor :__break_session__
|
6
|
-
|
7
|
-
def initialize(options={})
|
8
|
-
super(options)
|
9
|
-
|
10
|
-
@__break_session__ = options[:__break_session__]
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
Pry.prepend Break::Pry::PryExtensions
|
16
|
-
|
17
|
-
begin
|
18
|
-
require 'pry-remote'
|
19
|
-
|
20
|
-
module Break::Pry
|
21
|
-
class << self
|
22
|
-
attr_accessor :current_remote_server
|
23
|
-
end
|
24
|
-
|
25
|
-
module PryRemoteServerExtensions
|
26
|
-
def initialize(*)
|
27
|
-
Break::Pry.current_remote_server&.teardown
|
28
|
-
|
29
|
-
super
|
30
|
-
end
|
31
|
-
|
32
|
-
def run
|
33
|
-
return if Break::Pry.current_remote_server
|
34
|
-
|
35
|
-
Break::Pry.current_remote_server = self
|
36
|
-
|
37
|
-
setup
|
38
|
-
|
39
|
-
Pry.start @object, @options.merge(input: client.input_proxy, output: client.output)
|
40
|
-
end
|
41
|
-
|
42
|
-
def teardown
|
43
|
-
super
|
44
|
-
ensure
|
45
|
-
Break::Pry.current_remote_server = nil
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
# Hack for break works with pry_remote.
|
51
|
-
# More details, see: https://github.com/gsamokovarov/break/issues/9
|
52
|
-
|
53
|
-
# PryRemote::Server.prepend Break::Pry::PryRemoteServerExtensions
|
54
|
-
rescue LoadError
|
55
|
-
# Do nothing if we cannot require pry-remote.
|
56
|
-
end
|
data/lib/break/pry/frontend.rb
DELETED
@@ -1,28 +0,0 @@
|
|
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
DELETED
@@ -1,37 +0,0 @@
|
|
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
|
data/lib/break/session.rb
DELETED
@@ -1,39 +0,0 @@
|
|
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
|
data/lib/break/testing.rb
DELETED
@@ -1,57 +0,0 @@
|
|
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/version.rb
DELETED
data/lib/break.rb
DELETED
@@ -1,15 +0,0 @@
|
|
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:"
|