Sha256: 3f07cc9b2af5926992e417350ddc532154be60a4c04d55053f049fb0a93e1ad2

Contents?: true

Size: 1.72 KB

Versions: 6

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

require "active_support"

load("tasks/ci_recorder.rake")

module DeprecationToolkit
  autoload :DeprecationSubscriber,     "deprecation_toolkit/deprecation_subscriber"
  autoload :Configuration,             "deprecation_toolkit/configuration"
  autoload :Collector,                 "deprecation_toolkit/collector"
  autoload :ReadWriteHelper,           "deprecation_toolkit/read_write_helper"
  autoload :TestTriggerer,             "deprecation_toolkit/test_triggerer"

  module Behaviors
    autoload :Disabled,                "deprecation_toolkit/behaviors/disabled"
    autoload :Raise,                   "deprecation_toolkit/behaviors/raise"
    autoload :Record,                  "deprecation_toolkit/behaviors/record"
    autoload :CIRecordHelper,          "deprecation_toolkit/behaviors/ci_record_helper"
  end

  class << self
    def add_notify_behavior
      notify = ActiveSupport::Deprecation::DEFAULT_BEHAVIORS[:notify]

      each_deprecator do |deprecator|
        behaviors = deprecator.behavior

        unless behaviors.find { |behavior| behavior == notify }
          deprecator.behavior = (behaviors << notify)
        end
      end
    end

    def attach_subscriber
      return if DeprecationSubscriber.already_attached?

      Configuration.attach_to.each do |gem_name|
        DeprecationSubscriber.attach_to(gem_name)
      end
    end

    private

    def each_deprecator(&block)
      if defined?(Rails.application) && Rails.application.respond_to?(:deprecators)
        Rails.application.deprecators.each(&block)
      else
        block.call(ActiveSupport::Deprecation)
      end
    end
  end
end

require "deprecation_toolkit/minitest_hook" unless defined? RSpec
require "deprecation_toolkit/warning"

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
deprecation_toolkit-2.2.0 lib/deprecation_toolkit.rb
deprecation_toolkit-2.1.0 lib/deprecation_toolkit.rb
deprecation_toolkit-2.0.4 lib/deprecation_toolkit.rb
deprecation_toolkit-2.0.3 lib/deprecation_toolkit.rb
deprecation_toolkit-2.0.2 lib/deprecation_toolkit.rb
deprecation_toolkit-2.0.1 lib/deprecation_toolkit.rb