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.



116
117
118
# File 'lib/debase.rb', line 116

def initialize
  @enabled = false
end

Instance Method Details

#accept?(file_path) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

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

#enableObject



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

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

#exclude(file_path) ⇒ Object



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

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

#include(file_path) ⇒ Object



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

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