class Mushy::FileWatch

Public Class Methods

details() click to toggle source
# File lib/mushy/fluxs/file_watch.rb, line 7
def self.details
  {
    name: 'FileWatch',
    description: 'Watch for file changes.',
    config: {
      directory: {
                   description: 'The directory to watch.',
                   type:        'text',
                   value:       '',
                 },
    },
  }
end

Public Instance Methods

loop(&block) click to toggle source
# File lib/mushy/fluxs/file_watch.rb, line 21
def loop &block

  directory = config[:directory].to_s != '' ? config[:directory] : Dir.pwd

  listener = Listen.to(directory) do |modified, added, removed|
    the_event = {
                  modified: modified,
                  added: added,
                  removed: removed,
                }
    block.call the_event
  end

  listener.start

  sleep

end
process(event, config) click to toggle source
# File lib/mushy/fluxs/file_watch.rb, line 40
def process event, config
  event
end