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

.fail_on(*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, nil)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'warnings.rb', line 48

def self.fail_on(*warnings, &block)
  warnings = expand(warnings)
  unless block
    @fatal_warnings = (@fatal_warnings + warnings).uniq
    return
  end

  previous_warnings = fatal_warnings
  Thread.current.thread_variable_set(FATAL_WARNINGS_KEY, previous_warnings + warnings)
  begin
    yield
  ensure
    Thread.current.thread_variable_set(FATAL_WARNINGS_KEY, previous_warnings)
  end
end

.fatal?(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)


70
71
72
73
# File 'warnings.rb', line 70

def self.fatal?(message)
  @fatal_warnings.any? { |warning| warning.match?(message) } ||
    fatal_warnings.any? { |warning| warning.match?(message) }
end

.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)


35
36
37
38
39
40
41
42
43
44
45
# File 'warnings.rb', line 35

def self.ignore(*warnings, &_block)
  warnings = expand(warnings)

  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)


65
66
67
# File 'warnings.rb', line 65

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