Class: Debase::FileFilter

Inherits:
Object show all
Defined in:
lib/debase.rb

Instance Method Summary collapse

Constructor Details

#initializeFileFilter

Returns a new instance of FileFilter.



87
88
89
# File 'lib/debase.rb', line 87

def initialize
  @enabled = false
end

Instance Method Details

#accept?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


109
110
111
112
113
# File 'lib/debase.rb', line 109

def accept?(file_path)
  return true unless @enabled
  return false if file_path.nil?
  included.any? { |path| file_path.start_with?(path) } && excluded.all? { |path| !file_path.start_with?(path)}
end

#disableObject



104
105
106
107
# File 'lib/debase.rb', line 104

def disable
  @enabled = false
  Debase.enable_file_filtering(@enabled);
end

#enableObject



99
100
101
102
# File 'lib/debase.rb', line 99

def enable
  @enabled = true
  Debase.enable_file_filtering(@enabled);
end

#exclude(file_path) ⇒ Object



95
96
97
# File 'lib/debase.rb', line 95

def exclude(file_path)
  excluded << file_path unless included.delete(file_path)
end

#include(file_path) ⇒ Object



91
92
93
# File 'lib/debase.rb', line 91

def include(file_path)
  included << file_path unless excluded.delete(file_path)
end