Sha256: 0afd038340be0489074a1c3c90b6e23b96b128c87d5ea1aa5bebf01ca8a51a49

Contents?: true

Size: 872 Bytes

Versions: 8

Compression:

Stored size: 872 Bytes

Contents

module Mutest
  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 # Mutest

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mutest-0.0.9 lib/mutest/matcher/namespace.rb
mutest-0.0.8 lib/mutest/matcher/namespace.rb
mutest-0.0.7 lib/mutest/matcher/namespace.rb
mutest-0.0.6 lib/mutest/matcher/namespace.rb
mutest-0.0.5 lib/mutest/matcher/namespace.rb
mutest-0.0.4 lib/mutest/matcher/namespace.rb
mutest-0.0.3 lib/mutest/matcher/namespace.rb
mutest-0.0.2 lib/mutest/matcher/namespace.rb