Module: Uncruft::Warning

Defined in:
lib/uncruft/warning.rb

Constant Summary collapse

DEPRECATION_PATTERN =
/(deprecation|deprecated)/i

Instance Method Summary collapse

Instance Method Details

#warn(*args, **kwargs) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/uncruft/warning.rb', line 7

def warn(*args, **kwargs)
  str = args[0]

  if str =~ DEPRECATION_PATTERN # rubocop:disable Performance/RegexpMatch
    message = strip_caller_info(str, caller_locations(1..1).first).strip
    Uncruft.deprecator.warn(message)
  else
    super
  end
end