warning_signs 0.5.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d9af94718f30c122c45153b7c2837ec2544ab06d3c3f5356b6062408e766d64
4
- data.tar.gz: c038f7baf62f0f15c63041e47c54281e9c9c26c8dfc489f96c98780e7490b523
3
+ metadata.gz: 1f21801f5c06e7f5c646ba63b5848fb7fa11eee423e53bcdb74cd16932cc683a
4
+ data.tar.gz: 746c5de984d08d217a4cebe9c8aaf89f403ffe7961ad299499be81f0147b6384
5
5
  SHA512:
6
- metadata.gz: 5b47dd7876dec5213c03fb2774ee2add5a5da6f35d40dac9d33f8a27dd5767ac80bbc507b009d01887695184e2c24af5bd286028b41b647e56b63e1e3fc0f74b
7
- data.tar.gz: 14618990cbda30ebb76dcf6d362b67c4eacdbb700005d3f1aef6c15dc98348a43e5c67323ed3b286ee1b37ad5d0a88b7a4d721ea78c20948baa8a97560d0fdb6
6
+ metadata.gz: e666ef9d2789d74761fe39d56af39495f151d389da2ad97c791027b8f71f1890476254822db03e1beb220e5268b870d45deccf147fcfddc034a4d891903fc6e5
7
+ data.tar.gz: c5e79fcd7beab816f16883d6e3ac6a0f5001f8426ab25cfe5a2a4411ec821f6aac56beccbf5cf911bb1e852abac43bfb3aa508c03a455ad51ff8fb0773904838
@@ -20,7 +20,7 @@ jobs:
20
20
  - "2.7"
21
21
 
22
22
  steps:
23
- - uses: actions/checkout@v2
23
+ - uses: actions/checkout@v3
24
24
  - name: Set up Ruby
25
25
  uses: ruby/setup-ruby@v1
26
26
  with:
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## 0.6.1 Dec 15, 2023
2
+
3
+ * Warning Signs error message makes it clearer that Warning Signs is
4
+ triggering the error
5
+
6
+ ## 0.6.0
7
+
8
+ * Allow for format options in messages
9
+ * Allow for filter options in backtrace
10
+ * Allow for multiple output behaviors based on environment
11
+
12
+ ## 0.5.1
13
+
14
+ * Better filtering of backtraces
15
+
1
16
  ## 0.5.0
2
17
 
3
18
  * Allow handlers to print out backtraces for log, stdout, and stderr behaviors
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- warning_signs (0.5.0)
4
+ warning_signs (0.6.1)
5
5
  awesome_print
