Class: Sublayer::Triggers::FileChange
- Defined in:
- lib/sublayer/triggers/file_change.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ FileChange
constructor
A new instance of FileChange.
- #setup(agent) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(&block) ⇒ FileChange
Returns a new instance of FileChange.
4 5 6 |
# File 'lib/sublayer/triggers/file_change.rb', line 4 def initialize(&block) @block = block end |
Instance Method Details
#setup(agent) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'lib/sublayer/triggers/file_change.rb', line 8 def setup(agent) files_to_watch = agent.instance_eval(&@block) folders = files_to_watch.map { |file| File.dirname(File.(file)) }.uniq Listen.to(*folders) do |modified, added, removed| if files_to_watch.any? { |file| modified.include?(File.(file)) } activate(agent) end end.start end |