Sha256: 4ebed5f5e528bd4f3f7a1d68d2dfd957294f72b897745edb238a68e252de8cf7
Contents?: true
Size: 599 Bytes
Versions: 1
Compression:
Stored size: 599 Bytes
Contents
# frozen_string_literal: true require "listen" module Attractor # functionality for watching file system changes class Watcher def initialize(file_prefix, callback) @file_prefix = file_prefix @callback = callback end def watch @callback.call listener = Listen.to(File.absolute_path(@file_prefix), ignore: /^attractor_output/) do |modified, _added, _removed| if modified puts "#{modified.map(&:to_s).join(', ')} modified, recalculating..." @callback.call end end listener.start sleep end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
attractor-2.0.5 | lib/attractor/watcher.rb |