im-lost 1.0.1 → 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/README.md +56 -39
- data/examples/foo.rb +42 -25
- data/lib/im-lost/version.rb +1 -1
- data/lib/im-lost.rb +21 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b3508c022462842507ce749828e2c74c4db9e9097496e68cedc758018017cb5
|
4
|
+
data.tar.gz: 93ac54d98ae6474d4f7144b116cf0e2784c88babf57ff592a317b463caa7ee13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d45f27c98a6ed477ce4e696f4c41286ca24c105de1668889bf64fc0d57d3947e04c026b40fa7f5f79e2ce5016fcc8327e3c9a8b20a1e6ae0561900efae4f5f3
|
7
|
+
data.tar.gz: 1502147a826924c39988f9272d62e3c0274dc8cdb961f25c405a229cf6273142579ad136af1972c06874d13af110486b79db45907c219bd3082a91cd507220ab
|
data/README.md
CHANGED
@@ -20,14 +20,14 @@ File.open('test.txt', 'w') do |file|
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
# output will look like
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
23
|
+
# > IO#<<(?)
|
24
|
+
# /projects/test.rb:1
|
25
|
+
# > IO#write(*)
|
26
|
+
# /projects/test.rb:1
|
27
|
+
# > IO#puts(*)
|
28
|
+
# /projects/test.rb:2
|
29
|
+
# > IO#write(*)
|
30
|
+
# /projects/test.rb:2
|
31
31
|
```
|
32
32
|
|
33
33
|
When you need to know if exceptions are raised and handled you can use `ImLost.trace_exceptions`:
|
@@ -39,12 +39,12 @@ rescue SystemCallError
|
|
39
39
|
raise('something went wrong!')
|
40
40
|
end
|
41
41
|
# output will look like
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
42
|
+
# x Errno::EEXIST: File exists @ rb_sysopen - /
|
43
|
+
# /projects/test.rb:2
|
44
|
+
# ! Errno::EEXIST: File exists @ rb_sysopen - /
|
45
|
+
# /projects/test.rb:3
|
46
|
+
# x RuntimeError: something went wrong!
|
47
|
+
# /projects/test.rb:4
|
48
48
|
```
|
49
49
|
|
50
50
|
When you like to know if and when a code point is reached, `ImLost.here` will help:
|
@@ -108,31 +108,48 @@ my_foo.foo(3) { puts _1 }
|
|
108
108
|
ImLost.vars(my_foo)
|
109
109
|
|
110
110
|
# output will look like
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
118
|
-
#
|
119
|
-
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
124
|
-
#
|
125
|
-
#
|
126
|
-
#
|
127
|
-
#
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
111
|
+
# > Foo.create(:foo!)
|
112
|
+
# /projects/foo.rb:25
|
113
|
+
# > Foo.new(*)
|
114
|
+
# /projects/foo.rb:6
|
115
|
+
# < Foo.new(*)
|
116
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
117
|
+
# < Foo.create(:foo!)
|
118
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
119
|
+
# > Foo#foo(1, *[], :none, **{}, &nil)
|
120
|
+
# /projects/foo.rb:28
|
121
|
+
# > Foo#bar()
|
122
|
+
# /projects/foo.rb:15
|
123
|
+
# < Foo#bar()
|
124
|
+
# = :bar
|
125
|
+
# < Foo#foo(1, *[], :none, **{}, &nil)
|
126
|
+
# = "1-none-[]-{}-bar"
|
127
|
+
# = /projects/foo.rb:29
|
128
|
+
# instance variables:
|
129
|
+
# @value: "1-none-[]-{}-bar"
|
130
|
+
# > Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
131
|
+
# /projects/foo.rb:31
|
132
|
+
# > Foo#bar()
|
133
|
+
# /projects/foo.rb:15
|
134
|
+
# < Foo#bar()
|
135
|
+
# = :bar
|
136
|
+
# < Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
137
|
+
# = "2-some-[a,b,c]-{:name=>:value}-bar"
|
138
|
+
# = /projects/foo.rb:32
|
139
|
+
# instance variables:
|
140
|
+
# @value: "2-some-[a,b,c]-{:name=>:value}-bar"
|
141
|
+
# > Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
142
|
+
# /projects/foo.rb:34
|
143
|
+
# > Foo#bar()
|
144
|
+
# /projects/foo.rb:15
|
145
|
+
# < Foo#bar()
|
146
|
+
# = :bar
|
147
|
+
# 3--[]-{}-bar
|
148
|
+
# < Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
149
|
+
# = nil
|
150
|
+
# = /projects/foo.rb:35
|
151
|
+
# instance variables:
|
152
|
+
# @value: "3--[]-{}-bar"
|
136
153
|
```
|
137
154
|
|
138
155
|
See [examples dir](./examples) for more…
|
data/examples/foo.rb
CHANGED
@@ -35,28 +35,45 @@ my_foo.foo(3) { puts _1 }
|
|
35
35
|
ImLost.vars(my_foo)
|
36
36
|
|
37
37
|
# output will look like
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
#
|
50
|
-
#
|
51
|
-
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
#
|
60
|
-
#
|
61
|
-
#
|
62
|
-
#
|
38
|
+
# > Foo.create(:foo!)
|
39
|
+
# /projects/foo.rb:25
|
40
|
+
# > Foo.new(*)
|
41
|
+
# /projects/foo.rb:6
|
42
|
+
# < Foo.new(*)
|
43
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
44
|
+
# < Foo.create(:foo!)
|
45
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
46
|
+
# > Foo#foo(1, *[], :none, **{}, &nil)
|
47
|
+
# /projects/foo.rb:28
|
48
|
+
# > Foo#bar()
|
49
|
+
# /projects/foo.rb:15
|
50
|
+
# < Foo#bar()
|
51
|
+
# = :bar
|
52
|
+
# < Foo#foo(1, *[], :none, **{}, &nil)
|
53
|
+
# = "1-none-[]-{}-bar"
|
54
|
+
# = /projects/foo.rb:29
|
55
|
+
# instance variables:
|
56
|
+
# @value: "1-none-[]-{}-bar"
|
57
|
+
# > Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
58
|
+
# /projects/foo.rb:31
|
59
|
+
# > Foo#bar()
|
60
|
+
# /projects/foo.rb:15
|
61
|
+
# < Foo#bar()
|
62
|
+
# = :bar
|
63
|
+
# < Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
64
|
+
# = "2-some-[a,b,c]-{:name=>:value}-bar"
|
65
|
+
# = /projects/foo.rb:32
|
66
|
+
# instance variables:
|
67
|
+
# @value: "2-some-[a,b,c]-{:name=>:value}-bar"
|
68
|
+
# > Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
69
|
+
# /projects/foo.rb:34
|
70
|
+
# > Foo#bar()
|
71
|
+
# /projects/foo.rb:15
|
72
|
+
# < Foo#bar()
|
73
|
+
# = :bar
|
74
|
+
# 3--[]-{}-bar
|
75
|
+
# < Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
76
|
+
# = nil
|
77
|
+
# = /projects/foo.rb:35
|
78
|
+
# instance variables:
|
79
|
+
# @value: "3--[]-{}-bar"
|
data/lib/im-lost/version.rb
CHANGED
data/lib/im-lost.rb
CHANGED
@@ -254,7 +254,7 @@ module ImLost
|
|
254
254
|
return unless object.respond_to?(:instance_variables)
|
255
255
|
_vars(object, Kernel.caller_locations(1, 1)[0])
|
256
256
|
ensure
|
257
|
-
@trace[traced] =
|
257
|
+
@trace[traced] = traced if traced
|
258
258
|
end
|
259
259
|
|
260
260
|
protected
|
@@ -272,30 +272,35 @@ module ImLost
|
|
272
272
|
private
|
273
273
|
|
274
274
|
def _trace(arg)
|
275
|
-
|
275
|
+
id = arg.__id__
|
276
|
+
@trace[id] = id if __id__ != id && @output.__id__ != id
|
276
277
|
arg
|
277
278
|
end
|
278
279
|
|
279
280
|
def _trace_all(args)
|
280
281
|
args.each do |arg|
|
281
|
-
|
282
|
+
arg = arg.__id__
|
283
|
+
@trace[arg] = arg if __id__ != arg && @output.__id__ != arg
|
282
284
|
end
|
283
285
|
args
|
284
286
|
end
|
285
287
|
|
286
288
|
def _trace_b(arg)
|
287
|
-
|
288
|
-
yield(arg)
|
289
|
-
|
290
|
-
|
289
|
+
id = arg.__id__
|
290
|
+
return yield(arg) if __id__ == id || @output.__id__ == id
|
291
|
+
begin
|
292
|
+
@trace[id] = id
|
293
|
+
yield(arg)
|
294
|
+
ensure
|
295
|
+
@trace.delete(id) if id
|
296
|
+
end
|
291
297
|
end
|
292
298
|
|
293
299
|
def _trace_all_b(args)
|
294
300
|
ids =
|
295
301
|
args.filter_map do |arg|
|
296
|
-
|
297
|
-
@trace[
|
298
|
-
id
|
302
|
+
arg = arg.__id__
|
303
|
+
@trace[arg] = arg if __id__ != arg && @output.__id__ != arg
|
299
304
|
end
|
300
305
|
yield(args)
|
301
306
|
ensure
|
@@ -332,9 +337,8 @@ module ImLost
|
|
332
337
|
end
|
333
338
|
|
334
339
|
ARG_SIG = { rest: '*', keyrest: '**', block: '&' }.compare_by_identity.freeze
|
335
|
-
NO_NAME =
|
336
|
-
|
337
|
-
private_constant :ARG_SIG, :NO_NAME, :EX_PREFIX
|
340
|
+
NO_NAME = { :* => 1, :** => 1, :& => 1 }.compare_by_identity.freeze
|
341
|
+
private_constant :ARG_SIG, :NO_NAME
|
338
342
|
|
339
343
|
@trace = {}.compare_by_identity
|
340
344
|
@caller_locations = true
|
@@ -354,7 +358,7 @@ module ImLost
|
|
354
358
|
'>',
|
355
359
|
tp,
|
356
360
|
tp.parameters.map do |kind, name|
|
357
|
-
next name if NO_NAME.
|
361
|
+
next name if NO_NAME.key?(name)
|
358
362
|
"#{ARG_SIG[kind]}#{ctx.local_variable_get(name).inspect}"
|
359
363
|
end
|
360
364
|
)
|
@@ -392,7 +396,9 @@ module ImLost
|
|
392
396
|
@trace_exceptions =
|
393
397
|
TracePoint.new(*supported) do |tp|
|
394
398
|
ex = tp.raised_exception.inspect
|
395
|
-
@output.puts(
|
399
|
+
@output.puts(
|
400
|
+
"#{tp.event == :raise ? 'x' : '!'} #{ex[0] == '#' ? ex[2..-2] : ex}"
|
401
|
+
)
|
396
402
|
@output.puts(" #{tp.path}:#{tp.lineno}") if @exception_locations
|
397
403
|
end
|
398
404
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: im-lost
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Blumtritt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-05-
|
11
|
+
date: 2024-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
If you have overlooked something again and don't really understand what
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
- !ruby/object:Gem::Version
|
57
57
|
version: '0'
|
58
58
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
59
|
+
rubygems_version: 3.5.10
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Your debugging helper.
|