Sha256: 0687e5319d2a20749676d880ede75592eac4da398dca98f0cdb43f214a3a51a5

Contents?: true

Size: 675 Bytes

Versions: 59

Compression:

Stored size: 675 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] env
      #
      # @return [Enumerable<Subject>]
      def call(env)
        Chain.new(
          matched_scopes(env).map { |scope| Scope.new(scope.raw) }
        ).call(env)
      end

    private

      def matched_scopes(env)
        env
          .matchable_scopes
          .select(&method(:match?))
      end

      def match?(scope)
        expression.prefix?(scope.expression)
      end

    end # Namespace
  end # Matcher
end # Mutant

Version data entries

59 entries across 59 versions & 1 rubygems

Version Path
mutant-0.11.18 lib/mutant/matcher/namespace.rb
mutant-0.11.17 lib/mutant/matcher/namespace.rb
mutant-0.11.16 lib/mutant/matcher/namespace.rb
mutant-0.11.15 lib/mutant/matcher/namespace.rb
mutant-0.11.14 lib/mutant/matcher/namespace.rb
mutant-0.11.13 lib/mutant/matcher/namespace.rb
mutant-0.11.12 lib/mutant/matcher/namespace.rb
mutant-0.11.11 lib/mutant/matcher/namespace.rb
mutant-0.11.10 lib/mutant/matcher/namespace.rb
mutant-0.11.9 lib/mutant/matcher/namespace.rb
mutant-0.11.8 lib/mutant/matcher/namespace.rb
mutant-0.11.7 lib/mutant/matcher/namespace.rb
mutant-0.11.6 lib/mutant/matcher/namespace.rb
mutant-0.11.5 lib/mutant/matcher/namespace.rb
mutant-0.11.4 lib/mutant/matcher/namespace.rb
mutant-0.11.3 lib/mutant/matcher/namespace.rb
mutant-0.11.2 lib/mutant/matcher/namespace.rb
mutant-0.11.1 lib/mutant/matcher/namespace.rb
mutant-0.11.0 lib/mutant/matcher/namespace.rb
mutant-0.10.35 lib/mutant/matcher/namespace.rb