class Fire::FileState
File state.
Attributes
pattern[R]
File glob or regular expression.
Public Class Methods
new(pattern, digest, ignore)
click to toggle source
Initialize new instance of Autologic.
pattern - File glob or regular expression. [String,Regexp] digest - ignore -
# File lib/fire/state.rb, line 54 def initialize(pattern, digest, ignore) @pattern = pattern @digest = digest @ignore = ignore end
Public Instance Methods
call()
click to toggle source
Process logic.
# File lib/fire/state.rb, line 66 def call result = [] case pattern when Regexp @digest.current.keys.each do |fname| if md = pattern.match(fname) if @digest.current[fname] != @digest.saved[fname] result << Match.new(fname, md) end end end else # TODO: if fnmatch? worked like glob then we'd follow the same code as for regexp list = Dir[pattern].reject{ |path| @ignore.any?{ |ig| /^#{ig}/ =~ path } } list.each do |fname| if @digest.current[fname] != @digest.saved[fname] result << fname end end end result end