Sha256: 4dd36d23125daf63475a6d07aff9feaf31fef78f3ab13b1b971ef680ccd7eaea

Contents?: true

Size: 871 Bytes

Versions: 8

Compression:

Stored size: 871 Bytes

Contents

module Mutant
  class Matcher
    # Matcher for specific namespace
    class Namespace < self
      include Concord::Public.new(:expression)

      # Enumerate subjects
      #
      # @param [Env::Bootstrap] env
      #
      # @return [Enumerable<Subject>]
      def call(env)
        Chain.new(
          matched_scopes(env).map { |scope| Scope.new(scope.raw) }
        ).call(env)
      end

    private

      # The matched scopes
      #
      # @param [Env] env
      #
      # @return [Enumerable<Scope>]
      def matched_scopes(env)
        env
          .matchable_scopes
          .select(&method(:match?))
      end

      # Test scope if matches expression
      #
      # @param [Scope] scope
      #
      # @return [Boolean]
      def match?(scope)
        expression.prefix?(scope.expression)
      end

    end # Namespace
  end # Matcher
end # Mutant

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutant-0.8.16 lib/mutant/matcher/namespace.rb
mutant-0.8.15 lib/mutant/matcher/namespace.rb
mutant-0.8.14 lib/mutant/matcher/namespace.rb
mutant-0.8.13 lib/mutant/matcher/namespace.rb
mutant-0.8.12 lib/mutant/matcher/namespace.rb
mutant-0.8.11 lib/mutant/matcher/namespace.rb
mutant-0.8.10 lib/mutant/matcher/namespace.rb
mutant-0.8.9 lib/mutant/matcher/namespace.rb