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.



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

def initialize
  @patterns = []
end

Instance Method Details

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



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

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

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



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

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

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

Returns:

  • (Boolean)


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

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

#resetObject



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

def reset
  @patterns = []
end

#to_sObject



36
37
38
39
40
41
42
# File 'lib/file-monitor.rb', line 36

def to_s
  str = StringIO.new
  for pattern in @patterns
    str.puts "#{pattern[0].to_s} #{pattern[1].inspect}"
  end
  str.string
end