Sha256: fd866268942c37115d2f64fbdce30db0b3fb9927cc1064144dc8472fa77506d3

Contents?: true

Size: 911 Bytes

Versions: 1

Compression:

Stored size: 911 Bytes

Contents

require 'listen/file'
require 'listen/directory'
require 'listen/silencer'

module Listen
  class Change
    include Celluloid

    attr_accessor :listener, :silencer

    def initialize(listener)
      @listener = listener
      @silencer = Silencer.new(listener.options)
    end

    def change(path, options)
      return if silencer.silenced?(path)
      if change = options[:change]
        _notify_listener(change, path)
      else
        send("_#{options[:type].downcase}_change", path, options)
      end
    end

    private

    def _file_change(path, options)
      change = File.new(path).change
      if change && listener.listen? && !options[:silence]
        _notify_listener(change, path)
      end
    end

    def _dir_change(path, options)
      Directory.new(path, options).scan
    end

    def _notify_listener(change, path)
      listener.changes << { change => path }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
listen-2.0.0.beta.1 lib/listen/change.rb