enhanced_errors 0.1.8 → 2.0.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.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enhanced_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-04 00:00:00.000000000 Z
11
+ date: 2024-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print
@@ -42,14 +42,14 @@ dependencies:
42
42
  name: yard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">"
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.9'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">"
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.9'
55
55
  description: 'EnhancedErrors will automatically enhance your errors with messages
@@ -93,12 +93,13 @@ files:
93
93
  - doc/method_list.html
94
94
  - doc/top-level-namespace.html
95
95
  - enhanced_errors.gemspec
96
+ - examples/demo_spec.rb
96
97
  - examples/division_by_zero_example.rb
97
98
  - examples/example_spec.rb
98
- - lib/binding.rb
99
- - lib/colors.rb
99
+ - lib/enhanced/colors.rb
100
+ - lib/enhanced/exception.rb
101
+ - lib/enhanced/integrations/rspec_error_failure_message.rb
100
102
  - lib/enhanced_errors.rb
101
- - lib/error_enhancements.rb
102
103
  homepage: https://github.com/ericbeland/enhanced_errors
103
104
  licenses: []
104
105
  metadata:
data/lib/binding.rb DELETED
@@ -1,12 +0,0 @@
1
- # binding.rb
2
-
3
- module Debugging
4
- def let_vars_hash
5
- memoized_values = self.receiver.instance_variable_get(:@__memoized)&.instance_variable_get(:@memoized)
6
- memoized_values && !memoized_values.empty? ? memoized_values.dup : {}
7
- end
8
- end
9
-
10
- class Binding
11
- include Debugging
12
- end
data/lib/colors.rb DELETED
@@ -1,27 +0,0 @@
1
- class Colors
2
- COLORS = { red: 31, green: 32, yellow: 33, blue: 34, purple: 35, cyan: 36, white: 0 }
3
-
4
- class << self
5
- def enabled?
6
- @enabled
7
- end
8
-
9
- def enabled=(value)
10
- @enabled = value
11
- end
12
-
13
- def color(num, string)
14
- @enabled ? "#{code(num)}#{string}#{code(0)}" : string
15
- end
16
-
17
- def code(num)
18
- "\e[#{num}m"
19
- end
20
-
21
- COLORS.each do |color, code|
22
- define_method(color) do |str|
23
- color(COLORS[color], str)
24
- end
25
- end
26
- end
27
- end
@@ -1,64 +0,0 @@
1
- # error_enhancements.rb
2
-
3
- module ErrorEnhancements
4
- def message
5
- original_message = begin
6
- super()
7
- rescue
8
- ''
9
- end
10
- vars_message = variables_message rescue ""
11
- if original_message.include?(vars_message)
12
- original_message
13
- else
14
- "#{original_message}\n#{vars_message}"
15
- end
16
- rescue => e
17
- original_message || ''
18
- end
19
-
20
- def variables_message
21
- @variables_message ||= begin
22
- bindings_of_interest = []
23
- if defined?(@binding_infos) && @binding_infos && !@binding_infos.empty?
24
- bindings_of_interest = select_binding_infos(@binding_infos)
25
- end
26
- EnhancedErrors.format(bindings_of_interest)
27
- rescue => e
28
- # Avoid using puts; consider logging instead
29
- # Avoid raising exceptions in rescue blocks
30
- ""
31
- end
32
- end
33
-
34
- private
35
-
36
- def select_binding_infos(binding_infos)
37
- # Preference:
38
- # Grab the first raise binding that isn't a library (gem) binding.
39
- # If there are only library bindings, grab the first one.
40
- # Grab the last rescue binding if we have one
41
-
42
- bindings_of_interest = []
43
-
44
- binding_infos.each do |info|
45
- if info[:capture_event] == 'raise' && !info[:library]
46
- bindings_of_interest << info
47
- break
48
- end
49
- end
50
-
51
- if bindings_of_interest.empty?
52
- bindings_of_interest << binding_infos.first if binding_infos.first
53
- end
54
-
55
- # Find the last rescue binding if there is one
56
- binding_infos.reverse.each do |info|
57
- if info[:capture_event] == 'rescue'
58
- bindings_of_interest << info
59
- break
60
- end
61
- end
62
- bindings_of_interest
63
- end
64
- end