Class: CodeownerValidator::Lists::Whitelist
- Inherits:
-
Object
- Object
- CodeownerValidator::Lists::Whitelist
- Defined in:
- lib/codeowner_validator/lists/whitelist.rb
Overview
Manage whitelist file reading
Instance Attribute Summary collapse
-
#repo_path ⇒ Object
readonly
Returns the value of attribute repo_path.
Instance Method Summary collapse
-
#exist? ⇒ true
Public: Checks for existence configuration for the whitelist.
-
#initialize(filename: nil, repo_path: nil) ⇒ Whitelist
constructor
Public: Initialized with a provided file.
-
#to_proc ⇒ Object
add a ‘to_proc` method that allows instances of this class to be passed as a block for easier chaining executions.
-
#whitelisted?(filename) ⇒ true
Public: Returns <true> if the file supplied has been whitelisted; otherwise, <false>.
Constructor Details
#initialize(filename: nil, repo_path: nil) ⇒ Whitelist
Public: Initialized with a provided file
13 14 15 16 17 18 19 20 21 |
# File 'lib/codeowner_validator/lists/whitelist.rb', line 13 def initialize(filename: nil, repo_path: nil) @filename = filename @repo_path = repo_path # to avoid instance variable not initialized warnings @whitelist_file = nil @whitelist_file_paths = nil @git_ignore_file = nil end |
Instance Attribute Details
#repo_path ⇒ Object (readonly)
Returns the value of attribute repo_path.
7 8 9 |
# File 'lib/codeowner_validator/lists/whitelist.rb', line 7 def repo_path @repo_path end |
Instance Method Details
#exist? ⇒ true
Public: Checks for existence configuration for the whitelist
26 27 28 |
# File 'lib/codeowner_validator/lists/whitelist.rb', line 26 def exist? !pathspec.empty? end |
#to_proc ⇒ Object
add a ‘to_proc` method that allows instances of this class to be passed as a block for easier chaining executions
43 44 45 |
# File 'lib/codeowner_validator/lists/whitelist.rb', line 43 def to_proc proc { |item| whitelisted?(item) } end |
#whitelisted?(filename) ⇒ true
Public: Returns <true> if the file supplied has been whitelisted; otherwise, <false>
34 35 36 37 38 39 |
# File 'lib/codeowner_validator/lists/whitelist.rb', line 34 def whitelisted?(filename) # if no items in the whitelist, assume all items are whitelisted return true if pathspec.empty? listed?(filename) end |