Class: ASDeprecationTracker::Whitelist
- Inherits:
-
Object
- Object
- ASDeprecationTracker::Whitelist
- 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
-
#list ⇒ Object
readonly
Returns the value of attribute list.
Instance Method Summary collapse
- #add_to_list(*entries) ⇒ Object (also: #add)
- #clear ⇒ Object
-
#initialize ⇒ Whitelist
constructor
A new instance of Whitelist.
- #load_file(path) ⇒ Object
- #matches?(deprecation) ⇒ Boolean
Constructor Details
#initialize ⇒ Whitelist
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
#list ⇒ Object (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 |
#clear ⇒ Object
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
28 29 30 |
# File 'lib/as_deprecation_tracker/whitelist.rb', line 28 def matches?(deprecation) @list.any? { |entry| entry.matches?(deprecation) } end |