Sha256: c3eb7002cff0d1e1f5f6855baf2a3536cb0bfc4ca65c3f4fd31c55b75bc7efa8

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

require 'listen/adapter'
require 'listen/adapter/base'
require 'listen/adapter/config'

# This class just aggregates configuration object to avoid Listener specs
# from exploding with huge test setup blocks
module Listen
  class Backend
    def initialize(directories, queue, silencer, config)
      adapter_select_opts = config.adapter_select_options

      adapter_class = Adapter.select(adapter_select_opts)

      # Use default from adapter if possible
      @min_delay_between_events = config.min_delay_between_events
      @min_delay_between_events ||= adapter_class::DEFAULTS[:wait_for_delay]
      @min_delay_between_events ||= 0.1

      adapter_opts = config.adapter_instance_options(adapter_class)

      aconfig = Adapter::Config.new(directories, queue, silencer, adapter_opts)
      @adapter = adapter_class.new(aconfig)
    end

    def start
      adapter.start
    end

    def stop
      adapter.stop
    end

    def min_delay_between_events
      @min_delay_between_events
    end

    private

    attr_reader :adapter
  end
end

Version data entries

5 entries across 5 versions & 3 rubygems

Version Path
sass-listen-3.0.7 lib/listen/backend.rb
listen-3.0.7 lib/listen/backend.rb
listen-3.0.6 lib/listen/backend.rb
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/listen-3.0.5/lib/listen/backend.rb
listen-3.0.5 lib/listen/backend.rb