im-lost 1.2.1 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 533f4f50596d5c6a55f674e813d7053d954a26864ea80c2e266f8c6bd92c00fd
4
- data.tar.gz: 31a7bd884fabb3aba95789ff9771811300e3c7cb6e75ec3c762a394df603b2ed
3
+ metadata.gz: 6a11bb08b82dde3d4d56939a25d4898c77ef75ce9e82659511f8a47e6b1d0b9d
4
+ data.tar.gz: 073e42d29b09cd54db36a39d12e334d7cc2a5b9fbd5d2f3447265cd84cc278da
5
5
  SHA512:
6
- metadata.gz: 4631c248cc8af2691d09651ed3a90b863f72ba6954e3c14172208ceb153e69b834e5f67c12555347fa474f2f97a44ad579f8ef85a6b5db4be07ea574b76a7f36
7
- data.tar.gz: d1accd54c95db533220dd98a6a741380be91050568d16cbc3b6acdaef1ba147b98f2ad39f560b1613b7351c01dca4a44bafd4db46e7ef526b169e5821da68fc0
6
+ metadata.gz: eb4ee264f51b598b2b086033958a6eb587934a8d2be08c009f6c6d4c9991b84fd0657b5b691cdde7e50a2fb662316a81b6b38a5d7ada949277c14da99d12021a
7
+ data.tar.gz: 8b183a0464fb8a64a238792347ae697e557440b3cfc58bb26251f7b23ce2ef7ee766f2ca02fd0382ff449f3c17244c45dbfee494122bd6f28efd97f9e1b80e89
data/README.md CHANGED
@@ -75,8 +75,6 @@ See the [online help](https://rubydoc.info/gems/im-lost/ImLost) for more!
75
75
  ```ruby
76
76
  require 'im-lost'
77
77
 
78
- require_relative '../lib/im-lost'
79
-
80
78
  class Foo
81
79
  def self.create(value:) = new(value)
82
80
 
@@ -109,56 +107,56 @@ my_foo.foo(3) { puts _1 }
109
107
  ImLost.vars(my_foo)
110
108
 
111
109
  # output will look like
112
- # > Foo.create(:foo!)
113
- # /examples/foo.rb:24
114
- # > Foo.new(*)
115
- # /examples/foo.rb:6
116
- # < Foo.new(*)
117
- # /examples/foo.rb:6
118
- # = #<Foo:0x00000001006448c0 @value=:foo!>
119
- # < Foo.create(:foo!)
120
- # /examples/foo.rb:24
121
- # = #<Foo:0x00000001006448c0 @value=:foo!>
122
- # > Foo#foo(1, *[], :none, **{}, &nil)
123
- # /examples/foo.rb:27
124
- # > Foo#bar()
125
- # /examples/foo.rb:15
126
- # < Foo#bar()
127
- # /examples/foo.rb:15
128
- # = :bar
129
- # < Foo#foo(1, *[], :none, **{}, &nil)
130
- # /examples/foo.rb:27
131
- # = "1-none-[]-{}-bar"
132
- # * /examples/foo.rb:28
133
- # > instance variables
134
- # @value: "1-none-[]-{}-bar"
135
- # > Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
136
- # /examples/foo.rb:30
137
- # > Foo#bar()
138
- # /examples/foo.rb:15
139
- # < Foo#bar()
140
- # /examples/foo.rb:15
141
- # = :bar
142
- # < Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
143
- # /examples/foo.rb:30
144
- # = "2-some-[a,b,c]-{:name=>:value}-bar"
145
- # * /examples/foo.rb:31
146
- # > instance variables
147
- # @value: "2-some-[a,b,c]-{:name=>:value}-bar"
148
- # > Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000100641d28 /examples/foo.rb:33>)
149
- # /examples/foo.rb:33
150
- # > Foo#bar()
151
- # /examples/foo.rb:15
152
- # < Foo#bar()
153
- # /examples/foo.rb:15
154
- # = :bar
155
- # 3--[]-{}-bar
156
- # < Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000100641d28 /examples/foo.rb:33>)
157
- # /examples/foo.rb:33
158
- # = nil
159
- # * /examples/foo.rb:34
160
- # > instance variables
161
- # @value: "3--[]-{}-bar"
110
+ # > Foo.create(:foo!)
111
+ # ./examples/foo.rb:24
112
+ # > Foo.new(*args)
113
+ # ./examples/foo.rb:6
114
+ # < Foo.new(*args)
115
+ # ./examples/foo.rb:6
116
+ # = #<Foo:0x0000000104c24b88 @value=:foo!>
117
+ # < Foo.create(:foo!)
118
+ # ./examples/foo.rb:24
119
+ # = #<Foo:0x0000000104c24b88 @value=:foo!>
120
+ # > Foo#foo(1, *[], :none, **{}, &nil)
121
+ # ./examples/foo.rb:27
122
+ # > Foo#bar()
123
+ # ./examples/foo.rb:15
124
+ # < Foo#bar()
125
+ # ./examples/foo.rb:15
126
+ # = :bar
127
+ # < Foo#foo(1, *[], :none, **{}, &nil)
128
+ # ./examples/foo.rb:27
129
+ # = "1-none-[]-{}-bar"
130
+ # * ./examples/foo.rb:28
131
+ # > instance variables
132
+ # @value: "1-none-[]-{}-bar"
133
+ # > Foo#foo(2, *[:a, :b, :c], :some, **{name: :value}, &nil)
134
+ # ./examples/foo.rb:30
135
+ # > Foo#bar()
136
+ # ./examples/foo.rb:15
137
+ # < Foo#bar()
138
+ # ./examples/foo.rb:15
139
+ # = :bar
140
+ # < Foo#foo(2, *[:a, :b, :c], :some, **{name: :value}, &nil)
141
+ # ./examples/foo.rb:30
142
+ # = "2-some-[a,b,c]-{name: :value}-bar"
143
+ # * ./examples/foo.rb:31
144
+ # > instance variables
145
+ # @value: "2-some-[a,b,c]-{name: :value}-bar"
146
+ # > Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000104c22180 ./examples/foo.rb:33>)
147
+ # ./examples/foo.rb:33
148
+ # > Foo#bar()
149
+ # ./examples/foo.rb:15
150
+ # < Foo#bar()
151
+ # ./examples/foo.rb:15
152
+ # = :bar
153
+ # 3--[]-{}-bar
154
+ # < Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000104c22180 ./examples/foo.rb:33>)
155
+ # ./examples/foo.rb:33
156
+ # = nil
157
+ # * ./examples/foo.rb:34
158
+ # > instance variables
159
+ # @value: "3--[]-{}-bar"
162
160
  ```
163
161
 
164
162
  See [examples dir](./examples) for more…
data/examples/foo.rb CHANGED
@@ -34,53 +34,53 @@ my_foo.foo(3) { puts _1 }
34
34
  ImLost.vars(my_foo)
35
35
 
36
36
  # output will look like
37
- # > Foo.create(:foo!)
38
- # /examples/foo.rb:24
39
- # > Foo.new(*)
40
- # /examples/foo.rb:6
41
- # < Foo.new(*)
42
- # /examples/foo.rb:6
43
- # = #<Foo:0x00000001006448c0 @value=:foo!>
44
- # < Foo.create(:foo!)
45
- # /examples/foo.rb:24
46
- # = #<Foo:0x00000001006448c0 @value=:foo!>
47
- # > Foo#foo(1, *[], :none, **{}, &nil)
48
- # /examples/foo.rb:27
49
- # > Foo#bar()
50
- # /examples/foo.rb:15
51
- # < Foo#bar()
52
- # /examples/foo.rb:15
53
- # = :bar
54
- # < Foo#foo(1, *[], :none, **{}, &nil)
55
- # /examples/foo.rb:27
56
- # = "1-none-[]-{}-bar"
57
- # * /examples/foo.rb:28
58
- # > instance variables
59
- # @value: "1-none-[]-{}-bar"
60
- # > Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
61
- # /examples/foo.rb:30
62
- # > Foo#bar()
63
- # /examples/foo.rb:15
64
- # < Foo#bar()
65
- # /examples/foo.rb:15
66
- # = :bar
67
- # < Foo#foo(2, *[:a, :b, :c], :some, **{:name=>:value}, &nil)
68
- # /examples/foo.rb:30
69
- # = "2-some-[a,b,c]-{:name=>:value}-bar"
70
- # * /examples/foo.rb:31
71
- # > instance variables
72
- # @value: "2-some-[a,b,c]-{:name=>:value}-bar"
73
- # > Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000100641d28 /examples/foo.rb:33>)
74
- # /examples/foo.rb:33
75
- # > Foo#bar()
76
- # /examples/foo.rb:15
77
- # < Foo#bar()
78
- # /examples/foo.rb:15
79
- # = :bar
80
- # 3--[]-{}-bar
81
- # < Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000100641d28 /examples/foo.rb:33>)
82
- # /examples/foo.rb:33
83
- # = nil
84
- # * /examples/foo.rb:34
85
- # > instance variables
86
- # @value: "3--[]-{}-bar"
37
+ # > Foo.create(:foo!)
38
+ # ./examples/foo.rb:24
39
+ # > Foo.new(*args)
40
+ # ./examples/foo.rb:6
41
+ # < Foo.new(*args)
42
+ # ./examples/foo.rb:6
43
+ # = #<Foo:0x0000000104c24b88 @value=:foo!>
44
+ # < Foo.create(:foo!)
45
+ # ./examples/foo.rb:24
46
+ # = #<Foo:0x0000000104c24b88 @value=:foo!>
47
+ # > Foo#foo(1, *[], :none, **{}, &nil)
48
+ # ./examples/foo.rb:27
49
+ # > Foo#bar()
50
+ # ./examples/foo.rb:15
51
+ # < Foo#bar()
52
+ # ./examples/foo.rb:15
53
+ # = :bar
54
+ # < Foo#foo(1, *[], :none, **{}, &nil)
55
+ # ./examples/foo.rb:27
56
+ # = "1-none-[]-{}-bar"
57
+ # * ./examples/foo.rb:28
58
+ # > instance variables
59
+ # @value: "1-none-[]-{}-bar"
60
+ # > Foo#foo(2, *[:a, :b, :c], :some, **{name: :value}, &nil)
61
+ # ./examples/foo.rb:30
62
+ # > Foo#bar()
63
+ # ./examples/foo.rb:15
64
+ # < Foo#bar()
65
+ # ./examples/foo.rb:15
66
+ # = :bar
67
+ # < Foo#foo(2, *[:a, :b, :c], :some, **{name: :value}, &nil)
68
+ # ./examples/foo.rb:30
69
+ # = "2-some-[a,b,c]-{name: :value}-bar"
70
+ # * ./examples/foo.rb:31
71
+ # > instance variables
72
+ # @value: "2-some-[a,b,c]-{name: :value}-bar"
73
+ # > Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000104c22180 ./examples/foo.rb:33>)
74
+ # ./examples/foo.rb:33
75
+ # > Foo#bar()
76
+ # ./examples/foo.rb:15
77
+ # < Foo#bar()
78
+ # ./examples/foo.rb:15
79
+ # = :bar
80
+ # 3--[]-{}-bar
81
+ # < Foo#foo(3, *[], nil, **{}, &#<Proc:0x0000000104c22180 ./examples/foo.rb:33>)
82
+ # ./examples/foo.rb:33
83
+ # = nil
84
+ # * ./examples/foo.rb:34
85
+ # > instance variables
86
+ # @value: "3--[]-{}-bar"
@@ -2,5 +2,5 @@
2
2
 
3
3
  module ImLost
4
4
  # The version number of the gem.
5
- VERSION = '1.2.1'
5
+ VERSION = '1.2.2'
6
6
  end
data/lib/im-lost.rb CHANGED
@@ -54,7 +54,7 @@ module ImLost
54
54
  return @output = value if defined?(value.<<)
55
55
  raise(
56
56
  NoMethodError,
57
- "undefined method '<<' for an instance of #{
57
+ "undefined method '#<<' for an instance of #{
58
58
  Kernel.instance_method(:class).bind(value).call
59
59
  }"
60
60
  )
