module Kernel

Public Instance Methods

deprecated(*messages) click to toggle source

Kernel extension to print deprecation notices.

@example printing a deprecation warning

deprecated 'no longer in use' #=> "[DEPRECATION] no longer in use"

@param [Array<String>] messages

# File lib/chefspec/deprecations.rb, line 8
def deprecated(*messages)
  messages.each do |message|
    calling_spec = caller.find { |line| line =~ %r{(/spec)|(_spec\.rb)} }
    if calling_spec
      calling_spec = "spec/" + calling_spec.split("/spec/").last
      warn "[DEPRECATION] #{message} (called from #{calling_spec})"
    else
      warn "[DEPRECATION] #{message}"
    end
  end
end