Class: Fire::FileState
Overview
File state.
Instance Attribute Summary collapse
-
#pattern ⇒ Object
readonly
File glob or regular expression.
Instance Method Summary collapse
-
#call ⇒ Object
Process logic.
-
#initialize(pattern, digest, ignore) ⇒ FileState
constructor
Initialize new instance of Autologic.
Methods inherited from State
Constructor Details
#initialize(pattern, digest, ignore) ⇒ FileState
Initialize new instance of Autologic.
54 55 56 57 58 |
# File 'lib/fire/state.rb', line 54 def initialize(pattern, digest, ignore) @pattern = pattern @digest = digest @ignore = ignore end |
Instance Attribute Details
#pattern ⇒ Object (readonly)
File glob or regular expression.
61 62 63 |
# File 'lib/fire/state.rb', line 61 def pattern @pattern end |
Instance Method Details
#call ⇒ Object
Process logic.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# 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 |