enhanced_errors 3.0.3 → 3.0.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 +4 -3
- data/benchmark/benchmark.rb +31 -29
- data/benchmark/memory_bench.rb +1 -1
- data/benchmark/result.txt +13 -0
- data/doc/Enhanced/Colors.html +2 -2
- data/doc/Enhanced/Context.html +283 -0
- data/doc/Enhanced/ExceptionBindingInfos.html +255 -0
- data/doc/Enhanced/ExceptionContext.html +397 -0
- data/doc/Enhanced.html +8 -4
- data/doc/EnhancedErrors.html +385 -269
- data/doc/EnhancedExceptionContext.html +15 -15
- data/doc/Exception.html +5 -5
- data/doc/ExceptionBindingInfos.html +2 -2
- data/doc/Minitest.html +3 -3
- data/doc/_index.html +12 -6
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +9 -4
- data/doc/index.html +9 -4
- data/doc/method_list.html +34 -18
- data/doc/top-level-namespace.html +18 -8
- data/enhanced_errors.gemspec +1 -1
- data/lib/enhanced/context.rb +7 -5
- data/lib/enhanced/exception.rb +35 -36
- data/lib/enhanced/exception_context.rb +49 -0
- data/lib/enhanced/minitest_patch.rb +1 -1
- data/lib/enhanced_errors.rb +147 -98
- metadata +8 -9
- data/.yardoc/checksums +0 -6
- data/.yardoc/complete +0 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +0 -0
- data/lib/enhanced/enhanced_exception_context.rb +0 -47
data/.yardoc/object_types
DELETED
Binary file
|
data/.yardoc/objects/root.dat
DELETED
Binary file
|
data/.yardoc/proxy_types
DELETED
Binary file
|
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'weakref'
|
2
|
-
|
3
|
-
require_relative 'context'
|
4
|
-
|
5
|
-
require 'weakref'
|
6
|
-
require 'monitor'
|
7
|
-
|
8
|
-
module EnhancedExceptionContext
|
9
|
-
extend self
|
10
|
-
|
11
|
-
REGISTRY = {}
|
12
|
-
MUTEX = Monitor.new
|
13
|
-
|
14
|
-
def store_context(exception, context)
|
15
|
-
MUTEX.synchronize do
|
16
|
-
REGISTRY[exception.object_id] = { weak_exc: WeakRef.new(exception), context: context }
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def context_for(exception)
|
21
|
-
MUTEX.synchronize do
|
22
|
-
entry = REGISTRY[exception.object_id]
|
23
|
-
return nil unless entry
|
24
|
-
|
25
|
-
begin
|
26
|
-
_ = entry[:weak_exc].__getobj__ # ensure exception is still alive
|
27
|
-
entry[:context]
|
28
|
-
rescue RefError
|
29
|
-
# Exception no longer alive, clean up
|
30
|
-
REGISTRY.delete(exception.object_id)
|
31
|
-
nil
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def clear_context(exception)
|
37
|
-
MUTEX.synchronize do
|
38
|
-
REGISTRY.delete(exception.object_id)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def clear_all
|
43
|
-
MUTEX.synchronize do
|
44
|
-
REGISTRY.clear
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|