Sha256: 96f72e014979f7bc1396a560486148da40978b1b92ca3dada5d2acc53b688be5

Contents?: true

Size: 1.17 KB

Versions: 78

Compression:

Stored size: 1.17 KB

Contents

module Listen
  class Silencer
    class Controller
      def initialize(silencer, default_options)
        @silencer = silencer

        opts = default_options

        @prev_silencer_options = {}
        rules = [:only, :ignore, :ignore!].map do |option|
          [option, opts[option]] if opts.key? option
        end

        _reconfigure_silencer(Hash[rules.compact])
      end

      def append_ignores(*regexps)
        prev_ignores = Array(@prev_silencer_options[:ignore])
        _reconfigure_silencer(ignore: [prev_ignores + regexps])
      end

      def replace_with_bang_ignores(regexps)
        _reconfigure_silencer(ignore!: regexps)
      end

      def replace_with_only(regexps)
        _reconfigure_silencer(only: regexps)
      end

      private

      def _reconfigure_silencer(extra_options)
        opts = extra_options.dup
        opts = opts.map do |key, value|
          [key, Array(value).flatten.compact]
        end
        opts = Hash[opts]

        if opts.key?(:ignore) && opts[:ignore].empty?
          opts.delete(:ignore)
        end

        @prev_silencer_options = opts
        @silencer.configure(@prev_silencer_options.dup.freeze)
      end
    end
  end
end

Version data entries

78 entries across 69 versions & 15 rubygems

Version Path
vagrant-unbundled-2.2.10.0 vendor/bundle/ruby/2.7.0/gems/listen-3.2.1/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.9.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/listen-3.0.8/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.8.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.7.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/listen-3.0.8/lib/listen/silencer/controller.rb
listen-3.2.1 lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.6.2 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.6.1 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.6.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
listen-3.2.0 lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.5.0 vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.5.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
vagrant-unbundled-2.2.4.0 vendor/bundle/ruby/2.6.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/listen-3.1.5/lib/listen/silencer/controller.rb