Sha256: 930f09c6cf8f00ddcc429151905c96efafc6fd399d6f9a6527f318ea87080998

Contents?: true

Size: 1.29 KB

Versions: 111

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

require 'logger'
require 'weakref'
require 'listen/logger'
require 'listen/listener'

# Won't print anything by default because of level - unless you've set
# LISTEN_GEM_DEBUGGING or provided your own logger with a high enough level
Listen.logger.info "Listen loglevel set to: #{Listen.logger.level}"
Listen.logger.info "Listen version: #{Listen::VERSION}"

module Listen
  @listeners = Queue.new

  class << self
    # Listens to file system modifications on a either single directory or
    # multiple directories.
    #
    # @param (see Listen::Listener#new)
    #
    # @yield [modified, added, removed] the changed files
    # @yieldparam [Array<String>] modified the list of modified files
    # @yieldparam [Array<String>] added the list of added files
    # @yieldparam [Array<String>] removed the list of removed files
    #
    # @return [Listen::Listener] the listener
    #
    def to(*args, &block)
      Listener.new(*args, &block).tap do |listener|
        @listeners.enq(WeakRef.new(listener))
      end
    end

    # This is used by the `listen` binary to handle Ctrl-C
    #
    def stop
      while (listener = @listeners.deq(true))
        begin
          listener.stop
        rescue WeakRef::RefError
        end
      end
    rescue ThreadError
    end
  end
end

Version data entries

111 entries across 110 versions & 7 rubygems

Version Path
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.47 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.46 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.45 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.44 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.43 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.42 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.41 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.39 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.38 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
harbr-0.1.37 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/listen-3.8.0/lib/listen.rb
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/listen-3.8.0/lib/listen.rb
listen-3.8.0 lib/listen.rb