6
- railties
6
+ railties (<= 7.1.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -41,16 +41,16 @@ GEM
41
41
  json (2.6.3)
42
42
  language_server-protocol (3.17.0.3)
43
43
  lint_roller (1.0.0)
44
- loofah (2.20.0)
44
+ loofah (2.21.3)
45
45
  crass (~> 1.0.2)
46
- nokogiri (>= 1.5.9)
46
+ nokogiri (>= 1.12.0)
47
47
  method_source (1.0.0)
48
48
  minitest (5.18.0)
49
- nokogiri (1.14.3-arm64-darwin)
49
+ nokogiri (1.15.0-arm64-darwin)
50
50
  racc (~> 1.4)
51
- nokogiri (1.14.3-x86_64-darwin)
51
+ nokogiri (1.15.0-x86_64-darwin)
52
52
  racc (~> 1.4)
53
- nokogiri (1.14.3-x86_64-linux)
53
+ nokogiri (1.15.0-x86_64-linux)
54
54
  racc (~> 1.4)
55
55
  parallel (1.23.0)
56
56
  parser (3.2.2.1)
@@ -130,7 +130,7 @@ GEM
130
130
  standard-performance (1.0.1)
131
131
  lint_roller (~> 1.0)
132
132
  rubocop-performance (~> 1.16.0)
133
- thor (1.2.1)
133
+ thor (1.2.2)
134
134
  tzinfo (2.0.6)
135
135
  concurrent-ruby (~> 1.0)
136
136
  unicode-display_width (2.4.2)
data/README.md CHANGED
@@ -16,6 +16,8 @@ To install Warning Signs add
16
16
  to your gemfile, you will most likely want it to be in all environments, but
17
17
  under some use cases, you may not need it in production.
18
18
 
19
+ ### Rails 7.1 is not supported yet, it changed intenral deprecation objects
20
+
19
21
  ## Using Warning Signs
20
22
 
21
23
  The Warning Signs gem looks for a `.warning_signs.yml` file when the Rails
@@ -26,6 +28,8 @@ You should remove any environment settings in Rails that are managing
26
28
  `config.active_support.deprecation`, or at least those that are not
27
29
  set to `:notify` -- use WarningSigns to handle those settings...
28
30
 
31
+ ### Handlers
32
+
29
33
  Warning Signs allows you to define _handlers_ in the YAML file. A handler
30
34
  consists of the following:
31
35
 
@@ -58,6 +62,8 @@ handlers:
58
62
  behavior: log
59
63
  ```
60
64
 
65
+ ### Environments
66
+
61
67
  Multiple environments need to be handled in a nested list. This example
62
68
  raises exceptions in the test environment, but logs in other environments
63
69
 
@@ -70,6 +76,8 @@ handlers:
70
76
  behavior: log
71
77
  ```
72
78
 
79
+ ### Sources
80
+
73
81
  This example raises exceptions for Ruby deprecations, but ignores Rails
74
82
  deprecations:
75
83
 
@@ -98,20 +106,96 @@ No matter what order you have the behaviors in, a `raise` behavior will be
98
106
  executed last so that the other behaviors happen before the exception is
99
107
  invoked.
100
108
 
101
- The attribute `backtrace_lines` can be used to print extra lines of the
102
- backtrace to the output for the `log`, `stderr`, and `stdout` behaviors.
103
- Currently, it's one attribute that applies to all behaviors. This can be
104
- useful, especially if the direct cause of the issue is in a gem.
109
+ ### Message Formatters
110
+
111
+ Message formatters can affect how and what data is passed to the output
112
+ channel. You can define one handler:
105
113
 
106
114
  ```yaml
107
115
  handlers:
108
116
  - environment: all
109
- backtrace_lines: 5
110
- behaviors:
117
+ behavior: log
118
+ message_formatter:
119
+ backtrace_lines: 3
120
+ format: hash
121
+ filter_backtrace: filter_internals
122
+ ```
123
+
124
+ There are a few attributes of message formatter that you can set
125
+
126
+ * `backtrace_lines` is the number of filtered lines of backtrace, after the
127
+ current line, that are sent to the output. The default is zero. (For
128
+ raising exceptions, the default is the entire backtrace).
129
+ * `format` can be `text`, `json`, `hash`, or `yaml`. Non text formats are
130
+ hashes with keys `message` and `backtrace`, with the `json` and `yaml`
131
+ formats converted to strings in those formats.
132
+ * `filter_backtrace` has three settings. The default is `yes`, which filters
133
+ out Ruby internals, references to warning signs itself, and lines from
134
+ gems. To not filter at all, say `no`. To filter internals but not gems,
135
+ say `filter_internals`.
136
+
137
+ If a message formatter is not specified, the default is a hash with zero
138
+ backtrace lines.
139
+
140
+ Or you can define multiple message formatters. These can separate format
141
+ based on output behavior.
142
+
143
+ In this example, `log` behaviors are sent in hash format, while `stderr`
144
+ behaviors are sent in `text` format. Instead of an `only` list, an `except`
145
+ list can be specified.
146
+
147
+ ```yaml
148
+ handlers:
149
+ - environment: all
150
+ behaviors:
151
+ - log
152
+ - stderr
111
153
  - raise
154
+ message_formatters:
155
+ - backtrace_lines: 3
156
+ format: hash
157
+ behaviors:
158
+ only:
159
+ - log
160
+ - backtrace_lines: 3
161
+ format: text
162
+ behaviors:
163
+ only:
164
+ - stderr
165
+ ```
166
+
167
+ You can also define multiple message formatters based on environment.
168
+
169
+ In this case, logs in production get hash format, while logs in development
170
+ get yaml format.
171
+
172
+ ```yaml
173
+ handlers:
174
+ - environment: all
175
+ behaviors:
112
176
  - log
177
+ message_formatters:
178
+ - backtrace_lines: 3
179
+ format: hash
180
+ environments:
181
+ only:
182
+ - production
183
+ - backtrace_lines: 3
184
+ format: yaml
185
+ environments:
186
+ only:
187
+ - development
113
188
  ```
114
189
 
190
+ Environments can also be listed negatively with `except`.
191
+
192
+ Environment and behavior matching can be used together.
193
+
194
+ If no message formatter matches a given message, the default is text format
195
+ with no backtrace lines.
196
+
197
+ ### Pattern Matching
198
+
115
199
  A common pattern is to focus only on specific deprecations and ignore others.
116
200
  For example, this setting file would raise on Ruby keyword argument
117
201
  deprecations and ignore other ruby deprecations
@@ -165,6 +249,8 @@ handlers:
165
249
  behavior: log
166
250
  ```
167
251
 
252
+ ### Ruby Warning Types
253
+
168
254
  Ruby warnings can have an optional category, there are two predefined
169
255
  categories, `deprecated` and `experimental`. You can specify a handler to
170
256
  match those categories based on an "only" or "except" matcher. If you want
@@ -193,7 +279,3 @@ handlers:
193
279
  - blank
194
280
  behavior: log
195
281
  ```
196
-
197
- ## To Do:
198
-
199
- * Ability to customize output message format
@@ -0,0 +1,28 @@
1
+ module WarningSigns
2
+ module Behavior
3
+ class Base
4
+ attr_reader :message_formatter, :message, :backtrace
5
+
6
+ def self.for(behavior_type, *args)
7
+ class_name = "WarningSigns::Behavior::#{behavior_type.classify}"
8
+ class_name.constantize.new(*args)
9
+ end
10
+
11
+ def initialize(message, backtrace, message_formatter)
12
+ @message = message
13
+ @backtrace = backtrace
14
+ @message_formatter = message_formatter
15
+ end
16
+
17
+ def formatted_message
18
+ result = message_formatter.format_message(message, backtrace)
19
+ result = [result] unless result.is_a?(Array)
20
+ result
21
+ end
22
+
23
+ def emit
24
+ raise NotImplementedError
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,9 @@
1
+ module WarningSigns
2
+ module Behavior
3
+ class Ignore < Base
4
+ def emit
5
+ # no-op
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module WarningSigns
2
+ module Behavior
3
+ class Log < Base
4
+ def emit
5
+ formatted_message.each { Rails.logger.warn(_1) }
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ module WarningSigns
2
+ module Behavior
3
+ class Raise < Base
4
+ def filtered_backtrace
5
+ return backtrace if message_formatter.backtrace_lines.zero?
6
+ message_formatter.filtered_backtrace(backtrace)
7
+ end
8
+
9
+ def emit
10
+ raise UnhandledDeprecationError,
11
+ formatted_message.first,
12
+ filtered_backtrace[1..].map(&:to_s)
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,11 @@
1
+ # standard:disable Style/StderrPuts
2
+ module WarningSigns
3
+ module Behavior
4
+ class Stderr < Base
5
+ def emit
6
+ formatted_message.each { $stderr.puts(_1) }
7
+ end
8
+ end
9
+ end
10
+ end
11
+ # standard:enable Style/StderrPuts
@@ -0,0 +1,11 @@
1
+ # standard:disable Style/StdoutPuts
2
+ module WarningSigns
3
+ module Behavior
4
+ class Stdout < Base
5
+ def emit
6
+ formatted_message.each { $stdout.puts(_1) }
7
+ end
8
+ end
9
+ end
10
+ end
11
+ # standard:enable Style/StdoutPuts
@@ -0,0 +1,20 @@
1
+ module WarningSigns
2
+ module CallerHelper
3
+ def caller_filtered
4
+ caller.reject do |location|
5
+ ignore_line(location.to_s)
6
+ end
7
+ end
8
+
9
+ def ignore_line(line, filter_backtraces: "yes".inquiry)
10
+ return false if filter_backtraces.no?
11
+ partial_result = line.include?("<internal:") ||
12
+ line.include?("warning_signs/lib") ||
13
+ line.include?("warning_signs/spec")
14
+ return partial_result if filter_backtraces.filter_internals?
15
+ partial_result ||
16
+ line.include?("rubygems") ||
17
+ line.include?("/gems")
18
+ end
19
+ end
20
+ end
@@ -2,17 +2,21 @@ module WarningSigns
2
2
  class Deprecation
3
3
  attr_accessor :message, :source, :category, :backtrace
4
4
 
5
- def initialize(message, source:, category: nil, backtrace: nil)
5
+ def initialize(message, source:, category: nil, backtrace: [])
6
6
  @message = message
7
7
  @source = source.to_s.downcase.inquiry
8
8
  @category = category
9
- @backtrace = backtrace
9
+ @backtrace = backtrace || []
10
10
  end
11
11
 
12
12
  def handler
13
13
  World.instance.handler_for(self)
14
14
  end
15
15
 
16
+ def message_formatter_for(behavior)
17
+ handler.message_formatter_for(behavior)
18
+ end
19
+
16
20
  # force raise to be the last element if it is present
17
21
  def behaviors
18
22
  result = (handler&.environment&.behaviors || []).inquiry
@@ -20,27 +24,14 @@ module WarningSigns
20
24
  (result - ["raise"]) << "raise"
21
25
  end
22
26
 
23
- def backtrace_lines
24
- lines = handler&.backtrace_lines || 0
25
- return "" if lines.zero?
26
- backtrace[1..lines].join("\n")
27
- end
28
-
29
27
  def invoke
30
- behaviors.each do |behavior|
31
- case behavior
32
- when "raise"
33
- raise UnhandledDeprecationError, message
34
- when "log"
35
- Rails.logger.warn(message)
36
- backtrace_lines.split("\n").each { Rails.logger.warn(_1) }
37
- when "stderr"
38
- $stderr.puts(message) # standard:disable Style/StderrPuts
39
- $stderr.puts(backtrace_lines) # standard:disable Style/StderrPuts
40
- when "stdout"
41
- $stdout.puts(message) # standard:disable Style/StdoutPuts
42
- $stdout.puts(backtrace_lines) # standard:disable Style/StdoutPuts
43
- end
28
+ behaviors.each do |behavior_type|
29
+ Behavior::Base.for(
30
+ behavior_type,
31
+ message,
32
+ backtrace,
33
+ message_formatter_for(behavior_type)
34
+ ).emit
44
35
  end
45
36
  end
46
37
  end
@@ -1,7 +1,7 @@
1
1
  module WarningSigns
2
2
  class Handler
3
- attr_accessor :environments, :except, :only, :source,
4
- :category_matcher, :backtrace_lines
3
+ attr_accessor :environments, :only_except, :source,
4
+ :category_matcher, :backtrace_lines, :message_formatters
5
5
 
6
6
  def self.from_hash(hash)
7
7
  new(**hash.symbolize_keys)
@@ -16,28 +16,47 @@ module WarningSigns
16
16
  source: "any",
17
17
  environments: [],
18
18
  ruby_warnings: {},
19
- backtrace_lines: 0
19
+ message_formatter: nil,
20
+ message_formatters: []
20
21
  )
