Sha256: f846715945d36b0721681b1b531a27100338771675b00782d29a6dd65cc873df

Contents?: true

Size: 875 Bytes

Versions: 16

Compression:

Stored size: 875 Bytes

Contents

module Mutant
  class Matcher

    # Matcher for specific namespace
    #
    # rubocop:disable LineLength
    class Namespace < self
      include Concord::Public.new(:env, :expression)

      # Enumerate subjects
      #
      # @return [self]
      #   if block given
      #
      # @return [Enumerator<Subject>]
      #   otherwise
      #
      # @api private
      #
      def each(&block)
        return to_enum unless block_given?

        env.matchable_scopes.select do |scope|
          scope.each(&block) if match?(scope)
        end

        self
      end

    private

      # Test scope if name matches expression
      #
      # @param [Module, Class] scope
      #
      # @return [Boolean]
      #
      # @api private
      #
      def match?(scope)
        expression.prefix?(scope.expression)
      end

    end # Namespace
  end # Matcher
end # Mutant

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mutant-0.8.0 lib/mutant/matcher/namespace.rb
mutant-0.7.9 lib/mutant/matcher/namespace.rb
mutant-0.7.8 lib/mutant/matcher/namespace.rb
mutant-0.7.7 lib/mutant/matcher/namespace.rb
mutant-0.7.6 lib/mutant/matcher/namespace.rb
mutant-0.7.5 lib/mutant/matcher/namespace.rb
mutant-0.7.4 lib/mutant/matcher/namespace.rb
mutant-0.7.3 lib/mutant/matcher/namespace.rb
mutant-0.7.2 lib/mutant/matcher/namespace.rb
mutant-0.7.1 lib/mutant/matcher/namespace.rb
mutant-0.6.7 lib/mutant/matcher/namespace.rb
mutant-0.6.6 lib/mutant/matcher/namespace.rb
mutant-0.6.5 lib/mutant/matcher/namespace.rb
mutant-0.6.4 lib/mutant/matcher/namespace.rb
mutant-0.6.3 lib/mutant/matcher/namespace.rb
mutant-0.6.2 lib/mutant/matcher/namespace.rb