im-lost 1.2.3 → 1.2.4
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 +1 -1
- data/lib/im-lost/version.rb +1 -1
- data/lib/im-lost.rb +38 -16
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 997bc0a130f9ac4aad8b517db8b2e1de8ff8d8720c88b6866105e8948e3ee563
|
|
4
|
+
data.tar.gz: 806757992aa14e484919b319c56f3fa694c4c52973b6b32cf925234ea145359c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 14ff2167f66b94d8ffc165dd973a0ca848c7f32818cfe521e2cc82e1a2c0a285e909ceadf6fbeee3c18947d3163264c0faa0d830522bbd81c7ae5fa5a55fc816
|
|
7
|
+
data.tar.gz: c06a25f0310464f1a9ce19ba137a3f6fc5cf644c6c0ac7d9ef421077f3dbb07658014503b411492caa6477cafbc57296ae6eab990aab837db4d009ed2ac4e02f
|
data/README.md
CHANGED
|
@@ -6,7 +6,7 @@ ImLost helps you by analyzing function calls of objects, informing you about exc
|
|
|
6
6
|
|
|
7
7
|
- Gem: [rubygems.org](https://rubygems.org/gems/im-lost)
|
|
8
8
|
- Source: [codeberg.org](https://codeberg.org/mblumtritt/im-lost)
|
|
9
|
-
- Help: [rubydoc.info](https://rubydoc.info/gems/im-lost)
|
|
9
|
+
- Help: [rubydoc.info](https://rubydoc.info/gems/im-lost/ImLost)
|
|
10
10
|
|
|
11
11
|
## Description
|
|
12
12
|
|
data/lib/im-lost/version.rb
CHANGED
data/lib/im-lost.rb
CHANGED
|
@@ -46,7 +46,7 @@ module ImLost
|
|
|
46
46
|
# ImLost.output = original
|
|
47
47
|
# end
|
|
48
48
|
#
|
|
49
|
-
# @return [
|
|
49
|
+
# @return [#<<] the output device
|
|
50
50
|
#
|
|
51
51
|
attr_reader :output
|
|
52
52
|
|
|
@@ -61,8 +61,8 @@ module ImLost
|
|
|
61
61
|
end
|
|
62
62
|
|
|
63
63
|
#
|
|
64
|
-
# @return [TimerStore]
|
|
65
|
-
# your code
|
|
64
|
+
# @return [TimerStore]
|
|
65
|
+
# the timer store used to estimate the runtime of your code
|
|
66
66
|
#
|
|
67
67
|
attr_reader :timer
|
|
68
68
|
|
|
@@ -101,8 +101,9 @@ module ImLost
|
|
|
101
101
|
# # x RuntimeError: something went wrong!
|
|
102
102
|
# # /examples/test.rb:4
|
|
103
103
|
#
|
|
104
|
-
# @param with_locations [Boolean]
|
|
105
|
-
# into the exception trace
|
|
104
|
+
# @param with_locations [Boolean]
|
|
105
|
+
# whether the locations should be included into the exception trace
|
|
106
|
+
# information
|
|
106
107
|
# @yieldreturn [Object] return result
|
|
107
108
|
#
|
|
108
109
|
def trace_exceptions(with_locations: true)
|
|
@@ -235,8 +236,8 @@ module ImLost
|
|
|
235
236
|
#
|
|
236
237
|
# @see trace
|
|
237
238
|
#
|
|
238
|
-
# @param args [[]Object]]
|
|
239
|
-
# traced
|
|
239
|
+
# @param args [[]Object]]
|
|
240
|
+
# one or more objects which should not longer be traced
|
|
240
241
|
# @return [Array<Object>] the object(s) which are not longer be traced
|
|
241
242
|
# @return [nil] when none of the objects was traced before
|
|
242
243
|
#
|
|
@@ -319,17 +320,38 @@ module ImLost
|
|
|
319
320
|
@output << out
|
|
320
321
|
end
|
|
321
322
|
|
|
323
|
+
#
|
|
324
|
+
# Measure runtime of given block.
|
|
325
|
+
#
|
|
326
|
+
# @param title [#to_s] optional title to display
|
|
327
|
+
# @return [Object] the block's result
|
|
328
|
+
#
|
|
329
|
+
def time(title = nil, &block)
|
|
330
|
+
title &&= "#{title} "
|
|
331
|
+
if @caller_locations
|
|
332
|
+
loc = Kernel.caller_locations(1, 1)[0]
|
|
333
|
+
suffix = " #{loc.path}:#{loc.lineno}\n"
|
|
334
|
+
end
|
|
335
|
+
unless block_given?
|
|
336
|
+
@output << "t #{title}#{TimerStore.now}\n#{suffix}"
|
|
337
|
+
return
|
|
338
|
+
end
|
|
339
|
+
t = TimerStore.now
|
|
340
|
+
begin
|
|
341
|
+
yield
|
|
342
|
+
ensure
|
|
343
|
+
t = (TimerStore.now - t).round(4)
|
|
344
|
+
@output << "R #{title}#{t} sec.\n#{suffix} #{block.inspect}\n"
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
322
348
|
private
|
|
323
349
|
|
|
324
350
|
def _can_trace?(arg)
|
|
325
351
|
(id = arg.__id__) != __id__ && id != @output.__id__
|
|
326
352
|
end
|
|
327
353
|
|
|
328
|
-
def _trace(arg)
|
|
329
|
-
@trace[arg] = arg if _can_trace?(arg)
|
|
330
|
-
arg
|
|
331
|
-
end
|
|
332
|
-
|
|
354
|
+
def _trace(arg) = _can_trace?(arg) ? @trace[arg] = arg : arg
|
|
333
355
|
def _trace_all(args) = args.each { @trace[_1] = _1 if _can_trace?(_1) }
|
|
334
356
|
|
|
335
357
|
def _trace_b(arg)
|
|
@@ -375,8 +397,8 @@ module ImLost
|
|
|
375
397
|
storage = fiber.storage || {}
|
|
376
398
|
out.vars('fiber storage', storage.keys) { storage[_1] }
|
|
377
399
|
else
|
|
378
|
-
out << ' !!! given Fiber is not the current Fiber'
|
|
379
|
-
|
|
400
|
+
out << ' !!! given Fiber is not the current Fiber'
|
|
401
|
+
out << " #{fiber.inspect}"
|
|
380
402
|
end
|
|
381
403
|
fiber
|
|
382
404
|
end
|
|
@@ -653,10 +675,10 @@ module ImLost
|
|
|
653
675
|
@output << out.to_s
|
|
654
676
|
end
|
|
655
677
|
|
|
656
|
-
@timer = TimerStore.new { |title, location, time| @output << <<~
|
|
678
|
+
@timer = TimerStore.new { |title, location, time| @output << <<~MSG }
|
|
657
679
|
T #{title}: #{time ? "#{time} sec." : 'created'}
|
|
658
680
|
#{location.path}:#{location.lineno}
|
|
659
|
-
|
|
681
|
+
MSG
|
|
660
682
|
TimerStore.private_class_method(:new)
|
|
661
683
|
|
|
662
684
|
untrace_all!
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: im-lost
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.2.
|
|
4
|
+
version: 1.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Mike Blumtritt
|
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
55
|
version: '0'
|
|
56
56
|
requirements: []
|
|
57
|
-
rubygems_version:
|
|
57
|
+
rubygems_version: 4.0.0
|
|
58
58
|
specification_version: 4
|
|
59
59
|
summary: Your debugging helper.
|
|
60
60
|
test_files: []
|