21
- @except = except.map { Pattern.for(_1) }
22
- @only = only.map { Pattern.for(_1) }
22
+ @only_except = OnlyExcept.new(
23
+ only: only.map { Pattern.for(_1) },
24
+ except: except.map { Pattern.for(_1) }
25
+ )
23
26
  @environments = environments.map { Environment.new(**_1.symbolize_keys) }
24
27
  if environment.present?
25
- @environments << Environment.new(environment: environment, behaviors: behaviors, behavior: behavior)
28
+ @environments << Environment.new(
29
+ environment: environment,
30
+ behaviors: behaviors,
31
+ behavior: behavior
32
+ )
26
33
  end
27
34
  @source = source.to_s.downcase.inquiry
28
35
  @category_matcher = RubyCategoryMatcher.new(**ruby_warnings.symbolize_keys)
29
- @backtrace_lines = backtrace_lines
36
+ @message_formatters = MessageFormatterList.new(
37
+ message_formatters: message_formatters,
38
+ message_formatter: message_formatter
39
+ )
30
40
  raise InvalidHandlerError unless valid?
31
41
  end
32
42
 
43
+ def message_formatter_for(behavior)
44
+ message_formatters.behavior_match(behavior) ||
45
+ MessageFormatter::Text.new
46
+ end
47
+
33
48
  def valid?
