Sha256: 80853c905f45bdf28e45db9211f587296b2b43f85b846512958890303b1c6fa8

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require 'observer'

module Watchr
  module EventHandler

    # @private
    class AbstractMethod < Exception; end

    # Base functionality mixin, meant to be included in specific event handlers.
    #
    # @abstract
    module Base
      include Observable

      # Notify that a file was modified.
      #
      # @param [Pathname, String] path
      #   full path or path relative to current working directory
      #
      # @param [Symbol] event
      #   event type.
      #
      # @return [undefined]
      #
      def notify(path, event_type = nil)
        changed(true)
        notify_observers(path, event_type)
      end

      # Begin watching given paths and enter listening loop. Called by the
      # controller.
      #
      # @param [Array<Pathname>] monitored_paths
      #   list of paths the application is currently monitoring.
      #
      # @return [undefined]
      #
      # @abstract
      def listen(monitored_paths)
        raise AbstractMethod
      end

      # Called by the controller when the list of paths monitored by wantchr
      # has changed. It should refresh the list of paths being watched.
      #
      # @param [Array<Pathname>] monitored_paths
      #   list of paths the application is currently monitoring.
      #
      # @return [undefined]
      #
      # @abstract
      def refresh(monitored_paths)
        raise AbstractMethod
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
social_url_stats-0.0.1 vendor/ruby/1.9.1/gems/watchr-0.7/lib/watchr/event_handlers/base.rb
watchr-0.7 lib/watchr/event_handlers/base.rb
watchr-0.6 lib/watchr/event_handlers/base.rb