Sha256: bb9872c76462b07994b332211f967df67d6176e7aa395cb10e09aa6e13139ca4

Contents?: true

Size: 746 Bytes

Versions: 3

Compression:

Stored size: 746 Bytes

Contents

# encoding: utf-8

require 'rb-fsevent'

class Kicker
  class FSEvents
    class FSEvent
      attr_reader :path
      
      def initialize(path)
        @path = path
      end
      
      def files
        Dir.glob("#{File.expand_path(path)}/*").map do |filename|
          begin
            [File.mtime(filename), filename]
          rescue Errno::ENOENT
            nil
          end
        end.compact.sort.reverse.map { |_, filename| filename }
      end
    end
    
    def self.start_watching(paths, options={}, &block)
      fsevent = ::FSEvent.new
      fsevent.watch(paths, options) do |directories|
        yield directories.map { |directory| Kicker::FSEvents::FSEvent.new(directory) }
      end
      fsevent.run
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kicker-2.5.0 lib/kicker/fsevents.rb
kicker-2.4.0 lib/kicker/fsevents.rb
kicker-2.3.1 lib/kicker/fsevents.rb