tracia 0.2.6 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tracia/frame.rb +0 -9
- data/lib/tracia/gem_paths.rb +1 -3
- data/lib/tracia/version.rb +1 -1
- data/lib/tracia.rb +28 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac587bcc0c01258f1220731adda063b6c83a7f66e87fe51da334286e7f629c7a
|
4
|
+
data.tar.gz: 972cfa5242cb2570aa6e9614fc30fa43937cf8c23390af260c0685b57573d094
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7631de3f1aaa6cae27892e120ba4eadb9318c04f4461c8697141278642d4fd18253fc8b11abb26408a306d683c0e71f8c356f03dd8c862273fdbaf4a2c6ac36
|
7
|
+
data.tar.gz: 6410a901a160249b4dab2eebe147f7a517e2ffc5da81a99d097e12d031a59e631a3b5c4ec44dfbb6566cc34d416768725cf1dd7aa09db7713e7c72719f1a7e67
|
data/lib/tracia/frame.rb
CHANGED
@@ -50,16 +50,7 @@ class Tracia
|
|
50
50
|
"#{klass}#{call_sym}#{method_name}"
|
51
51
|
end
|
52
52
|
|
53
|
-
INSTANCE_METHOD_SHARP = '#'
|
54
|
-
|
55
53
|
def source_location
|
56
|
-
if @file == nil
|
57
|
-
meth = call_sym == INSTANCE_METHOD_SHARP ? klass.instance_method(method_name) : klass.method(method_name)
|
58
|
-
src_loc = meth.source_location
|
59
|
-
@file = src_loc[0]
|
60
|
-
@lineno = src_loc[1]
|
61
|
-
end
|
62
|
-
|
63
54
|
"#{GemPaths.shorten(@file)}:#{@lineno}"
|
64
55
|
end
|
65
56
|
end
|
data/lib/tracia/gem_paths.rb
CHANGED
@@ -4,9 +4,7 @@ class Tracia
|
|
4
4
|
module GemPaths
|
5
5
|
ABSTRACTS = {}
|
6
6
|
|
7
|
-
::
|
8
|
-
.detect{ |hash| hash.has_key?('GEM PATHS') }['GEM PATHS']
|
9
|
-
.each_with_index { |path, i| ABSTRACTS["GemPath#{i}"] = path }
|
7
|
+
::Gem.path.each_with_index { |path, i| ABSTRACTS["GemPath#{i}"] = path }
|
10
8
|
|
11
9
|
class << self
|
12
10
|
def shorten(location)
|
data/lib/tracia/version.rb
CHANGED
data/lib/tracia.rb
CHANGED
@@ -10,6 +10,8 @@ require "binding_of_callers"
|
|
10
10
|
class Tracia
|
11
11
|
class Error < StandardError; end
|
12
12
|
|
13
|
+
INSTANCE_METHOD_SHARP = '#'
|
14
|
+
|
13
15
|
attr_accessor :level, :error, :depth
|
14
16
|
|
15
17
|
class << self
|
@@ -88,13 +90,33 @@ class Tracia
|
|
88
90
|
|
89
91
|
root = @stack[0]
|
90
92
|
if root
|
91
|
-
|
93
|
+
eliminate_tail_recursion!([root]) if @non_tail_recursion
|
92
94
|
@logger.call(root)
|
93
95
|
end
|
94
96
|
end
|
95
97
|
|
96
98
|
private
|
97
99
|
|
100
|
+
def eliminate_tail_recursion!(stack)
|
101
|
+
@specific_recursion =
|
102
|
+
case @non_tail_recursion
|
103
|
+
when true
|
104
|
+
-> (_) { true }
|
105
|
+
else
|
106
|
+
target_recursions = Array === @non_tail_recursion ? @non_tail_recursion : [@non_tail_recursion]
|
107
|
+
target_recursions.map!{ |h| Frame.new(h[:klass], h[:call_sym], h[:method_name], nil, nil) }
|
108
|
+
-> (current) do
|
109
|
+
target_recursions.any? do |tr|
|
110
|
+
current.klass == tr.klass &&
|
111
|
+
current.call_sym == tr.call_sym &&
|
112
|
+
current.method_name == tr.method_name
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
non_tail_recursion!(stack)
|
118
|
+
end
|
119
|
+
|
98
120
|
def non_tail_recursion!(stack)
|
99
121
|
current_frame = stack.last
|
100
122
|
last_idx = current_frame.children.count - 1
|
@@ -103,7 +125,9 @@ class Tracia
|
|
103
125
|
next unless Frame === child
|
104
126
|
next non_tail_recursion!([child]) if last_idx != idx
|
105
127
|
|
106
|
-
|
128
|
+
# pp (stack + [child]).map{|f| "#{f.send(:class_and_method)}:#{f.object_id}" }
|
129
|
+
|
130
|
+
recursion_idx = @specific_recursion[child] && stack.rindex{ |frame| frame.same_klass_and_method?(child) }
|
107
131
|
if recursion_idx
|
108
132
|
parent = stack[recursion_idx - 1]
|
109
133
|
parent.children << child
|
@@ -140,8 +164,6 @@ class Tracia
|
|
140
164
|
@frames_to_reject.any?{ |rj| rj =~ raw_frame.file }
|
141
165
|
end
|
142
166
|
|
143
|
-
EMPTY_SRC_LOC = []
|
144
|
-
|
145
167
|
def convert_to_frames(callers)
|
146
168
|
callers.map! do |c|
|
147
169
|
_binding = c._binding
|
@@ -151,9 +173,8 @@ class Tracia
|
|
151
173
|
|
152
174
|
source_location =
|
153
175
|
if _binding.frame_type == :method
|
154
|
-
|
155
|
-
|
156
|
-
EMPTY_SRC_LOC
|
176
|
+
meth = call_symbol == INSTANCE_METHOD_SHARP ? klass.instance_method(frame_env) : klass.method(frame_env)
|
177
|
+
meth.source_location
|
157
178
|
else
|
158
179
|
_binding.source_location
|
159
180
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tracia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.9
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.9
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: binding_of_callers
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|