Class: Mutant::WarningFilter
- Inherits:
-
Object
- Object
- Mutant::WarningFilter
- Defined in:
- lib/mutant/warning_filter.rb
Overview
Stream filter for warnings
Constant Summary collapse
- WARNING_PATTERN =
/\A(?:.+):(?:\d+): warning: (?:.+)\n\z/
Instance Attribute Summary collapse
-
#warnings ⇒ Array<String>
readonly
private
Warnings captured by filter.
Class Method Summary collapse
-
.use ⇒ Array<String>
private
Use warning filter during block execution.
Instance Method Summary collapse
-
#initialize(target) ⇒ undefined
constructor
private
Initialize object.
-
#write(message) ⇒ self
private
Write message to target filtering warnings.
Constructor Details
#initialize(target) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
15 16 17 18 |
# File 'lib/mutant/warning_filter.rb', line 15 def initialize(target) @target = target @warnings = [] end |
Instance Attribute Details
#warnings ⇒ Array<String> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Warnings captured by filter
25 26 27 |
# File 'lib/mutant/warning_filter.rb', line 25 def warnings @warnings end |
Class Method Details
.use ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Use warning filter during block execution
59 60 61 62 63 64 65 66 |
# File 'lib/mutant/warning_filter.rb', line 59 def self.use original = $stderr $stderr = filter = new(original) yield filter.warnings ensure $stderr = original end |
Instance Method Details
#write(message) ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Write message to target filtering warnings
44 45 46 47 48 49 50 51 52 |
# File 'lib/mutant/warning_filter.rb', line 44 def write() if WARNING_PATTERN =~ warnings << else target.write() end self end |