pry-moves 0.1.13 → 1.0.2
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/Gemfile +1 -1
- data/Gemfile.lock +9 -5
- data/README.md +25 -9
- data/lib/commands/debug.rb +21 -0
- data/lib/commands/finish.rb +26 -0
- data/lib/commands/goto.rb +19 -0
- data/lib/commands/iterate.rb +22 -0
- data/lib/commands/next.rb +37 -0
- data/lib/commands/next_breakpoint.rb +22 -0
- data/lib/commands/step.rb +83 -0
- data/lib/commands/trace_command.rb +87 -0
- data/lib/commands/trace_helpers.rb +49 -0
- data/lib/commands/traced_method.rb +71 -0
- data/lib/debug_sugar.rb +73 -0
- data/lib/pry-moves/add_suffix.rb +87 -0
- data/lib/pry-moves/backtrace.rb +99 -50
- data/lib/pry-moves/bindings_stack.rb +106 -0
- data/lib/pry-moves/commands.rb +42 -3
- data/lib/pry-moves/error_with_data.rb +10 -0
- data/lib/pry-moves/formatter.rb +79 -0
- data/lib/pry-moves/painter.rb +3 -2
- data/lib/pry-moves/pry_ext.rb +66 -18
- data/lib/pry-moves/pry_wrapper.rb +30 -17
- data/lib/pry-moves/recursion_tracker.rb +94 -0
- data/lib/pry-moves/restartable.rb +39 -0
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves/watch.rb +3 -0
- data/lib/pry-moves.rb +77 -6
- data/lib/pry-stack_explorer/frame_helpers.rb +114 -0
- data/lib/pry-stack_explorer/frame_manager.rb +6 -9
- data/lib/pry-stack_explorer/pry-stack_explorer.rb +2 -17
- data/lib/pry-stack_explorer/{commands.rb → stack_commands.rb} +6 -109
- data/lib/pry-stack_explorer/when_started_hook.rb +10 -65
- data/playground/Gemfile.lock +9 -5
- data/playground/README.md +1 -0
- data/playground/playground.rb +94 -9
- data/playground/sand.rb +12 -10
- data/playground/test.rb +5 -1
- data/playground/test.sh +1 -0
- data/pry-moves.gemspec +4 -2
- data/publish.sh +2 -1
- data/spec/backtrace_spec.rb +11 -13
- data/spec/blocks_spec.rb +41 -8
- data/spec/commands_spec.rb +26 -25
- data/spec/pry_debugger.rb +5 -1
- data/spec/redirection_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -4
- data/spec/step_spec.rb +51 -0
- metadata +60 -13
- data/lib/pry-moves/helpers.rb +0 -56
- data/lib/pry-moves/trace_commands.rb +0 -109
- data/lib/pry-moves/traced_method.rb +0 -61
- data/lib/pry-moves/tracer.rb +0 -140
- data/lib/pry-moves/traversing.rb +0 -69
data/spec/commands_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative 'spec_helper'
|
|
2
2
|
|
3
3
|
describe 'PryMoves commands' do
|
4
4
|
|
5
|
-
it 'should make one
|
5
|
+
it 'should make one move next' do
|
6
6
|
breakpoints [
|
7
7
|
[nil, 'basic next stop'],
|
8
8
|
['n', 'next step'],
|
@@ -10,7 +10,7 @@ describe 'PryMoves commands' do
|
|
10
10
|
Playground.new.basic_next
|
11
11
|
end
|
12
12
|
|
13
|
-
it 'should stop on second
|
13
|
+
it 'should stop on second binding.pry' do
|
14
14
|
breakpoints [
|
15
15
|
[nil, 'first stop'],
|
16
16
|
['c', 'second stop'],
|
@@ -18,37 +18,19 @@ describe 'PryMoves commands' do
|
|
18
18
|
Playground.new.continue
|
19
19
|
end
|
20
20
|
|
21
|
-
it 'should
|
21
|
+
it 'should walk over stack' do
|
22
22
|
breakpoints [
|
23
23
|
[nil, 'step_into stop'],
|
24
24
|
['s', 'point to step inside'],
|
25
25
|
['s', 'some internal line'],
|
26
26
|
['up', 'point to step inside'],
|
27
|
-
['up',
|
28
|
-
['up', {output_includes: 'top of stack'} ],
|
29
|
-
['down',
|
27
|
+
['up', 'spec example beginning' ],
|
28
|
+
#['up', {output_includes: 'top of stack'} ],
|
29
|
+
['down', 'point to step inside'],
|
30
30
|
['down', 'some internal line'],
|
31
31
|
['down', {output_includes: 'bottom of stack'} ],
|
32
32
|
]
|
33
|
-
Playground.new.step_into
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should step into func by name' do
|
37
|
-
breakpoints [
|
38
|
-
[nil, 'stop in step_by_name'],
|
39
|
-
['s level_c', 'stop in level_c'],
|
40
|
-
['param', {output: '=> :target'}],
|
41
|
-
['n', nil],
|
42
|
-
]
|
43
|
-
Playground.new.step_by_name
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should stop after inability to step into func by name' do
|
47
|
-
breakpoints [
|
48
|
-
[nil, 'stop in step_by_name'],
|
49
|
-
['s absent_function', 'after_step_by_name'],
|
50
|
-
]
|
51
|
-
Playground.new.step_by_name_wrap
|
33
|
+
Playground.new.step_into # spec example beginning
|
52
34
|
end
|
53
35
|
|
54
36
|
it 'should go next over recursion calls' do
|
@@ -61,6 +43,15 @@ describe 'PryMoves commands' do
|
|
61
43
|
Playground.new.recursion
|
62
44
|
end
|
63
45
|
|
46
|
+
it 'should stop after finishing early return' do
|
47
|
+
breakpoints [
|
48
|
+
[nil, 'stop in level_c'],
|
49
|
+
['f', 'at early return'],
|
50
|
+
['f', 'after early return']
|
51
|
+
]
|
52
|
+
Playground.new.early_return_wrap
|
53
|
+
end
|
54
|
+
|
64
55
|
it 'should debug' do
|
65
56
|
breakpoints [
|
66
57
|
[nil, 'basic next stop'],
|
@@ -70,4 +61,14 @@ describe 'PryMoves commands' do
|
|
70
61
|
Playground.new.basic_next
|
71
62
|
end
|
72
63
|
|
64
|
+
it 'should next breakpoint' do
|
65
|
+
breakpoints [
|
66
|
+
[nil, 'method_with_breakpoints host'],
|
67
|
+
['b', 'breakpoint'],
|
68
|
+
['n', 'after breakpoint'],
|
69
|
+
['b', 'breakpoint 2']
|
70
|
+
]
|
71
|
+
Playground.new.method_with_breakpoints
|
72
|
+
end
|
73
|
+
|
73
74
|
end
|
data/spec/pry_debugger.rb
CHANGED
@@ -24,13 +24,17 @@ module PryDebugger
|
|
24
24
|
|
25
25
|
def compare(step, label, binding_, output)
|
26
26
|
exp = step[:expected]
|
27
|
+
puts "\nSTEP #{step[:index]}:\n#{output}" if ENV['PRINT']
|
27
28
|
if exp.is_a? Proc
|
28
29
|
exp.call binding_, output
|
29
30
|
elsif exp.is_a? Hash
|
30
31
|
if exp[:output_includes]
|
31
32
|
expect(output).to include exp[:output_includes]
|
32
33
|
else
|
33
|
-
|
34
|
+
err = <<-TEXT
|
35
|
+
[#{step[:index]}] #{step[:cmd]} expected output '#{exp[:output]}', got '#{output}'
|
36
|
+
TEXT
|
37
|
+
expect(output).to eq(exp[:output]), err
|
34
38
|
end
|
35
39
|
elsif not exp.nil?
|
36
40
|
err = <<-TEXT
|
data/spec/redirection_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
$VERBOSE = nil # Disable warnings for whole specs
|
2
|
+
|
1
3
|
require 'pry'
|
2
4
|
require_relative 'pry_debugger'
|
3
5
|
require_relative '../playground/playground.rb'
|
@@ -14,7 +16,8 @@ RSpec.configure do |config|
|
|
14
16
|
|
15
17
|
config.after(:example) do |example|
|
16
18
|
unless example.exception
|
17
|
-
expect(PryDebugger.breakpoints.count).to be(0),
|
19
|
+
expect(PryDebugger.breakpoints.count).to be(0),
|
20
|
+
"not all breakpoints launched: #{PryDebugger.breakpoints.count}"
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
@@ -34,9 +37,11 @@ RSpec::Core::BacktraceFormatter.class_eval do
|
|
34
37
|
|
35
38
|
FILTER = /(\/gems\/|\/lib\/pry\/|spec\/pry_debugger\.rb)/
|
36
39
|
def backtrace_line(line)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
unless ENV['TRACE']
|
41
|
+
return if @lines == 3
|
42
|
+
#return if line.match FILTER
|
43
|
+
return unless line.include? '/playground.rb'
|
44
|
+
end
|
40
45
|
|
41
46
|
result = native_backtrace_line(line)
|
42
47
|
if result
|
data/spec/step_spec.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe 'step' do
|
4
|
+
|
5
|
+
it 'should step into func by name' do
|
6
|
+
breakpoints [
|
7
|
+
[nil, 'stop in step_by_name'],
|
8
|
+
['s level_c', 'stop in level_c'],
|
9
|
+
['param', {output: '=> :target'}],
|
10
|
+
['n', nil],
|
11
|
+
]
|
12
|
+
Playground.new.step_by_name
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'should stop after inability to step into func by name' do
|
16
|
+
breakpoints [
|
17
|
+
[nil, 'stop in step_by_name'],
|
18
|
+
['s absent_function', 'after_step_by_name'],
|
19
|
+
]
|
20
|
+
Playground.new.step_by_name_wrap
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should skip hidden frames' do
|
24
|
+
breakpoints [
|
25
|
+
[nil, 'skip_hidden_impl stop'],
|
26
|
+
['s', 'point to step inside'],
|
27
|
+
['s', 'some internal line']
|
28
|
+
]
|
29
|
+
Playground.new.skip_hidden_impl
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should step down to hidden frame and resume there' do
|
33
|
+
breakpoints [
|
34
|
+
[nil, 'at root'],
|
35
|
+
['down', 'hidden stop'],
|
36
|
+
['n', 'hidden_stop for next'],
|
37
|
+
['s', 'hidden_stop for step']
|
38
|
+
]
|
39
|
+
Playground.new.hidden_stop # at root
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should skip hidden method' do
|
43
|
+
breakpoints [
|
44
|
+
[nil, 'stop in skip_test'],
|
45
|
+
['n', 'next step'],
|
46
|
+
['s', 'at not_skipped_method']
|
47
|
+
]
|
48
|
+
Playground.new.skip_test
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-moves
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- garmoshka-mo
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: 0.10.4
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 0.
|
22
|
+
version: '0.13'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: 0.10.4
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: '0.13'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: binding_of_caller
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,6 +44,34 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0.7'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: colorize
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0.8'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0.8'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: diffy
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 3.4.0
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 3.4.0
|
47
75
|
- !ruby/object:Gem::Dependency
|
48
76
|
name: pry-remote
|
49
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,25 +100,38 @@ files:
|
|
72
100
|
- README.md
|
73
101
|
- Rakefile
|
74
102
|
- dynamic_debug_experiments.rb
|
103
|
+
- lib/commands/debug.rb
|
104
|
+
- lib/commands/finish.rb
|
105
|
+
- lib/commands/goto.rb
|
106
|
+
- lib/commands/iterate.rb
|
107
|
+
- lib/commands/next.rb
|
108
|
+
- lib/commands/next_breakpoint.rb
|
109
|
+
- lib/commands/step.rb
|
110
|
+
- lib/commands/trace_command.rb
|
111
|
+
- lib/commands/trace_helpers.rb
|
112
|
+
- lib/commands/traced_method.rb
|
113
|
+
- lib/debug_sugar.rb
|
75
114
|
- lib/pry-moves.rb
|
115
|
+
- lib/pry-moves/add_suffix.rb
|
76
116
|
- lib/pry-moves/backtrace.rb
|
117
|
+
- lib/pry-moves/bindings_stack.rb
|
77
118
|
- lib/pry-moves/cli.rb
|
78
119
|
- lib/pry-moves/commands.rb
|
79
|
-
- lib/pry-moves/
|
120
|
+
- lib/pry-moves/error_with_data.rb
|
121
|
+
- lib/pry-moves/formatter.rb
|
80
122
|
- lib/pry-moves/painter.rb
|
81
123
|
- lib/pry-moves/pry_ext.rb
|
82
124
|
- lib/pry-moves/pry_remote_ext.rb
|
83
125
|
- lib/pry-moves/pry_wrapper.rb
|
84
|
-
- lib/pry-moves/
|
85
|
-
- lib/pry-moves/
|
86
|
-
- lib/pry-moves/tracer.rb
|
87
|
-
- lib/pry-moves/traversing.rb
|
126
|
+
- lib/pry-moves/recursion_tracker.rb
|
127
|
+
- lib/pry-moves/restartable.rb
|
88
128
|
- lib/pry-moves/version.rb
|
89
129
|
- lib/pry-moves/watch.rb
|
90
130
|
- lib/pry-stack_explorer/VERSION
|
91
|
-
- lib/pry-stack_explorer/
|
131
|
+
- lib/pry-stack_explorer/frame_helpers.rb
|
92
132
|
- lib/pry-stack_explorer/frame_manager.rb
|
93
133
|
- lib/pry-stack_explorer/pry-stack_explorer.rb
|
134
|
+
- lib/pry-stack_explorer/stack_commands.rb
|
94
135
|
- lib/pry-stack_explorer/when_started_hook.rb
|
95
136
|
- playground/Gemfile
|
96
137
|
- playground/Gemfile.lock
|
@@ -100,6 +141,7 @@ files:
|
|
100
141
|
- playground/recursions.rb
|
101
142
|
- playground/sand.rb
|
102
143
|
- playground/test.rb
|
144
|
+
- playground/test.sh
|
103
145
|
- playground/threads.rb
|
104
146
|
- playground/tracer.rb
|
105
147
|
- pry-moves.gemspec
|
@@ -110,11 +152,12 @@ files:
|
|
110
152
|
- spec/pry_debugger.rb
|
111
153
|
- spec/redirection_spec.rb
|
112
154
|
- spec/spec_helper.rb
|
155
|
+
- spec/step_spec.rb
|
113
156
|
homepage: https://github.com/garmoshka-mo/pry-moves
|
114
157
|
licenses:
|
115
158
|
- MIT
|
116
159
|
metadata: {}
|
117
|
-
post_install_message:
|
160
|
+
post_install_message:
|
118
161
|
rdoc_options: []
|
119
162
|
require_paths:
|
120
163
|
- lib
|
@@ -123,6 +166,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
123
166
|
- - ">="
|
124
167
|
- !ruby/object:Gem::Version
|
125
168
|
version: 1.8.7
|
169
|
+
- - "<"
|
170
|
+
- !ruby/object:Gem::Version
|
171
|
+
version: '3'
|
126
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
173
|
requirements:
|
128
174
|
- - ">="
|
@@ -130,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
176
|
version: '0'
|
131
177
|
requirements: []
|
132
178
|
rubygems_version: 3.1.2
|
133
|
-
signing_key:
|
179
|
+
signing_key:
|
134
180
|
specification_version: 4
|
135
181
|
summary: Debugger for ruby
|
136
182
|
test_files:
|
@@ -140,3 +186,4 @@ test_files:
|
|
140
186
|
- spec/pry_debugger.rb
|
141
187
|
- spec/redirection_spec.rb
|
142
188
|
- spec/spec_helper.rb
|
189
|
+
- spec/step_spec.rb
|
data/lib/pry-moves/helpers.rb
DELETED
@@ -1,56 +0,0 @@
|
|
1
|
-
module PryMoves::Helpers
|
2
|
-
|
3
|
-
extend self
|
4
|
-
|
5
|
-
# @return [String] Signature for the method object in Class#method format.
|
6
|
-
def method_signature_with_owner(binding)
|
7
|
-
meth = binding.eval('__method__')
|
8
|
-
meth_obj = meth ? Pry::Method.from_binding(binding) : nil
|
9
|
-
if !meth_obj
|
10
|
-
""
|
11
|
-
elsif meth_obj.undefined?
|
12
|
-
"#{meth_obj.name_with_owner}(UNKNOWN) (undefined method)"
|
13
|
-
else
|
14
|
-
args = meth_obj.parameters.inject([]) do |arr, (type, name)|
|
15
|
-
name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
|
16
|
-
arr << case type
|
17
|
-
when :req then name.to_s
|
18
|
-
when :opt then "#{name}=?"
|
19
|
-
when :rest then "*#{name}"
|
20
|
-
when :block then "&#{name}"
|
21
|
-
else '?'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
"#{meth_obj.name_with_owner}(#{args.join(', ')})"
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def method_signature(binding)
|
29
|
-
meth = binding.eval('__method__')
|
30
|
-
meth_obj = meth ? Pry::Method.from_binding(binding) : nil
|
31
|
-
if !meth_obj
|
32
|
-
""
|
33
|
-
elsif meth_obj.undefined?
|
34
|
-
"#{meth_obj.name}(UNKNOWN) (undefined method)"
|
35
|
-
else
|
36
|
-
args = meth_obj.parameters.inject([]) do |arr, (type, name)|
|
37
|
-
name ||= (type == :block ? 'block' : "arg#{arr.size + 1}")
|
38
|
-
arr << case type
|
39
|
-
when :req then name.to_s
|
40
|
-
when :opt then "#{name}=?"
|
41
|
-
when :rest then "*#{name}"
|
42
|
-
when :block then "&#{name}"
|
43
|
-
else '?'
|
44
|
-
end
|
45
|
-
end
|
46
|
-
"#{meth_obj.name}(#{args.join(', ')})"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
PATH_TRASH = defined?(Rails) ? Rails.root.to_s : Dir.pwd
|
51
|
-
|
52
|
-
def shorten_path(path)
|
53
|
-
path.gsub( /^#{PATH_TRASH}\//, '')
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
module PryMoves::TraceCommands
|
2
|
-
|
3
|
-
private
|
4
|
-
|
5
|
-
def trace_step(event, file, line, method, binding_)
|
6
|
-
return unless event == 'line'
|
7
|
-
|
8
|
-
if @step_in_everywhere
|
9
|
-
true
|
10
|
-
elsif @step_into_funcs
|
11
|
-
|
12
|
-
if @recursion_level < 0
|
13
|
-
pry_puts "⚠️ Unable to find function with name #{@step_into_funcs.join(',')}"
|
14
|
-
return true
|
15
|
-
end
|
16
|
-
|
17
|
-
method = binding_.eval('__callee__').to_s
|
18
|
-
return false unless method_matches?(method)
|
19
|
-
|
20
|
-
func_reached = (not @caller_digest or
|
21
|
-
# if we want to step-in only into straight descendant
|
22
|
-
@caller_digest == frame_digest(binding_.of_caller(3 + 1)))
|
23
|
-
|
24
|
-
if func_reached
|
25
|
-
@caller_digest = nil
|
26
|
-
not redirect_step_into? binding_
|
27
|
-
end
|
28
|
-
|
29
|
-
elsif redirect_step_into? binding_
|
30
|
-
false
|
31
|
-
else
|
32
|
-
not binding_.local_variable_defined? :hide_from_stack
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def trace_next(event, file, line, method, binding_)
|
37
|
-
traced_method_exit = (@recursion_level < 0 and %w(line call).include? event)
|
38
|
-
if traced_method_exit
|
39
|
-
# Set new traced method, because we left previous one
|
40
|
-
set_traced_method binding_
|
41
|
-
throw :skip if event == 'call'
|
42
|
-
end
|
43
|
-
|
44
|
-
if @recursion_level == 0 and
|
45
|
-
within_current_method?(file, line)
|
46
|
-
|
47
|
-
if event == 'line'
|
48
|
-
if @stay_at_frame
|
49
|
-
return (
|
50
|
-
@stay_at_frame == frame_digest(binding_.of_caller(3)) or
|
51
|
-
@c_stack_level < 0
|
52
|
-
)
|
53
|
-
else
|
54
|
-
return true
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
exit_from_method if event == 'return' and
|
59
|
-
method != :to_s and before_end?(line)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def trace_finish(event, file, line, method, binding_)
|
64
|
-
return unless event == 'line'
|
65
|
-
if @recursion_level < 0 or @method_to_finish != @method
|
66
|
-
if redirect_step_into?(binding_)
|
67
|
-
@action = :step
|
68
|
-
return false
|
69
|
-
end
|
70
|
-
return true
|
71
|
-
end
|
72
|
-
|
73
|
-
# for finishing blocks inside current method
|
74
|
-
if @block_to_finish
|
75
|
-
@recursion_level == 0 and
|
76
|
-
within_current_method?(file, line) and
|
77
|
-
@block_to_finish != frame_digest(binding_.of_caller(3))
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def trace_debug(event, file, line, method, binding_)
|
82
|
-
return unless event == 'line'
|
83
|
-
if @first_line_skipped
|
84
|
-
true
|
85
|
-
else
|
86
|
-
@first_line_skipped = true
|
87
|
-
false
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def trace_iterate(event, file, line, method, binding_)
|
92
|
-
return exit_from_method if event == 'return' and
|
93
|
-
within_current_method?(file, line)
|
94
|
-
|
95
|
-
# промотка итерации -
|
96
|
-
# попасть на ту же или предыдущую строку или выйти из дайджеста
|
97
|
-
# будучи в том же методе
|
98
|
-
event == 'line' and @recursion_level == 0 and
|
99
|
-
within_current_method?(file, line) and
|
100
|
-
(line <= @iteration_start_line or
|
101
|
-
@caller_digest != frame_digest(binding_.of_caller(3))
|
102
|
-
)
|
103
|
-
end
|
104
|
-
|
105
|
-
def trace_goto(event, file, line, method, binding_)
|
106
|
-
event == 'line' && @goto_line == line and @method[:file] == file
|
107
|
-
end
|
108
|
-
|
109
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module PryMoves::TracedMethod
|
2
|
-
|
3
|
-
private
|
4
|
-
|
5
|
-
def set_traced_method(binding)
|
6
|
-
@recursion_level = 0
|
7
|
-
@c_stack_level = 0
|
8
|
-
@stay_at_frame = nil # reset tracked digest
|
9
|
-
|
10
|
-
method = find_method_definition binding
|
11
|
-
if method
|
12
|
-
source = method.source_location
|
13
|
-
set_method({
|
14
|
-
file: source[0],
|
15
|
-
start: source[1],
|
16
|
-
name: method.name,
|
17
|
-
end: (source[1] + method.source.count("\n") - 1)
|
18
|
-
})
|
19
|
-
else
|
20
|
-
set_method({file: binding.eval('__FILE__')})
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def find_method_definition(binding)
|
25
|
-
method_name, obj, line, file =
|
26
|
-
binding.eval '[__method__, self, __LINE__, __FILE__]'
|
27
|
-
return unless method_name
|
28
|
-
|
29
|
-
method = obj.method(method_name)
|
30
|
-
return method if method.source_location[0] == file
|
31
|
-
|
32
|
-
# If found file was different - search definition at superclasses:
|
33
|
-
obj.class.ancestors.each do |cls|
|
34
|
-
if cls.instance_methods(false).include? method_name
|
35
|
-
method = cls.instance_method method_name
|
36
|
-
return method if method.source_location[0] == file
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
pry_puts "⚠️ Unable to find definition for method #{method_name} in #{obj}"
|
41
|
-
|
42
|
-
nil
|
43
|
-
end
|
44
|
-
|
45
|
-
def set_method(method)
|
46
|
-
#puts "set_traced_method #{method}"
|
47
|
-
@method = method
|
48
|
-
end
|
49
|
-
|
50
|
-
def within_current_method?(file, line)
|
51
|
-
@method[:file] == file and (
|
52
|
-
@method[:start].nil? or
|
53
|
-
line.between?(@method[:start], @method[:end])
|
54
|
-
)
|
55
|
-
end
|
56
|
-
|
57
|
-
def before_end?(line)
|
58
|
-
@method[:end] and line < @method[:end]
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|