34
- except.empty? || only.empty?
49
+ only_except.valid?
35
50
  end
36
51
 
37
52
  def known_source?(deprecation_source)
38
53
  deprecation_source.in?(%w[ruby rails])
39
54
  end
40
55
 
56
+ def pattern_match?(message)
57
+ only_except.only_except_match?(message)
58
+ end
59
+
41
60
  def match?(deprecation)
42
61
  source_match?(deprecation.source) &&
43
62
  pattern_match?(deprecation.message) &&
@@ -48,29 +67,11 @@ module WarningSigns
48
67
  category_matcher.match?(category)
49
68
  end
50
69
 
51
- def pattern_match?(message)
52
- only_match?(message) && except_match?(message)
53
- end
54
-
55
70
  def source_match?(deprecation_source)
56
71
  return known_source?(deprecation_source) if source.any?
57
72
  source == deprecation_source
58
73
  end
59
74
 
60
- def only_match?(message)
61
- return true if only.empty?
62
- only.any? do |only_pattern|
63
- only_pattern.match?(message)
64
- end
65
- end
66
-
67
- def except_match?(message)
68
- return true if except.empty?
69
- except.none? do |except_pattern|
70
- except_pattern.match?(message)
71
- end
72
- end
73
-
74
75
  def enabled_for_ruby?
