Sha256: 1df4bbe3758dad98db57a02661e4077c7b6a4289b9b8a0f5b5e0ffa03929a32b

Contents?: true

Size: 714 Bytes

Versions: 2

Compression:

Stored size: 714 Bytes

Contents

# frozen_string_literal: true
require 'as_deprecation_tracker/whitelist_entry'

module ASDeprecationTracker
  # Stores a list of known and ignored deprecation warnings, and provides a
  # query interface to check if a warning matches the list
  class Whitelist
    attr_reader :list

    def initialize
      @list = []
    end

    def add_to_list(*entries)
      entries.flatten.each { |entry| @list << WhitelistEntry.new(entry.symbolize_keys) }
    end
    alias add add_to_list

    def clear
      @list.clear
    end

    def load_file(path)
      add_to_list(YAML.load(File.read(path)) || [])
    end

    def matches?(deprecation)
      @list.any? { |entry| entry.matches?(deprecation) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
as_deprecation_tracker-1.5.0 lib/as_deprecation_tracker/whitelist.rb
as_deprecation_tracker-1.4.1 lib/as_deprecation_tracker/whitelist.rb