warning 1.4.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 +12 -0
  3. data/MIT-LICENSE +1 -1
  4. data/README.rdoc +3 -1
  5. data/lib/warning.rb +15 -4
  6. metadata +4 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2af0fa1becb10a11e209630c73fdb0f1184352cdb174edbf2ce8eabeff2d1763
4
- data.tar.gz: 51b04db9d1bcdfd9432c7501d3cfe15043bad6556940aea4214154791cee3964
3
+ metadata.gz: 707cbc126ba2e2b3fa89a38761da44db11f6a2f874a11142b5f9ea41e17d381c
4
+ data.tar.gz: 3335471b45e47921a7caf26444bff7bd9b1c82168a693e0f5d51ba9076725780
5
5
  SHA512:
6
- metadata.gz: bc4fe66b7efc5066225ad74b947bc7d32113651112a88ff12a9d8888dea60ed7b22ba54bc6cc156eb19f85f8cfe0c3199cbb7e041af44c54db08a9fda4fb4738
7
- data.tar.gz: dc243ded2132d05c9e926a59577c978a10169253419ba6e1aa1cfbc9c96a2628b1360991dac9dce7ab4ac11e29683e129a52eb9859b9a61eb07f9492f8ae089a
6
+ metadata.gz: 5da455cf6df9073f1419fb8daf5651ecbd54ad192e71c312480e9930fcab7ccc9aa0a2c33f564263739d5cc41d98ce247d7e97209996ba4711446cb1f8c8a55a
7
+ data.tar.gz: df67b33db51111caf1683463db2ff6221ea62329ae135230477da66a79938159cc9f696450c288fc89e033f084fc686e0de7455100e54cb7380dbcfb8ab99b4d
data/CHANGELOG CHANGED
@@ -1,3 +1,15 @@
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
+
7
+ === 1.5.0 (2024-12-18)
8
+
9
+ * Handle warning formats produced by prism compiler (jeremyevans)
10
+
11
+ * Add support for :default_gem_removal as regexp argument to Warning.ignore (jamiemccarthy, jeremyevans) (#24)
12
+
1
13
  === 1.4.0 (2024-05-24)
2
14
 
3
15
  * Add support for :ignored_block as regexp argument to Warning.ignore (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
@@ -30,6 +30,7 @@ appropriate regexp. The supported symbols are:
30
30
  * :arg_prefix
31
31
  * :ambiguous_slash
32
32
  * :bignum
33
+ * :default_gem_removal
33
34
  * :fixnum
34
35
  * :ignored_block
35
36
  * :keyword_separation
@@ -53,7 +54,8 @@ choosing the longest path prefix that the string starts with.
53
54
 
54
55
  <tt>Warning.process</tt> blocks can return +:default+ to use the default
55
56
  behavior, +:backtrace+ to use the default behavior and also print the backtrace
56
- 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.
57
59
 
58
60
  <tt>Warning.process</tt> can also accept a hash of actions instead of a block,
59
61
  with keys being regexps (or symbols supported by <tt>Warning.ignore</tt>) and
data/lib/warning.rb CHANGED
@@ -4,9 +4,10 @@ module Warning
4
4
  module Processor
5
5
  # Map of symbols to regexps for warning messages to ignore.
6
6
  IGNORE_MAP = {
7
- ambiguous_slash: /: warning: ambiguous first argument; put parentheses or a space even after [`']\/' operator\n\z|: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after [`']\/' operator\n\z/,
8
- arg_prefix: /: warning: [`'][&\*]' interpreted as argument prefix\n\z/,
7
+ ambiguous_slash: /: warning: ambiguous first argument; put parentheses or a space even after [`']\/' operator\n\z|: warning: ambiguity between regexp and two divisions: wrap regexp in parentheses or add a space after [`']\/' operator\n\z|ambiguous `\/`; wrap regexp in parentheses or add a space after `\/` operator\n\z/,
8
+ arg_prefix: /: warning: ([`'][&\*]'||ambiguous `[\*&]` has been) interpreted as( an)? argument prefix\n\z/,
9
9
  bignum: /: warning: constant ::Bignum is deprecated\n\z/,
10
+ default_gem_removal: /: warning: .+? was loaded from the standard library, but will no longer be part of the default gems starting from Ruby [\d.]+\./,
10
11
  fixnum: /: warning: constant ::Fixnum is deprecated\n\z/,
11
12
  ignored_block: /: warning: the block passed to '.+' defined at .+:\d+ may be ignored\n\z/,
12
13
  method_redefined: /: warning: method redefined; discarding old .+\n\z|: warning: previous definition of .+ was here\n\z/,
@@ -31,6 +32,9 @@ module Warning
31
32
  }
32
33
  private_constant :ACTION_PROC_MAP
33
34
 
35
+ # The error class used when converting warnings into errors.
36
+ attr_accessor :error_class
37
+
34
38
  # Clear all current ignored warnings, warning processors, and duplicate check cache.
35
39
  # Also disables deduplicating warnings if that is currently enabled.
36
40
  #
@@ -95,6 +99,8 @@ module Warning
95
99
  # :arg_prefix :: Ignore warnings when using * or & as an argument prefix
96
100
  # :ambiguous_slash :: Ignore warnings for things like <tt>method /regexp/</tt>
97
101
  # :bignum :: Ignore warnings when referencing the ::Bignum constant.
102
+ # :default_gem_removal :: Ignore warnings that a gem will be removed from the default gems
103
+ # in a future Ruby version.
98
104
  # :fixnum :: Ignore warnings when referencing the ::Fixnum constant.
99
105
  # :keyword_separation :: Ignore warnings related to keyword argument separation.
100
106
  # :method_redefined :: Ignore warnings when defining a method in a class/module where a
@@ -155,7 +161,8 @@ module Warning
155
161
  # :default :: Take the default action (call super, printing to $stderr).
156
162
  # :backtrace :: Take the default action (call super, printing to $stderr),
157
163
  # and also print the backtrace.
158
- # :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).
159
166
  #
160
167
  # If the block returns anything else, it is assumed the block completely handled
161
168
  # the warning and takes no other action.
@@ -207,6 +214,9 @@ module Warning
207
214
  nil
208
215
  end
209
216
 
217
+ # :nocov:
218
+ backtrace_locations = RUBY_VERSION >= '3.4' ? 'caller_locations' : 'caller'
219
+ # :nocov:
210
220
 
211
221
  if RUBY_VERSION >= '3.0'
212
222
  method_args = ', category: nil'
@@ -258,7 +268,7 @@ module Warning
258
268
  #{super_}
259
269
  $stderr.puts caller
260
270
  when :raise
261
- raise str
271
+ raise @error_class, str, #{backtrace_locations}(3..-1)
262
272
  else
263
273
  # nothing
264
274
  end
@@ -292,6 +302,7 @@ module Warning
292
302
  @process = []
293
303
  @dedup = false
294
304
  @monitor = Monitor.new
305
+ @error_class = RuntimeError
295
306
 
296
307
  extend Processor
297
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.4.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-05-24 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.9
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: []