Class: FileMonitorFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/file-monitor.rb

Instance Method Summary collapse

Constructor Details

#initializeFileMonitorFilter

Returns a new instance of FileMonitorFilter.



7
8
9
# File 'lib/file-monitor.rb', line 7

def initialize
  @patterns = []
end

Instance Method Details

#allow(pattern) ⇒ Object Also known as: a



27
28
29
# File 'lib/file-monitor.rb', line 27

def allow(pattern)
  @patterns << [:allow, pattern]
end

#disallow(pattern) ⇒ Object Also known as: d



23
24
25
# File 'lib/file-monitor.rb', line 23

def disallow(pattern)
  @patterns << [:disallow, pattern]
end

#ignored?(path) ⇒ Boolean Also known as: disallow?

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
# File 'lib/file-monitor.rb', line 11

def ignored?(path)
  status = :allow
  for mode, pattern in @patterns
    if path =~ pattern
      status = mode
    end
  end
  return status == :disallow
end

#resetObject



31
32
33
# File 'lib/file-monitor.rb', line 31

def reset
  @patterns = []
end