warning 1.5.0 → 1.6.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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +6 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +2 -1
  5. data/lib/warning.rb +10 -2
  6. metadata +4 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6054dca1a00f1d10743d33a9763485b627d28308c6f3ea759c13dc3d1dc93ee9
4
- data.tar.gz: b6a1dbed6106cf3fda161ea834b198bce4576e140891043437fb1e857a2117a8
3
+ metadata.gz: 707cbc126ba2e2b3fa89a38761da44db11f6a2f874a11142b5f9ea41e17d381c
4
+ data.tar.gz: 3335471b45e47921a7caf26444bff7bd9b1c82168a693e0f5d51ba9076725780
5
5
  SHA512:
6
- metadata.gz: 23f51a39800e815957754d82f090e4372e1709176eedc4e905151d81848ebdc1173049f570d74d65be3a360358d6a2786191e58ba3edfcb5f88edb27296325c5
7
- data.tar.gz: 4212dde6557469b9b9e1ab37200a4d27e84f629b803a533fc9fd52645efb9ed2b8382dde7e115b80d54fef187819c9c169cc09c90f71be8136540e6a41ef0659
6
+ metadata.gz: 5da455cf6df9073f1419fb8daf5651ecbd54ad192e71c312480e9930fcab7ccc9aa0a2c33f564263739d5cc41d98ce247d7e97209996ba4711446cb1f8c8a55a
7
+ data.tar.gz: df67b33db51111caf1683463db2ff6221ea62329ae135230477da66a79938159cc9f696450c288fc89e033f084fc686e0de7455100e54cb7380dbcfb8ab99b4d
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.6.0 (2026-05-11)
2
+
3
+ * Skip warning's own frame when raising exceptions (byroot) (#27)
4
+
5
+ * Add Warning.error_class accessor to override class to use when raising warnings as errors (byroot) (#26)
6
+
1
7
  === 1.5.0 (2024-12-18)
2
8
 
3
9
  * Handle warning formats produced by prism compiler (jeremyevans)
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016-2022 Jeremy Evans
1
+ Copyright (c) 2016-2026 Jeremy Evans and contributors
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to
data/README.rdoc CHANGED
@@ -54,7 +54,8 @@ choosing the longest path prefix that the string starts with.
54
54
 
55
55
  <tt>Warning.process</tt> blocks can return +:default+ to use the default
56
56
  behavior, +:backtrace+ to use the default behavior and also print the backtrace
57
- or +:raise+ to raise the warning string as a RuntimeError.
57
+ or +:raise+ to raise the warning string as a +RuntimeError+. You can use
58
+ <tt>Warning.error_class=</tt> to override the exception class used.
58
59
 
59
60
  <tt>Warning.process</tt> can also accept a hash of actions instead of a block,
60
61
  with keys being regexps (or symbols supported by <tt>Warning.ignore</tt>) and
data/lib/warning.rb CHANGED
@@ -32,6 +32,9 @@ module Warning
32
32
  }
33
33
  private_constant :ACTION_PROC_MAP
34
34
 
35
+ # The error class used when converting warnings into errors.
36
+ attr_accessor :error_class
37
+
35
38
  # Clear all current ignored warnings, warning processors, and duplicate check cache.
36
39
  # Also disables deduplicating warnings if that is currently enabled.
37
40
  #
@@ -158,7 +161,8 @@ module Warning
158
161
  # :default :: Take the default action (call super, printing to $stderr).
159
162
  # :backtrace :: Take the default action (call super, printing to $stderr),
160
163
  # and also print the backtrace.
161
- # :raise :: Raise a RuntimeError with the warning as the message.
164
+ # :raise :: Raise a RuntimeError with the warning as the message (use
165
+ # Warning.error_class= to use a different warning class).
162
166
  #
163
167
  # If the block returns anything else, it is assumed the block completely handled
164
168
  # the warning and takes no other action.
@@ -210,6 +214,9 @@ module Warning
210
214
  nil
211
215
  end
212
216
 
217
+ # :nocov:
218
+ backtrace_locations = RUBY_VERSION >= '3.4' ? 'caller_locations' : 'caller'
219
+ # :nocov:
213
220
 
214
221
  if RUBY_VERSION >= '3.0'
215
222
  method_args = ', category: nil'
@@ -261,7 +268,7 @@ module Warning
261
268
  #{super_}
262
269
  $stderr.puts caller
263
270
  when :raise
264
- raise str
271
+ raise @error_class, str, #{backtrace_locations}(3..-1)
265
272
  else
266
273
  # nothing
267
274
  end
@@ -295,6 +302,7 @@ module Warning
295
302
  @process = []
296
303
  @dedup = false
297
304
  @monitor = Monitor.new
305
+ @error_class = RuntimeError
298
306
 
299
307
  extend Processor
300
308
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warning
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-12-18 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: minitest-global_expectations
@@ -34,9 +33,9 @@ email: code@jeremyevans.net
34
33
  executables: []
35
34
  extensions: []
36
35
  extra_rdoc_files:
37
- - README.rdoc
38
36
  - CHANGELOG
39
37
  - MIT-LICENSE
38
+ - README.rdoc
40
39
  files:
41
40
  - CHANGELOG
42
41
  - MIT-LICENSE
@@ -50,7 +49,6 @@ metadata:
50
49
  changelog_uri: https://github.com/jeremyevans/ruby-warning/blob/master/CHANGELOG
51
50
  documentation_uri: https://github.com/jeremyevans/ruby-warning/blob/master/README.rdoc
52
51
  source_code_uri: https://github.com/jeremyevans/ruby-warning
53
- post_install_message:
54
52
  rdoc_options:
55
53
  - "--quiet"
56
54
  - "--line-numbers"
@@ -72,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
70
  - !ruby/object:Gem::Version
73
71
  version: '0'
74
72
  requirements: []
75
- rubygems_version: 3.5.22
76
- signing_key:
73
+ rubygems_version: 4.0.3
77
74
  specification_version: 4
78
75
  summary: Add custom processing for warnings
79
76
  test_files: []