Class: DAF::FileUpdateMonitor

Inherits:
Monitor
  • Object
show all
Defined in:
lib/daf/monitors/file_update_monitor.rb

Overview

Monitor that watches a file’s last update time, and triggers when it changes includes several return outputs that can be used as well

Instance Method Summary collapse

Methods inherited from Monitor

#on_trigger

Methods included from Configurable

included

Constructor Details

#initialize(options) ⇒ FileUpdateMonitor

Returns a new instance of FileUpdateMonitor.



21
22
23
# File 'lib/daf/monitors/file_update_monitor.rb', line 21

def initialize(options)
  super
end

Instance Method Details

#block_until_triggeredObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/daf/monitors/file_update_monitor.rb', line 25

def block_until_triggered
  initial_modified_time = File.mtime(@path.value)
  loop do
    sleep @frequency.value
    modified_time = File.mtime(@path.value)
    next unless modified_time > initial_modified_time
    @time = modified_time
    @contents = contents_of_file(@path.value)
    break
  end
end

#contentsString

Returns The contents of the tile that caused trigger.

Returns:

  • (String)

    The contents of the tile that caused trigger



19
# File 'lib/daf/monitors/file_update_monitor.rb', line 19

attr_output :contents, String

#timeTime

Returns The last modified time of file that caused trigger.

Returns:

  • (Time)

    The last modified time of file that caused trigger



16
# File 'lib/daf/monitors/file_update_monitor.rb', line 16

attr_output :time, Time