Sha256: 61e2f7deee0be6df491e5854617a92578753834b0478215ac76db27c3d68c8fa

Contents?: true

Size: 1.25 KB

Versions: 97

Compression:

Stored size: 1.25 KB

Contents

module Listen
  module Adapters

    # Adapter implementation for Mac OS X `FSEvents`.
    #
    class Darwin < Adapter
      LAST_SEPARATOR_REGEX = /\/$/


      def self.target_os_regex; /darwin(1.+)?$/i; end
      def self.adapter_gem; 'rb-fsevent'; end

      private

      # Initializes a FSEvent worker and adds a watcher for
      # each directory passed to the adapter.
      #
      # @return [FSEvent] initialized worker
      #
      # @see Listen::Adapter#initialize_worker
      #
      def initialize_worker
        FSEvent.new.tap do |worker|
          worker.watch(directories.dup, :latency => latency) do |changes|
            next if paused

            mutex.synchronize do
              changes.each { |path| @changed_directories << path.sub(LAST_SEPARATOR_REGEX, '') }
            end
          end
        end
      end

      # Starts the worker in a new thread and sleep 0.1 second.
      #
      # @see Listen::Adapter#start_worker
      #
      def start_worker
        @worker_thread = Thread.new { worker.run }
        # The FSEvent worker needs some time to start up. Turnstiles can't
        # be used to wait for it as it runs in a loop.
        # TODO: Find a better way to block until the worker starts.
        sleep 0.1
      end
    end

  end
end

Version data entries

97 entries across 94 versions & 8 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/sass-3.4.15/vendor/listen/lib/listen/adapters/darwin.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/sass-3.4.15/vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.16 vendor/listen/lib/listen/adapters/darwin.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sass-3.4.14/vendor/listen/lib/listen/adapters/darwin.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/sass-3.4.15/vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.15 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.14 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.13 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.12 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.11 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.10 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.9 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.8 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.7 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.6 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.5 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.4 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.3 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.2 vendor/listen/lib/listen/adapters/darwin.rb
sass-3.4.1 vendor/listen/lib/listen/adapters/darwin.rb