@@ -107,14 +107,16 @@ module ImLost
107
107
  #
108
108
  def trace_exceptions(with_locations: true)
109
109
  return unless block_given?
110
- we = @trace_exceptions.enabled?
111
- el = @exception_locations
112
- @exception_locations = with_locations
113
- @trace_exceptions.enable unless we
114
- yield
115
- ensure
116
- @trace_exceptions.disable unless we
117
- @exception_locations = el
110
+ begin
111
+ we = @trace_exceptions.enabled?
112
+ el = @exception_locations
113
+ @exception_locations = with_locations
114
+ @trace_exceptions.enable unless we
115
+ yield
116
+ ensure
117
+ @trace_exceptions.disable unless we
118
+ @exception_locations = el
119
+ end
118
120
  end
119
121
 
120
122
  #
@@ -314,7 +316,7 @@ module ImLost
314
316
  object
315
317
  ensure
316
318
  @trace[traced] = traced if traced
317
- @output << out.to_s
319
+ @output << out
318
320
  end
319
321
 
320
322
  private
@@ -380,8 +382,8 @@ module ImLost
380
382
  end
381
383
 
382
384
  def _instance_vars(out, object)
383
- out.vars('instance variables', object.instance_variables) do |n|
384
- object.instance_variable_get(n)
385
+ out.vars('instance variables', object.instance_variables) do |name|
386
+ object.instance_variable_get(name)
385
387
  end
