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.



121
122
123
# File 'lib/debase.rb', line 121

def initialize
  @enabled = false
end

Instance Method Details

#accept?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


143
144
145
146
147
# File 'lib/debase.rb', line 143

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



138
139
140
141
# File 'lib/debase.rb', line 138

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

#enableObject



133
134
135
136
# File 'lib/debase.rb', line 133

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

#exclude(file_path) ⇒ Object



129
130
131
# File 'lib/debase.rb', line 129

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

#include(file_path) ⇒ Object



125
126
127
# File 'lib/debase.rb', line 125

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