Stand-alone deprecation library borrowed from ActiveSupport::Deprecation
Ruby
Latest commit a22edb9 Jul 13, 2016 @cbeer committed on GitHub Merge pull request #10 from cbeer/cbeer-patch-1
Update travis build matrix

README.md

Deprecation

Build Status

Provide deprecation warnings for code

Add warnings

class DeprecatedModule
  extend Deprecation
  self.deprecation_horizon = 'my_gem version 3.0.0'

  def asdf

  end
  deprecation_deprecate :asdf

  def custom_deprecation *args
    Deprecation.warn(DeprecatedModule, "don't do that!") if args.length < 15
  end

end

DeprecatedModule.new.asdf
DEPRECATION WARNING: asdf is deprecated and will be removed from my_gem version 3.0.0. (called from irb_binding at (irb):18)
=> nil

Silence warnings

  def silence_asdf_warning
     Deprecation.silence(DeprecationModule) do
       asdf
     end
  end

Reporting

Deprecation.default_deprecation_behavior = :stderr # the default

Deprecation.default_deprecation_behavior = :log # put deprecation warnings into the Rails / ActiveSupport log

DeprecationModule.debug = true # put the full callstack in the logged message

Deprecation.default_deprecation_behavior = :notify # use ActiveSupport::Notifications to log the message

Deprecation.default_deprecation_behavior = :raise # Raise an exception when using deprecated behavior

Deprecation.default_deprecation_behavior = :silence # ignore all deprecations