Sha256: 757d87137fb660cbf1550bc18908d5835e384f27dfb0d09e4f481e700c175e2b

Contents?: true

Size: 1.03 KB

Versions: 11

Compression:

Stored size: 1.03 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
      # TODO: does nothing
    end

    def min_delay_between_events
      @min_delay_between_events
    end

    private

    attr_reader :adapter
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
listen-3.0.4 lib/listen/backend.rb
mastermind_adeybee-0.1.4 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/backend.rb
mastermind_adeybee-0.1.3 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/backend.rb
mastermind_adeybee-0.1.2 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/backend.rb
mastermind_adeybee-0.1.1 vendor/bundle/ruby/2.2.0/gems/listen-3.0.3/lib/listen/backend.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/listen-3.0.3/lib/listen/backend.rb
geminfo-0.1.0 path/gems/listen-3.0.3/lib/listen/backend.rb
listen-3.0.3 lib/listen/backend.rb
listen-3.0.2 lib/listen/backend.rb
listen-3.0.1 lib/listen/backend.rb
listen-3.0.0 lib/listen/backend.rb