Class: ASDeprecationTracker::Whitelist

Inherits:
Object
  • Object
show all
Defined in:
lib/as_deprecation_tracker/whitelist.rb

Overview

Stores a list of known and ignored deprecation warnings, and provides a query interface to check if a warning matches the list

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWhitelist

Returns a new instance of Whitelist.



11
12
13
# File 'lib/as_deprecation_tracker/whitelist.rb', line 11

def initialize
  @list = []
end

Instance Attribute Details

#listObject (readonly)

Returns the value of attribute list.



9
10
11
# File 'lib/as_deprecation_tracker/whitelist.rb', line 9

def list
  @list
end

Instance Method Details

#add_to_list(*entries) ⇒ Object Also known as: add



15
16
17
# File 'lib/as_deprecation_tracker/whitelist.rb', line 15

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

#clearObject



20
21
22
# File 'lib/as_deprecation_tracker/whitelist.rb', line 20

def clear
  @list.clear
end

#load_file(path) ⇒ Object



24
25
26
# File 'lib/as_deprecation_tracker/whitelist.rb', line 24

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

#matches?(deprecation) ⇒ Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/as_deprecation_tracker/whitelist.rb', line 28

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