75
76
  source.ruby? || source.all?
76
77
  end
@@ -0,0 +1,39 @@
1
+ module WarningSigns
2
+ module MessageFormatter
3
+ class Base
4
+ include CallerHelper
5
+ attr_reader :backtrace_lines, :behaviors, :environments, :filter_backtraces
6
+
7
+ def self.for(**args)
8
+ args = args.symbolize_keys
9
+ type = args.delete(:format) || "text"
10
+ class_name = "WarningSigns::MessageFormatter::#{type.classify}"
11
+ class_name.constantize.new(**args)
12
+ end
13
+
14
+ def initialize(backtrace_lines: 0, behaviors: {}, environments: {}, filter_backtraces: "yes")
15
+ @backtrace_lines = backtrace_lines
16
+ @behaviors = OnlyExcept.new(**behaviors.symbolize_keys)
17
+ @environments = OnlyExcept.new(**environments.symbolize_keys)
18
+ @filter_backtraces = filter_backtraces.to_s.downcase.inquiry
19
+ end
20
+
21
+ def format_message(message, backtrace)
22
+ raise NotImplementedError
23
+ end
24
+
25
+ def filtered_backtrace(backtrace)
26
+ return [] if backtrace.nil?
27
+ result = backtrace.reject do |location|
28
+ ignore_line(location.to_s, filter_backtraces: filter_backtraces)
29
+ end
30
+ result.empty? ? backtrace : result
31
+ end
32
+
33
+ def filtered_backtrace_lines(backtrace)
34
+ return [] if backtrace_lines.zero?
35
+ filtered_backtrace(backtrace)[1..backtrace_lines] || []
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,12 @@
1
+ module WarningSigns
2
+ module MessageFormatter
3
+ class Hash < Base
4
+ def format_message(message, backtrace)
5
+ {
6
+ message: message,
7
+ backtrace: filtered_backtrace_lines(backtrace).map(&:to_s)
8
+ }
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ module WarningSigns
2
+ module MessageFormatter
3
+ class Json < Base
4
+ def format_message(message, backtrace)
5
+ {
6
+ message: message,
7
+ backtrace: filtered_backtrace_lines(backtrace).map(&:to_s)
8
+ }.to_json
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,9 @@
1
+ module WarningSigns
2
+ module MessageFormatter
3
+ class Text < Base
4
+ def format_message(message, backtrace)
5
+ [message] + filtered_backtrace_lines(backtrace)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ module WarningSigns
2
+ module MessageFormatter
3
+ class Yaml < Base
4
+ def format_message(message, backtrace)
5
+ {
6
+ message: message,
7
+ backtrace: filtered_backtrace_lines(backtrace).map(&:to_s)
8
+ }.to_yaml
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ module WarningSigns
2
+ class MessageFormatterList
3
+ include Enumerable
4
+
5
+ attr_reader :message_formatters
6
+
7
+ def initialize(message_formatters: [], message_formatter: nil)
8
+ @message_formatters = message_formatters.map do
9
+ MessageFormatter::Base.for(**_1)
10
+ end
11
+ @message_formatters << MessageFormatter::Base.for(**message_formatter) if message_formatter
12
+ end
13
+
14
+ def each(&block)
15
+ message_formatters.each(&block)
16
+ end
17
+
18
+ def behavior_match(behavior)
19
+ message_formatters.find do
20
+ _1.behaviors.only_except_match?(behavior) &&
21
+ _1.environments.only_except_match?(Rails.env)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ module WarningSigns
2
+ class OnlyExcept
3
+ attr_accessor :only, :except
4
+
5
+ def initialize(only: [], except: [])
6
+ @only = only
7
+ @except = except
8
+ end
9
+
10
+ def only_except_match?(message)
11
+ only_match?(message) && except_match?(message)
12
+ end
13
+
14
+ def only_match?(message)
15
+ return true if only.empty?
16
+ only.any? do |only_pattern|
17
+ only_pattern.match?(message)
18
+ end
19
+ end
20
+
21
+ def except_match?(message)
22
+ return true if except.empty?
23
+ except.none? do |except_pattern|
24
+ except_pattern.match?(message)
25
+ end
26
+ end
27
+
28
+ def valid?
29
+ except.empty? || only.empty?
30
+ end
31
+ end
32
+ end
@@ -1,13 +1,12 @@
1
1
  module WarningSigns
