Sha256: b33fd5f7749434a2ef3791a7c442c771bc93a69dabf6903bcaca5f57710ee2d8

Contents?: true

Size: 561 Bytes

Versions: 30

Compression:

Stored size: 561 Bytes

Contents

# frozen_string_literal: true

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_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

30 entries across 30 versions & 1 rubygems

Version Path
attractor-2.3.0 lib/attractor/watcher.rb~
attractor-2.2.0 lib/attractor/watcher.rb~
attractor-2.1.0 lib/attractor/watcher.rb~
attractor-2.0.5 lib/attractor/watcher.rb~
attractor-2.0.4 lib/attractor/watcher.rb
attractor-2.0.3 lib/attractor/watcher.rb
attractor-2.0.2 lib/attractor/watcher.rb
attractor-2.0.1 lib/attractor/watcher.rb
attractor-2.0.0 lib/attractor/watcher.rb
attractor-1.2.0 lib/attractor/watcher.rb
attractor-1.1.1 lib/attractor/watcher.rb
attractor-1.1.0 lib/attractor/watcher.rb
attractor-1.0.2 lib/attractor/watcher.rb
attractor-1.0.1 lib/attractor/watcher.rb
attractor-1.0.0 lib/attractor/watcher.rb
attractor-0.6.1 lib/attractor/watcher.rb
attractor-0.6.0 lib/attractor/watcher.rb
attractor-0.5.1 lib/attractor/watcher.rb
attractor-0.5.0 lib/attractor/watcher.rb
attractor-0.4.3 lib/attractor/watcher.rb