Sha256: 1dd155fa6385f677a613146d84a0ce45fb8ae72434ca7f00dfd52b1a5e8df2a9

Contents?: true

Size: 853 Bytes

Versions: 12

Compression:

Stored size: 853 Bytes

Contents

module Listen
  class Record
    include Celluloid

    attr_accessor :paths, :listener

    def initialize(listener)
      @listener = listener
      @paths    = _init_paths
    end

    def set_path(path, data)
      @paths[::File.dirname(path)][::File.basename(path)] = file_data(path).merge(data)
    end

    def unset_path(path)
      @paths[::File.dirname(path)].delete(::File.basename(path))
    end

    def file_data(path)
      @paths[::File.dirname(path)][::File.basename(path)] || {}
    end

    def dir_entries(path)
      @paths[path.to_s]
    end

    def build
      @paths = _init_paths
      listener.directories.each do |path|
        Actor[:listen_change_pool].change(path, type: 'Dir', recursive: true, silence: true)
      end
    end

    private

    def _init_paths
      Hash.new { |h, k| h[k] = Hash.new }
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
listen-2.2.0 lib/listen/record.rb
listen-2.1.2 lib/listen/record.rb
listen-2.1.1 lib/listen/record.rb
listen-2.1.0 lib/listen/record.rb
listen-2.0.4 lib/listen/record.rb
listen-2.0.3 lib/listen/record.rb
listen-2.0.2 lib/listen/record.rb
listen-2.0.1 lib/listen/record.rb
listen-2.0.0 lib/listen/record.rb
listen-2.0.0.pre.1 lib/listen/record.rb
listen-2.0.0.beta.2 lib/listen/record.rb
listen-2.0.0.beta.1 lib/listen/record.rb