2
2
  class RailsDeprecationCatcher < ActiveSupport::Subscriber
3
- include CallerLocationHelper
4
3
  attach_to :rails
5
4
 
6
5
  def deprecation(event)
7
6
  Deprecation.new(
8
7
  event.payload[:message],
9
8
  source: "rails",
10
- backtrace: caller_locations[caller_location_start..]
9
+ backtrace: caller
11
10
  ).invoke
12
11
  end
13
12
  end
@@ -1,18 +1,19 @@
1
1
  module WarningSigns
2
2
  module RubyDeprecationCatcher
3
- include CallerLocationHelper
3
+ include CallerHelper
4
+
4
5
  def warn(message, category: nil)
5
6
  Deprecation.new(
6
7
  augmented_message(message, category),
7
8
  source: "ruby",
8
9
  category: category,
9
- backtrace: caller_locations[caller_location_start..]
10
+ backtrace: caller
10
11
  ).invoke
11
12
  end
12
13
 
13
14
  def augmented_message(message, category)
14
15
  category_part = category.present? ? " #{category.upcase}: " : ": "
15
- "RUBY WARNING#{category_part}#{message} called from #{caller_locations[caller_location_start]}"
16
+ "RUBY WARNING#{category_part}#{message} called from #{caller_filtered.first}"
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,9 @@
1
+ module WarningSigns
2
+ class UnhandledDeprecationError < StandardError
3
+ MESSAGE = "This error was raised by the Warning Signs gem in response to a deprecation warning in Ruby or Rails. If this warning is not causing problems, you can add it to the exceptions list in .warning_signs.yml."
4
+
5
+ def message
6
+ super + "\n\n" + MESSAGE
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module WarningSigns
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.1"
3
3
  end
