Class: Undercover::FilterSet

Inherits:
Object
  • Object
show all
Defined in:
lib/undercover/filter_set.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(allow_filters, reject_filters) ⇒ FilterSet

Returns a new instance of FilterSet.



7
8
9
10
# File 'lib/undercover/filter_set.rb', line 7

def initialize(allow_filters, reject_filters)
  @allow_filters = allow_filters || []
  @reject_filters = reject_filters || []
end

Instance Attribute Details

#allow_filtersObject (readonly)

Returns the value of attribute allow_filters.



5
6
7
# File 'lib/undercover/filter_set.rb', line 5

def allow_filters
  @allow_filters
end

#reject_filtersObject (readonly)

Returns the value of attribute reject_filters.



5
6
7
# File 'lib/undercover/filter_set.rb', line 5

def reject_filters
  @reject_filters
end

Instance Method Details

#include?(filepath) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/undercover/filter_set.rb', line 12

def include?(filepath)
  fnmatch = proc { |glob| File.fnmatch(glob, filepath) }
  allow_filters.any?(fnmatch) && reject_filters.none?(fnmatch)
end