tracing 2.0.2 → 2.0.3
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/lib/tracing.rb +12 -2
- data/lib/tracing/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d4d4f8efb01206dd0ee3dbb63532fa393e52df
|
4
|
+
data.tar.gz: 340bc352b682059e1ddbb64c8acd890ad07ebec1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6e1dc61dd29d0ff9ebb0ace44ff73f88760a233dd393c7d05d5a7dfc878cd9a122b0ebb17b90dec13ac52f122ff2784027a500b38a40dda6cfdd677a4328bd6
|
7
|
+
data.tar.gz: cbd2d6eeeadc301d574389402151d5c15b75fc2476d649c05c34ce2aee64558b10e002d4eda1ba2b9462c5bd7b18019a6c9f0e6c0d44a65315d9055a5dc6c706
|
data/lib/tracing.rb
CHANGED
@@ -49,6 +49,8 @@ module Tracing
|
|
49
49
|
end
|
50
50
|
|
51
51
|
class Tracer
|
52
|
+
attr_accessor :indent, :nested
|
53
|
+
|
52
54
|
def initialize
|
53
55
|
reinitialize
|
54
56
|
end
|
@@ -202,7 +204,6 @@ module Tracing
|
|
202
204
|
puts msg
|
203
205
|
end
|
204
206
|
|
205
|
-
private
|
206
207
|
def show(*args)
|
207
208
|
key, enabled_prefix = *selected?(args)
|
208
209
|
|
@@ -231,6 +232,7 @@ module Tracing
|
|
231
232
|
!!enabled_prefix
|
232
233
|
end
|
233
234
|
|
235
|
+
private
|
234
236
|
def selected?(args)
|
235
237
|
# Figure out whether this trace is enabled (itself or by :all), if it nests, and if we should print the key:
|
236
238
|
key =
|
@@ -272,7 +274,15 @@ end
|
|
272
274
|
# Make the trace method globally available:
|
273
275
|
class Object
|
274
276
|
def trace *args, &block
|
275
|
-
|
277
|
+
begin
|
278
|
+
# This monstrosity reduces the steps when single-stepping:
|
279
|
+
tracer = (Tracing.tracer ||= Tracing::Tracer.new) and
|
280
|
+
(old_indent, old_nested, enabled = tracer.indent, tracer.nested, tracer.show(*args))
|
281
|
+
|
282
|
+
block ? yield : (args.size == 0 ? tracer : enabled)
|
283
|
+
ensure
|
284
|
+
tracer.indent, tracer.nested = old_indent, old_nested
|
285
|
+
end
|
276
286
|
end
|
277
287
|
end
|
278
288
|
|
data/lib/tracing/version.rb
CHANGED