Sha256: f4a980c232cf97bb688fd4b180471bc31ff75ad4bedd367085094b2a3938e3d6

Contents?: true

Size: 902 Bytes

Versions: 8

Compression:

Stored size: 902 Bytes

Contents

# frozen_string_literal: true

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.24 lib/mutant/matcher/namespace.rb
mutant-0.8.23 lib/mutant/matcher/namespace.rb
mutant-0.8.22 lib/mutant/matcher/namespace.rb
mutant-0.8.21 lib/mutant/matcher/namespace.rb
mutant-0.8.20 lib/mutant/matcher/namespace.rb
mutant-0.8.19 lib/mutant/matcher/namespace.rb
mutant-0.8.18 lib/mutant/matcher/namespace.rb
mutant-0.8.17 lib/mutant/matcher/namespace.rb