data/lib/warning_signs.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "English"
3
4
  require "yaml"
4
5
  require "rails/railtie"
5
6
  require "active_support/all"
@@ -13,8 +14,6 @@ module WarningSigns
13
14
  SAMPLE_CONSTANT = "foobar"
14
15
 
15
16
  class InvalidHandlerError < StandardError; end
16
-
17
- class UnhandledDeprecationError < StandardError; end
18
17
  end
19
18
 
20
19
  loader.eager_load
@@ -39,5 +39,5 @@ Gem::Specification.new do |spec|
39
39
  spec.add_development_dependency "yard"
40
40
 
41
41
  spec.add_runtime_dependency "awesome_print"
42
- spec.add_runtime_dependency "railties"
42
+ spec.add_runtime_dependency "railties", "<= 7.1.0"
43
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warning_signs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noel Rappin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-12 00:00:00.000000000 Z
11
+ date: 2023-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry-byebug
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: railties
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - "<="
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 7.1.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - "<="
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 7.1.0
153
153
  description: A gem for managing ruby and rails deprecation warnings
154
154
  email:
155
155
  - noelrap@hey.com
@@ -170,10 +170,23 @@ files:
170
170
  - bin/console
171
171
  - bin/setup
172
172
  - lib/warning_signs.rb
173
- - lib/warning_signs/caller_location_helper.rb
173
+ - lib/warning_signs/behavior/base.rb
174
+ - lib/warning_signs/behavior/ignore.rb
175
+ - lib/warning_signs/behavior/log.rb
176
+ - lib/warning_signs/behavior/raise.rb
177
+ - lib/warning_signs/behavior/stderr.rb
178
+ - lib/warning_signs/behavior/stdout.rb
179
+ - lib/warning_signs/caller_helper.rb
174
180
  - lib/warning_signs/deprecation.rb
175
181
  - lib/warning_signs/environment.rb
176
182
  - lib/warning_signs/handler.rb
183
+ - lib/warning_signs/message_formatter/base.rb
184
+ - lib/warning_signs/message_formatter/hash.rb
185
+ - lib/warning_signs/message_formatter/json.rb
186
+ - lib/warning_signs/message_formatter/text.rb
187
+ - lib/warning_signs/message_formatter/yaml.rb
188
+ - lib/warning_signs/message_formatter_list.rb
189
+ - lib/warning_signs/only_except.rb
177
190
  - lib/warning_signs/pattern.rb
178
191
  - lib/warning_signs/rails_deprecation_catcher.rb
179
192
  - lib/warning_signs/railtie.rb
@@ -181,6 +194,7 @@ files:
181
194
  - lib/warning_signs/ruby_category_matcher.rb
182
195
  - lib/warning_signs/ruby_deprecation_catcher.rb
183
196
  - lib/warning_signs/string_pattern.rb
197
+ - lib/warning_signs/unhandled_deprecation_error.rb
184
198
  - lib/warning_signs/version.rb
185
199
  - lib/warning_signs/world.rb
186
200
  - warning_signs.gemspec
@@ -1,17 +0,0 @@
1
- module WarningSigns
2
- module CallerLocationHelper
3
- def caller_location_start
4
- caller_locations.find_index do |location|
5
- !ignore_line(location.to_s)
6
- end || 0
7
- end
8
-
9
- def ignore_line(line)
10
- line.include?("<internal:") ||
11
- line.include?("warning_signs/lib") ||
12
- line.include?("warning_signs/spec") ||
13
- line.include?("rubygems") ||
14
- line.include?("/gems")
15
- end
16
- end
17
- end