386
388
  object
387
389
  end
@@ -454,7 +456,11 @@ module ImLost
454
456
 
455
457
  # @attribute [r] ids
456
458
  # @return [Array<Integer>] IDs of all registered timers
457
- def ids = (@ll.keys.keep_if { Integer === _1 })
459
+ def ids = @ll.keys.keep_if { Integer === _1 }
460
+
461
+ # @attribute [r] names
462
+ # @return [Array<String>] names of all registered named timers
463
+ def names = @ll.keys.delete_if { Integer === _1 }
458
464
 
459
465
  #
460
466
  # Create and register a new named or anonymous timer.
@@ -491,6 +497,16 @@ module ImLost
491
497
  nil
492
498
  end
493
499
 
500
+ #
501
+ # Delete and unregister all timers.
502
+ #
503
+ # @return [self] itself
504
+ #
505
+ def clear
506
+ @ll = {}
507
+ self
508
+ end
509
+
494
510
  #
495
511
  # Print the ID or name and the runtime since a timer was created.
496
512
  # It includes the location.
@@ -525,7 +541,7 @@ module ImLost
525
541
 
526
542
  def initialize(&block)
527
543
  @cb = block
528
- @ll = {}
544
+ clear
529
545
  end
530
546
  end
531
547
 
@@ -643,10 +659,9 @@ module ImLost
643
659
  TIMER_MSG
644
660
  TimerStore.private_class_method(:new)
645
661
 
646
- @fiber_support = !!defined?(Fiber.current.storage)
647
-
662
+ untrace_all!
648
663
  @output = STDERR
649
- @trace = {}.compare_by_identity
664
+ @fiber_support = !!defined?(Fiber.current.storage)
650
665
  @caller_locations = @exception_locations = true
651
666
  self.trace_calls = self.trace_results = true
652
667
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: im-lost
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Blumtritt
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-01-30 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: |
13
13
  If you have overlooked something again and don't really understand what
@@ -21,8 +21,8 @@ description: |
21
21
  executables: []
22
22
  extensions: []
23
23
  extra_rdoc_files:
24
- - README.md
25
24
  - LICENSE
25
+ - README.md
26
26
  files:
27
27
  - LICENSE
28
28
  - README.md
@@ -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: 3.6.3
57
+ rubygems_version: 3.6.8
58
58
  specification_version: 4
59
59
  summary: Your debugging helper.
60
60
  test_files: []