Sha256: d283cbb67199f957bcfaa306c1cd410dc098d0059b650eac7b5a9f17cf6bd238

Contents?: true

Size: 759 Bytes

Versions: 2

Compression:

Stored size: 759 Bytes

Contents

module RShade
  module Filter
    class IncludePathFilter < AbstractFilter
      attr_reader :paths

      NAME = :include_paths

      def initialize
        @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.1.9.1 lib/rshade/filter/include_path_filter.rb
rshade-0.1.9 lib/rshade/filter/include_path_filter.rb