Module: Hoe::Halostatue::StrictWarnings

Defined in:
lib/hoe/halostatue/strict_warnings.rb

Overview

:nodoc:

Constant Summary collapse

WarningError =
Class.new(StandardError)

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.allowedObject

Returns the value of attribute allowed.



9
10
11
# File 'lib/hoe/halostatue/strict_warnings.rb', line 9

def allowed
  @allowed
end

.project_rootObject

Returns the value of attribute project_root.



8
9
10
# File 'lib/hoe/halostatue/strict_warnings.rb', line 8

def project_root
  @project_root
end

.suppressedObject

Returns the value of attribute suppressed.



10
11
12
# File 'lib/hoe/halostatue/strict_warnings.rb', line 10

def suppressed
  @suppressed
end

Instance Method Details

#warn(message) ⇒ Object

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/hoe/halostatue/strict_warnings.rb', line 23

def warn(message, ...)
  pattern = Hoe::Halostatue::StrictWarnings.suppressed
  return if pattern&.match?(message)

  super

  return unless ENV["STRICT_WARNINGS"] || ENV["CI"]

  project_root = Hoe::Halostatue::StrictWarnings.project_root
  return if project_root && !message.include?(project_root)

  pattern = Hoe::Halostatue::StrictWarnings.allowed
  return if pattern&.match?(message)

  raise WarningError.new(message)
end