Sha256: e3bdd841627d4541d625a42fcc5497b1b76158c561d9e545f64b7f310931f20c

Contents?: true

Size: 744 Bytes

Versions: 346

Compression:

Stored size: 744 Bytes

Contents

module ActiveSupport
  class FileWatcher
    class Backend
      def initialize(path, watcher)
        @watcher = watcher
        @path    = path
      end

      def trigger(files)
        @watcher.trigger(files)
      end
    end

    def initialize
      @regex_matchers = {}
    end

    def watch(pattern, &block)
      @regex_matchers[pattern] = block
    end

    def trigger(files)
      trigger_files = Hash.new { |h,k| h[k] = Hash.new { |h2,k2| h2[k2] = [] } }

      files.each do |file, state|
        @regex_matchers.each do |pattern, block|
          trigger_files[block][state] << file if pattern === file
        end
      end

      trigger_files.each do |block, payload|
        block.call payload
      end
    end
  end
end

Version data entries

346 entries across 302 versions & 28 rubygems

Version Path
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/activesupport-3.2.22.5/lib/active_support/file_watcher.rb
activesupport-3.2.22.5 lib/active_support/file_watcher.rb
activesupport-3.2.22.4 lib/active_support/file_watcher.rb
activesupport-3.2.22.3 lib/active_support/file_watcher.rb
activesupport-4.1.16 lib/active_support/file_watcher.rb
activesupport-4.1.16.rc1 lib/active_support/file_watcher.rb
activesupport-4.1.15 lib/active_support/file_watcher.rb
activesupport-4.1.15.rc1 lib/active_support/file_watcher.rb
activesupport-3.2.22.2 lib/active_support/file_watcher.rb
activesupport-4.1.14.2 lib/active_support/file_watcher.rb
activesupport-4.1.14.1 lib/active_support/file_watcher.rb
activesupport-3.2.22.1 lib/active_support/file_watcher.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/file_watcher.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/file_watcher.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activesupport-4.1.13/lib/active_support/file_watcher.rb
activesupport-4.1.14 lib/active_support/file_watcher.rb
activesupport-4.1.14.rc2 lib/active_support/file_watcher.rb
activesupport-4.1.14.rc1 lib/active_support/file_watcher.rb
classiccms-0.7.5 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/file_watcher.rb
classiccms-0.7.4 vendor/bundle/gems/activesupport-3.2.3/lib/active_support/file_watcher.rb