Sha256: d1ff3eef1e28476f7f73bdfd20334a151cd21df53951a2f75ae339bdfca98597

Contents?: true

Size: 926 Bytes

Versions: 10

Compression:

Stored size: 926 Bytes

Contents

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

module Listen
  class Change
    include Celluloid

    attr_accessor :listener

    def initialize(listener)
      @listener = listener
    end

    def change(path, options)
      return if _silencer.silenced?(path, options[:type])

      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(listener, path).change
      if change && listener.listen? && !options[:silence]
        _notify_listener(change, path)
      end
    end

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

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

    def _silencer
      listener.registry[:silencer]
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
listen-2.7.2 lib/listen/change.rb
listen-2.7.1 lib/listen/change.rb
listen-2.7.0 lib/listen/change.rb
listen-2.6.2 lib/listen/change.rb
listen-2.6.1 lib/listen/change.rb
listen-2.6.0 lib/listen/change.rb
listen-2.5.0 lib/listen/change.rb
listen-2.4.1 lib/listen/change.rb
listen-2.4.0 lib/listen/change.rb
listen-2.3.1 lib/listen/change.rb