Sha256: ce27186eb2be92b8a71f6f4f5c24651e22b4349ca11bdfe8ef569a17387d3ab6

Contents?: true

Size: 807 Bytes

Versions: 2

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

module RShade
  module Filter
    class IncludePathFilter < AbstractFilter
      attr_reader :paths

      NAME = :include_paths

      def initialize
        super
        @paths = []
      end

      def name
        NAME
      end

      def priority
        1
      end

      def call(event)
        event_path = event.path
        paths.any? do |path|
          next str?(path, event_path) if path.is_a? String
          next regexp?(path, event_path) if path.is_a? Regexp

          false
        end
      end

      def config_call(&block)
        block.call(@paths)
      end

      private

      def str?(str, event_path)
        event_path.include?(str)
      end

      def regexp?(regex, event_path)
        regex.match?(event_path)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rshade-0.2.2 lib/rshade/filter/include_path_filter.rb
rshade-0.2.1 lib/rshade/filter/include_path_filter.rb