Sha256: c7a8eafbe7c6a71250a4ab332e37fbcb8c2c885c7ad48193b0ad9f1abf6f68e3
Contents?: true
Size: 1.12 KB
Versions: 8
Compression:
Stored size: 1.12 KB
Contents
module Mutant # Stream filter for warnings class WarningFilter include Equalizer.new(:target) WARNING_PATTERN = /\A(?:.+):(?:\d+): warning: (?:.+)\n\z/ # Initialize object # # @param [#write] target # # @return [undefined] def initialize(target) @target = target @warnings = [] end # Warnings captured by filter # # @return [Array<String>] attr_reader :warnings # Target stream to capture warnings on # # @return [#write] target # # @return [undefined] attr_reader :target protected :target # Write message to target filtering warnings # # @param [String] message # # @return [self] def write(message) if WARNING_PATTERN =~ message warnings << message else target.write(message) end self end # Use warning filter during block execution # # @return [Array<String>] def self.use original = $stderr $stderr = filter = new(original) yield filter.warnings ensure $stderr = original end end # WarningFilter end # Mutant
Version data entries
8 entries across 8 versions & 1 rubygems