Module: Warnings Private

Defined in:
warnings.rb

Overview

This module is part of a private API. This module may only be used in the Homebrew/brew repository. Third parties should avoid using this module if possible, as it may be removed or changed without warning.

Helper module for handling warnings.

Class Method Summary collapse

Class Method Details

.ignore(*warnings, &_block) ⇒ void

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.

Parameters:

  • warnings (Symbol, Regexp)
  • _block (T.proc.void)


28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'warnings.rb', line 28

def self.ignore(*warnings, &_block)
  warnings = warnings.flat_map do |warning|
    warning.is_a?(Symbol) ? COMMON_WARNINGS.fetch(warning) : warning
  end

  previous_warnings = ignored_warnings
  Thread.current.thread_variable_set(IGNORED_WARNINGS_KEY, previous_warnings + warnings)
  begin
    yield
  ensure
    Thread.current.thread_variable_set(IGNORED_WARNINGS_KEY, previous_warnings)
  end
end

.ignored?(message) ⇒ Boolean

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

Parameters:

Returns:

  • (Boolean)


43
44
45
# File 'warnings.rb', line 43

def self.ignored?(message)
  ignored_warnings.any? { |warning| warning.match?(message) }
end