im-lost 1.0.1 → 1.1.0
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 +59 -40
- data/examples/foo.rb +43 -26
- data/examples/timer.rb +29 -0
- data/lib/im-lost/version.rb +1 -1
- data/lib/im-lost.rb +195 -40
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be7b612cd1d68529fbba18b5a9a4759e60111facc52e99a20b4da140e887f8c4
|
4
|
+
data.tar.gz: c1aeff67c05a2e31c0dab72c6c5ed84bb27f9231e759de874882a082f0fac284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9821d580f5c5e4e62133dba01fbdd9a26ec3cfd8ffe8ed6603b24760d5073184bd22bdbc6ab95317c6a39690abc56ad4e2e5afdd5df4e3d261525afc927448eb
|
7
|
+
data.tar.gz: b12a64d4ee2b7e9f1764c5bcb0e79a5f9b240b9b49359c10868abc2f763cefb8ea4a7844c0ba17239346157f516b10a6fc8d368386206cb0fea0c6cc330a7601
|
data/README.md
CHANGED
@@ -19,15 +19,16 @@ File.open('test.txt', 'w') do |file|
|
|
19
19
|
file.puts(:world!)
|
20
20
|
end
|
21
21
|
end
|
22
|
+
|
22
23
|
# output will look like
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
24
|
+
# > IO#<<(?)
|
25
|
+
# /projects/test.rb:1
|
26
|
+
# > IO#write(*)
|
27
|
+
# /projects/test.rb:1
|
28
|
+
# > IO#puts(*)
|
29
|
+
# /projects/test.rb:2
|
30
|
+
# > IO#write(*)
|
31
|
+
# /projects/test.rb:2
|
31
32
|
```
|
32
33
|
|
33
34
|
When you need to know if exceptions are raised and handled you can use `ImLost.trace_exceptions`:
|
@@ -38,16 +39,17 @@ ImLost.trace_exceptions do
|
|
38
39
|
rescue SystemCallError
|
39
40
|
raise('something went wrong!')
|
40
41
|
end
|
42
|
+
|
41
43
|
# output will look like
|
42
|
-
#
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
44
|
+
# x Errno::EEXIST: File exists @ rb_sysopen - /
|
45
|
+
# /projects/test.rb:2
|
46
|
+
# ! Errno::EEXIST: File exists @ rb_sysopen - /
|
47
|
+
# /projects/test.rb:3
|
48
|
+
# x RuntimeError: something went wrong!
|
49
|
+
# /projects/test.rb:4
|
48
50
|
```
|
49
51
|
|
50
|
-
When you like to know if
|
52
|
+
When you like to know if a code point is reached, `ImLost.here` will help:
|
51
53
|
|
52
54
|
```ruby
|
53
55
|
ImLost.here
|
@@ -108,31 +110,48 @@ my_foo.foo(3) { puts _1 }
|
|
108
110
|
ImLost.vars(my_foo)
|
109
111
|
|
110
112
|
# 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
|
-
#
|
113
|
+
# > Foo.create(:foo!)
|
114
|
+
# /projects/foo.rb:25
|
115
|
+
# > Foo.new(*)
|
116
|
+
# /projects/foo.rb:6
|
117
|
+
# < Foo.new(*)
|
118
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
119
|
+
# < Foo.create(:foo!)
|
120
|
+
# = #<Foo:0x00000001030810c0 @value=:foo!>
|
121
|
+
# > Foo#foo(1, *[], :none, **{}, &nil)
|
122
|
+
# /projects/foo.rb:28
|
123
|
+
# > Foo#bar()
|
124
|
+
# /projects/foo.rb:15
|
125
|
+
# < Foo#bar()
|
126
|
+
# = :bar
|
127
|
+
# < Foo#foo(1, *[], :none, **{}, &nil)
|
128
|
+
# = "1-none-[]-{}-bar"
|
129
|
+
# = /projects/foo.rb:29
|
130
|
+
# instance variables:
|
131
|
+
# @value: "1-none-[]-{}-bar"
|
132
|
+
# > Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
133
|
+
# /projects/foo.rb:31
|
134
|
+
# > Foo#bar()
|
135
|
+
# /projects/foo.rb:15
|
136
|
+
# < Foo#bar()
|
137
|
+
# = :bar
|
138
|
+
# < Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
|
139
|
+
# = "2-some-[a,b,c]-{:name=>:value}-bar"
|
140
|
+
# = /projects/foo.rb:32
|
141
|
+
# instance variables:
|
142
|
+
# @value: "2-some-[a,b,c]-{:name=>:value}-bar"
|
143
|
+
# > Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
144
|
+
# /projects/foo.rb:34
|
145
|
+
# > Foo#bar()
|
146
|
+
# /projects/foo.rb:15
|
147
|
+
# < Foo#bar()
|
148
|
+
# = :bar
|
149
|
+
# 3--[]-{}-bar
|
150
|
+
# < Foo#foo(3, *[], nil, **{}, &#<Proc:0x00000001030aee30 /projects/foo.rb:34>)
|
151
|
+
# = nil
|
152
|
+
# = /projects/foo.rb:35
|
153
|
+
# instance variables:
|
154
|
+
# @value: "3--[]-{}-bar"
|
136
155
|
```
|
137
156
|
|
138
157
|
See [examples dir](./examples) for more…
|
data/examples/foo.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
require 'im-lost'
|
4
4
|
|
5
5
|
class Foo
|
6
6
|
def self.create(value:) = new(value)
|
@@ -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/examples/timer.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
puts <<~INFO
|
4
|
+
|
5
|
+
This is an example how to use named and anonymous timers.
|
6
|
+
|
7
|
+
INFO
|
8
|
+
|
9
|
+
require_relative '../lib/im-lost'
|
10
|
+
|
11
|
+
puts 'Create a named timer:'
|
12
|
+
ImLost.timer.create(:first)
|
13
|
+
|
14
|
+
puts 'Create an anonymous timer:'
|
15
|
+
second = ImLost.timer.create
|
16
|
+
|
17
|
+
sleep(0.5) # or whatever
|
18
|
+
|
19
|
+
puts 'print runtime for named timer:'
|
20
|
+
ImLost.timer[:first]
|
21
|
+
|
22
|
+
puts 'print runtime for anonymous timer:'
|
23
|
+
ImLost.timer[second]
|
24
|
+
|
25
|
+
puts 'delete a named timer'
|
26
|
+
ImLost.timer.delete(:first)
|
27
|
+
|
28
|
+
puts 'delete an anonymous timer'
|
29
|
+
ImLost.timer.delete(second)
|
data/lib/im-lost/version.rb
CHANGED
data/lib/im-lost.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
#
|
3
4
|
# If you have overlooked something again and don't really understand what your
|
4
5
|
# code is doing. If you have to maintain this application but can't really find
|
5
6
|
# your way around and certainly can't track down that stupid error. If you feel
|
@@ -53,6 +54,12 @@ module ImLost
|
|
53
54
|
raise(ArgumentError, "invalid output device - #{value.inspect}")
|
54
55
|
end
|
55
56
|
|
57
|
+
#
|
58
|
+
# @return [TimerStore] the timer store used to estimate the runtime of
|
59
|
+
# your code
|
60
|
+
#
|
61
|
+
attr_reader :timer
|
62
|
+
|
56
63
|
#
|
57
64
|
# Enables/disables tracing of method calls.
|
58
65
|
# This is enabled by default.
|
@@ -79,6 +86,7 @@ module ImLost
|
|
79
86
|
# rescue SystemCallError
|
80
87
|
# raise('something went wrong!')
|
81
88
|
# end
|
89
|
+
#
|
82
90
|
# # output will look like
|
83
91
|
# # x Errno::EEXIST: File exists @ rb_sysopen - /
|
84
92
|
# # /projects/test.rb:2
|
@@ -170,15 +178,16 @@ module ImLost
|
|
170
178
|
# file.puts(:world!)
|
171
179
|
# end
|
172
180
|
# end
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
177
|
-
#
|
178
|
-
#
|
179
|
-
#
|
180
|
-
#
|
181
|
-
#
|
181
|
+
#
|
182
|
+
# # output will look like
|
183
|
+
# # > IO#<<(?)
|
184
|
+
# # /projects/test.rb:1
|
185
|
+
# # > IO#write(*)
|
186
|
+
# # /projects/test.rb:1
|
187
|
+
# # > IO#puts(*)
|
188
|
+
# # /projects/test.rb:2
|
189
|
+
# # > IO#write(*)
|
190
|
+
# # /projects/test.rb:2
|
182
191
|
#
|
183
192
|
# @overload trace(*args)
|
184
193
|
# @param args [[Object]] one or more objects to be traced
|
@@ -187,7 +196,6 @@ module ImLost
|
|
187
196
|
# @see untrace
|
188
197
|
# @see untrace_all!
|
189
198
|
#
|
190
|
-
#
|
191
199
|
# @overload trace(*args)
|
192
200
|
# @param args [[Object]] one or more objects to be traced
|
193
201
|
# @yieldparam args [Object] the traced object(s)
|
@@ -254,10 +262,10 @@ module ImLost
|
|
254
262
|
return unless object.respond_to?(:instance_variables)
|
255
263
|
_vars(object, Kernel.caller_locations(1, 1)[0])
|
256
264
|
ensure
|
257
|
-
@trace[traced] =
|
265
|
+
@trace[traced] = traced if traced
|
258
266
|
end
|
259
267
|
|
260
|
-
|
268
|
+
private
|
261
269
|
|
262
270
|
def as_sig(prefix, info, args)
|
263
271
|
args = args.join(', ')
|
@@ -269,33 +277,36 @@ module ImLost
|
|
269
277
|
end
|
270
278
|
end
|
271
279
|
|
272
|
-
private
|
273
|
-
|
274
280
|
def _trace(arg)
|
275
|
-
|
281
|
+
id = arg.__id__
|
282
|
+
@trace[id] = id if __id__ != id && @output.__id__ != id
|
276
283
|
arg
|
277
284
|
end
|
278
285
|
|
279
286
|
def _trace_all(args)
|
280
287
|
args.each do |arg|
|
281
|
-
|
288
|
+
arg = arg.__id__
|
289
|
+
@trace[arg] = arg if __id__ != arg && @output.__id__ != arg
|
282
290
|
end
|
283
291
|
args
|
284
292
|
end
|
285
293
|
|
286
294
|
def _trace_b(arg)
|
287
|
-
|
288
|
-
yield(arg)
|
289
|
-
|
290
|
-
|
295
|
+
id = arg.__id__
|
296
|
+
return yield(arg) if __id__ == id || @output.__id__ == id
|
297
|
+
begin
|
298
|
+
@trace[id] = id
|
299
|
+
yield(arg)
|
300
|
+
ensure
|
301
|
+
@trace.delete(id) if id
|
302
|
+
end
|
291
303
|
end
|
292
304
|
|
293
305
|
def _trace_all_b(args)
|
294
306
|
ids =
|
295
307
|
args.filter_map do |arg|
|
296
|
-
|
297
|
-
@trace[
|
298
|
-
id
|
308
|
+
arg = arg.__id__
|
309
|
+
@trace[arg] = arg if __id__ != arg && @output.__id__ != arg
|
299
310
|
end
|
300
311
|
yield(args)
|
301
312
|
ensure
|
@@ -307,11 +318,11 @@ module ImLost
|
|
307
318
|
vars = obj.instance_variables
|
308
319
|
if vars.empty?
|
309
320
|
@output.puts(' <no instance variables defined>')
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
321
|
+
return obj
|
322
|
+
end
|
323
|
+
@output.puts(' instance variables:')
|
324
|
+
vars.sort!.each do |name|
|
325
|
+
@output.puts(" #{name}: #{obj.instance_variable_get(name).inspect}")
|
315
326
|
end
|
316
327
|
obj
|
317
328
|
end
|
@@ -321,25 +332,167 @@ module ImLost
|
|
321
332
|
vars = binding.local_variables
|
322
333
|
if vars.empty?
|
323
334
|
@output.puts(' <no local variables>')
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
335
|
+
return self
|
336
|
+
end
|
337
|
+
@output.puts(' local variables:')
|
338
|
+
vars.sort!.each do |name|
|
339
|
+
@output.puts(" #{name}: #{binding.local_variable_get(name).inspect}")
|
329
340
|
end
|
330
341
|
self
|
331
342
|
end
|
332
343
|
end
|
333
344
|
|
345
|
+
#
|
346
|
+
# A store to create and register timers you can use to estimate the runtime of
|
347
|
+
# some code.
|
348
|
+
#
|
349
|
+
# All timers are identified by an unique ID or a name.
|
350
|
+
#
|
351
|
+
# @example Use a named timer
|
352
|
+
# ImLost.timer.create('my_test')
|
353
|
+
#
|
354
|
+
# # ...your code here...
|
355
|
+
#
|
356
|
+
# ImLost.timer['my_test']
|
357
|
+
# # => prints the timer name, this location and runtime so far
|
358
|
+
#
|
359
|
+
# # ...more code here...
|
360
|
+
#
|
361
|
+
# ImLost.timer['my_test']
|
362
|
+
# # => prints the timer name, this location and runtime since the timer was created
|
363
|
+
#
|
364
|
+
# ImLost.timer.delete('my_test')
|
365
|
+
# # the timer with name 'my_test' is not longer valid now
|
366
|
+
#
|
367
|
+
#
|
368
|
+
# @example Use an anonymous timer (identified by ID)
|
369
|
+
# tmr = ImLost.timer.create
|
370
|
+
#
|
371
|
+
# # ...your code here...
|
372
|
+
#
|
373
|
+
# ImLost.timer[tmr]
|
374
|
+
# # => prints the timer ID, this location and runtime so far
|
375
|
+
#
|
376
|
+
# # ...more code here...
|
377
|
+
#
|
378
|
+
# ImLost.timer[tmr]
|
379
|
+
# # => prints the timer ID, this location and runtime since the timer was created
|
380
|
+
#
|
381
|
+
# ImLost.timer.delete(tmr)
|
382
|
+
# # the timer with the ID `tmr` is not longer valid now
|
383
|
+
#
|
384
|
+
# @see ImLost.timer
|
385
|
+
#
|
386
|
+
class TimerStore
|
387
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
388
|
+
# @return [Float] current time
|
389
|
+
def self.now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
390
|
+
else
|
391
|
+
# @return [Float] current time
|
392
|
+
def self.now = ::Time.now
|
393
|
+
end
|
394
|
+
|
395
|
+
# @attribute [r] count
|
396
|
+
# @return [Integer] the number of registered timers
|
397
|
+
def count = ids.size
|
398
|
+
|
399
|
+
# @attribute [r] empty?
|
400
|
+
# @return [Boolean] wheter the timer store is empty or not
|
401
|
+
def empty? = ids.empty?
|
402
|
+
|
403
|
+
# @attribute [r] ids
|
404
|
+
# @return [Array<Integer>] IDs of all registered timers
|
405
|
+
def ids = (@ll.keys.keep_if { _1.is_a?(Integer) })
|
406
|
+
|
407
|
+
#
|
408
|
+
# Create and register a new named or anonymous timer.
|
409
|
+
# It print the ID or name of the created timer and includes the location.
|
410
|
+
#
|
411
|
+
# @param name [#to_s] optional timer name
|
412
|
+
# @return [Integer] timer ID
|
413
|
+
#
|
414
|
+
def create(name = nil)
|
415
|
+
timer = []
|
416
|
+
@ll[id = timer.__id__] = timer
|
417
|
+
name ? @ll[name = name.to_s] = timer : name = id
|
418
|
+
@cb[name, Kernel.caller_locations(1, 1)[0]]
|
419
|
+
timer << name << self.class.now
|
420
|
+
id
|
421
|
+
end
|
422
|
+
|
423
|
+
#
|
424
|
+
# Delete and unregister timers.
|
425
|
+
#
|
426
|
+
# @param id_or_names [Array<Integer, #to_s>] the IDs or the names
|
427
|
+
# @return [nil]
|
428
|
+
#
|
429
|
+
def delete(*id_or_names)
|
430
|
+
id_or_names.flatten.each do |id|
|
431
|
+
if id.is_a?(Integer)
|
432
|
+
del = @ll.delete(id)
|
433
|
+
@ll.delete(del[0]) if del
|
434
|
+
else
|
435
|
+
del = @ll.delete(id.to_s)
|
436
|
+
@ll.delete(del.__id__) if del
|
437
|
+
end
|
438
|
+
end
|
439
|
+
nil
|
440
|
+
end
|
441
|
+
|
442
|
+
#
|
443
|
+
# Print the ID or name and the runtime since timer was created.
|
444
|
+
# It includes the location.
|
445
|
+
#
|
446
|
+
# @param id_or_name [Integer, #to_s] the identifier or the name of the timer
|
447
|
+
# @return [Integer] timer ID
|
448
|
+
# @raise [ArgumentError] when the given id or name is not a registered timer
|
449
|
+
# identifier or name
|
450
|
+
#
|
451
|
+
def [](id_or_name)
|
452
|
+
time = self.class.now
|
453
|
+
timer = @ll[id_or_name.is_a?(Integer) ? id_or_name : id_or_name.to_s]
|
454
|
+
raise(ArgumentError, "not a timer - #{id_or_name.inspect}") unless timer
|
455
|
+
@cb[timer[0], Kernel.caller_locations(1, 1)[0], time - timer[1]]
|
456
|
+
timer.__id__
|
457
|
+
end
|
458
|
+
|
459
|
+
#
|
460
|
+
# Print the ID or name and the runtime of all active timers.
|
461
|
+
# It includes the location.
|
462
|
+
#
|
463
|
+
# @return [nil]
|
464
|
+
#
|
465
|
+
def all
|
466
|
+
now = self.class.now
|
467
|
+
loc = Kernel.caller_locations(1, 1)[0]
|
468
|
+
@ll.values.uniq.reverse_each { |name, start| @cb[name, loc, now - start] }
|
469
|
+
nil
|
470
|
+
end
|
471
|
+
|
472
|
+
# @!visibility private
|
473
|
+
def initialize(&block)
|
474
|
+
@cb = block
|
475
|
+
@ll = {}
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
334
479
|
ARG_SIG = { rest: '*', keyrest: '**', block: '&' }.compare_by_identity.freeze
|
335
|
-
NO_NAME =
|
336
|
-
|
337
|
-
private_constant :ARG_SIG, :NO_NAME, :EX_PREFIX
|
480
|
+
NO_NAME = { :* => 1, :** => 1, :& => 1 }.compare_by_identity.freeze
|
481
|
+
private_constant :ARG_SIG, :NO_NAME
|
338
482
|
|
339
483
|
@trace = {}.compare_by_identity
|
340
484
|
@caller_locations = true
|
341
485
|
@output = $stderr.respond_to?(:puts) ? $stderr : STDERR
|
342
486
|
|
487
|
+
@timer =
|
488
|
+
TimerStore.new do |title, location, time|
|
489
|
+
@output.puts(
|
490
|
+
"T #{title}: #{time ? "#{time} sec." : 'created'}",
|
491
|
+
" #{location.path}:#{location.lineno}"
|
492
|
+
)
|
493
|
+
end
|
494
|
+
TimerStore.private_class_method(:new)
|
495
|
+
|
343
496
|
@trace_calls = [
|
344
497
|
TracePoint.new(:c_call) do |tp|
|
345
498
|
next if !@trace.key?(tp.self.__id__) || tp.path == __FILE__
|
@@ -354,7 +507,7 @@ module ImLost
|
|
354
507
|
'>',
|
355
508
|
tp,
|
356
509
|
tp.parameters.map do |kind, name|
|
357
|
-
next name if NO_NAME.
|
510
|
+
next name if NO_NAME.key?(name)
|
358
511
|
"#{ARG_SIG[kind]}#{ctx.local_variable_get(name).inspect}"
|
359
512
|
end
|
360
513
|
)
|
@@ -379,7 +532,7 @@ module ImLost
|
|
379
532
|
'<',
|
380
533
|
tp,
|
381
534
|
tp.parameters.map do |kind, name|
|
382
|
-
next name if
|
535
|
+
next name if NO_NAME.key?(name)
|
383
536
|
"#{ARG_SIG[kind]}#{ctx.local_variable_get(name).inspect}"
|
384
537
|
end
|
385
538
|
)
|
@@ -388,11 +541,13 @@ module ImLost
|
|
388
541
|
end
|
389
542
|
]
|
390
543
|
|
391
|
-
supported = RUBY_VERSION
|
544
|
+
supported = RUBY_VERSION.to_f < 3.3 ? %i[raise] : %i[raise rescue]
|
392
545
|
@trace_exceptions =
|
393
546
|
TracePoint.new(*supported) do |tp|
|
394
547
|
ex = tp.raised_exception.inspect
|
395
|
-
@output.puts(
|
548
|
+
@output.puts(
|
549
|
+
"#{tp.event == :raise ? 'x' : '!'} #{ex[0] == '#' ? ex[2..-2] : ex}"
|
550
|
+
)
|
396
551
|
@output.puts(" #{tp.path}:#{tp.lineno}") if @exception_locations
|
397
552
|
end
|
398
553
|
|
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.1.0
|
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-29 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
|
@@ -30,6 +30,7 @@ files:
|
|
30
30
|
- README.md
|
31
31
|
- examples/foo.rb
|
32
32
|
- examples/kernel_calls.rb
|
33
|
+
- examples/timer.rb
|
33
34
|
- lib/im-lost.rb
|
34
35
|
- lib/im-lost/version.rb
|
35
36
|
- lib/im_lost.rb
|
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
57
|
- !ruby/object:Gem::Version
|
57
58
|
version: '0'
|
58
59
|
requirements: []
|
59
|
-
rubygems_version: 3.
|
60
|
+
rubygems_version: 3.5.11
|
60
61
|
signing_key:
|
61
62
|
specification_version: 4
|
62
63
|
summary: Your debugging helper.
|