pry-moves 1.0.0 → 1.0.1
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.lock +2 -2
- data/lib/pry-moves/add_suffix.rb +0 -1
- data/lib/pry-moves/backtrace.rb +13 -6
- data/lib/pry-moves/formatter.rb +1 -0
- data/lib/pry-moves/recursion_tracker.rb +94 -0
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47c7a7529bee28ca664536458891b00f6a1bee574869106686cd2abef9b57adb
|
4
|
+
data.tar.gz: 13d671c5f8ed4005304da6d4201908c0857d19e8ee3fe85631d18cea5c109580
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: addaf61aa995184e49f3b655f1d4fa863fa0554d1fb00f022fce7a9e1d8671595c03056e37754fd394bf9a204e32c91b3005a00fac3287f2803bafb66273e2d6
|
7
|
+
data.tar.gz: 9ba407049732e75c27e8cc87936e25967a30798212098fce844e948e7986912874137088fc87ffc8d9ef48ca09a3c2445da545132109a58ed47d5c4577775db4
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pry-moves (1.0.
|
4
|
+
pry-moves (1.0.1)
|
5
5
|
binding_of_caller (~> 0.7)
|
6
6
|
colorize (~> 0.8)
|
7
7
|
pry (>= 0.10.4, < 0.13)
|
@@ -13,7 +13,7 @@ GEM
|
|
13
13
|
debug_inspector (>= 0.0.1)
|
14
14
|
coderay (1.1.2)
|
15
15
|
colorize (0.8.1)
|
16
|
-
debug_inspector (
|
16
|
+
debug_inspector (1.1.0)
|
17
17
|
diff-lcs (1.3)
|
18
18
|
method_source (0.9.0)
|
19
19
|
pry (0.11.3)
|
data/lib/pry-moves/add_suffix.rb
CHANGED
data/lib/pry-moves/backtrace.rb
CHANGED
@@ -2,10 +2,12 @@ require 'fileutils'
|
|
2
2
|
|
3
3
|
class PryMoves::Backtrace
|
4
4
|
|
5
|
+
FILTERS = %w[/gems/ /rubygems/ /bin/ /lib/ruby/]
|
6
|
+
|
5
7
|
class << self
|
6
8
|
|
7
9
|
def filter
|
8
|
-
@filter
|
10
|
+
@filter ||= Regexp.new FILTERS.join("|")
|
9
11
|
end
|
10
12
|
def filter=(f); @filter = f; end
|
11
13
|
|
@@ -49,11 +51,13 @@ class PryMoves::Backtrace
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def build
|
52
|
-
show_vapid = %w(+ a all hidden vapid).include?(@filter)
|
53
54
|
show_all = %w(a all).include?(@filter)
|
55
|
+
show_vapid = %w(+ hidden vapid).include?(@filter) || show_all
|
54
56
|
result = []
|
55
57
|
current_object, vapid_count = nil, 0
|
56
58
|
|
59
|
+
recursion = PryMoves::Recursion::Holder.new
|
60
|
+
|
57
61
|
frame_manager.bindings.each_with_details do |binding, vapid|
|
58
62
|
next if !show_all and binding.eval('__FILE__').match self.class::filter
|
59
63
|
|
@@ -74,16 +78,20 @@ class PryMoves::Backtrace
|
|
74
78
|
current_object = obj
|
75
79
|
end
|
76
80
|
|
77
|
-
|
81
|
+
file, line = binding.eval('[__FILE__, __LINE__]')
|
82
|
+
recursion.track file, line, result.count, binding.index unless show_vapid
|
83
|
+
result << build_line(binding, file, line)
|
78
84
|
end
|
79
85
|
|
86
|
+
recursion.each { |t| t.apply result }
|
87
|
+
|
80
88
|
result << "👽 frames hidden: #{vapid_count}" if vapid_count > 0
|
81
89
|
|
82
90
|
result
|
83
91
|
end
|
84
92
|
|
85
|
-
def build_line(binding)
|
86
|
-
file = @formatter.shorten_path "#{
|
93
|
+
def build_line(binding, file, line)
|
94
|
+
file = @formatter.shorten_path "#{file}"
|
87
95
|
|
88
96
|
signature = @formatter.method_signature binding
|
89
97
|
signature = ":#{binding.frame_type}" if !signature or signature.length < 1
|
@@ -97,7 +105,6 @@ class PryMoves::Backtrace
|
|
97
105
|
' '
|
98
106
|
end
|
99
107
|
|
100
|
-
line = binding.eval('__LINE__')
|
101
108
|
"#{indent}#{file}:#{line} #{signature}"
|
102
109
|
end
|
103
110
|
|
data/lib/pry-moves/formatter.rb
CHANGED
@@ -0,0 +1,94 @@
|
|
1
|
+
module PryMoves::Recursion
|
2
|
+
|
3
|
+
class Tracker
|
4
|
+
|
5
|
+
attr_reader :loops
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@history = []
|
9
|
+
@loops = 0
|
10
|
+
@missing = 0
|
11
|
+
@currently_missing = []
|
12
|
+
@missing_lines = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def track file, line_num, bt_index, binding_index
|
16
|
+
line = "#{file}:#{line_num}"
|
17
|
+
if @last_index
|
18
|
+
check_recursion line, bt_index, binding_index
|
19
|
+
elsif (prev_index = @history.rindex line)
|
20
|
+
@loops += 1
|
21
|
+
@last_index = prev_index
|
22
|
+
@recursion_size = 1
|
23
|
+
else
|
24
|
+
@history << line
|
25
|
+
@last_index = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
@repetitions_start ||= bt_index if @loops == 2
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_recursion line, bt_index, binding_index
|
32
|
+
prev_index = @history.rindex line
|
33
|
+
if prev_index == @last_index
|
34
|
+
@loops += 1
|
35
|
+
@missing = 0
|
36
|
+
@recursion_size = 0
|
37
|
+
@missing_lines.concat @currently_missing
|
38
|
+
@repetitions_end = bt_index
|
39
|
+
elsif prev_index && prev_index > @last_index
|
40
|
+
@last_index = prev_index + 1
|
41
|
+
@recursion_size += 1
|
42
|
+
# todo: finish tracking and debug multi-line recursions
|
43
|
+
elsif @missing <= @recursion_size
|
44
|
+
@missing += 1
|
45
|
+
@currently_missing << binding_index
|
46
|
+
false
|
47
|
+
else
|
48
|
+
# @missing_lines = nil
|
49
|
+
# @last_index = nil
|
50
|
+
@is_finished = true
|
51
|
+
false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def finished?
|
56
|
+
@is_finished
|
57
|
+
end
|
58
|
+
|
59
|
+
def good?
|
60
|
+
@repetitions_start and @repetitions_end
|
61
|
+
end
|
62
|
+
|
63
|
+
def apply result
|
64
|
+
label = "♻️ recursion with #{@loops} loops"
|
65
|
+
label += " Ⓜ️ #{@missing} missing lines #{@missing_lines}" if @missing_lines.present?
|
66
|
+
label = "...(#{label})..."
|
67
|
+
# puts "#{@repetitions_start}..#{@repetitions_end}"
|
68
|
+
result[@repetitions_start..@repetitions_end] = [label]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
class Holder < Array
|
74
|
+
|
75
|
+
def initialize(*args)
|
76
|
+
super
|
77
|
+
new_tracker
|
78
|
+
end
|
79
|
+
|
80
|
+
def new_tracker
|
81
|
+
@tracker = Tracker.new
|
82
|
+
end
|
83
|
+
|
84
|
+
def track *args
|
85
|
+
@tracker.track *args
|
86
|
+
if @tracker.finished?
|
87
|
+
self << @tracker if @tracker.good?
|
88
|
+
new_tracker
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
data/lib/pry-moves/version.rb
CHANGED
data/lib/pry-moves.rb
CHANGED
@@ -11,6 +11,7 @@ require 'pry-moves/backtrace'
|
|
11
11
|
require 'pry-moves/watch'
|
12
12
|
require 'pry-moves/painter'
|
13
13
|
require 'pry-moves/restartable'
|
14
|
+
require 'pry-moves/recursion_tracker'
|
14
15
|
|
15
16
|
require 'commands/traced_method'
|
16
17
|
require 'commands/trace_helpers'
|
@@ -48,8 +49,8 @@ module PryMoves
|
|
48
49
|
pry_moves_stack_root = true
|
49
50
|
PryMoves.re_execution
|
50
51
|
if PryMoves.stop_on_breakpoints
|
52
|
+
self.debug_called_times += 1
|
51
53
|
if at
|
52
|
-
self.debug_called_times += 1
|
53
54
|
return unless self.debug_called_times == at
|
54
55
|
end
|
55
56
|
PryMoves.messages << message if message
|
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: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- garmoshka-mo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/pry-moves/pry_ext.rb
|
109
109
|
- lib/pry-moves/pry_remote_ext.rb
|
110
110
|
- lib/pry-moves/pry_wrapper.rb
|
111
|
+
- lib/pry-moves/recursion_tracker.rb
|
111
112
|
- lib/pry-moves/restartable.rb
|
112
113
|
- lib/pry-moves/version.rb
|
113
114
|
- lib/pry-moves/watch.rb
|