Module: DeprecationCollector::MultipartWarningJoiner
- Defined in:
- lib/deprecation_collector/collectors.rb
Overview
Ruby sometimes has two warnings for one actual occurence Example: caller.rb:1: warning: Passing the keyword argument as the last hash parameter is deprecated calleee.rb:1: warning: The called method ‘method_name’ is defined here
Class Method Summary collapse
Class Method Details
.handle(new_str) {|new_str| ... } ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/deprecation_collector/collectors.rb', line 94 def handle(new_str) old_str = Thread.current[:multipart_warning_str] Thread.current[:multipart_warning_str] = nil if old_str return yield(old_str + new_str) if new_str.include?("is defined here") || new_str.include?(" was here") yield(old_str) end return (Thread.current[:multipart_warning_str] = new_str) if two_part_warning?(new_str) yield(new_str) end |
.two_part_warning?(str) ⇒ Boolean
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/deprecation_collector/collectors.rb', line 81 def two_part_warning?(str) # see ruby src - `rb_warn`, `rb_compile_warn` str.end_with?( "uses the deprecated method signature, which takes one parameter\n", # respond_to? # 2.7 kwargs: "maybe ** should be added to the call\n", "Passing the keyword argument as the last hash parameter is deprecated\n", # бывает и не двойной "Splitting the last argument into positional and keyword parameters is deprecated\n" ) || str.include?("warning: already initialized constant") || str.include?("warning: method redefined; discarding old") end |