Sha256: 0d6177c545a88c5db31259f0ce375cddeb9befeff27c61b472896d157cd448f7
Contents?: true
Size: 1.77 KB
Versions: 6
Compression:
Stored size: 1.77 KB
Contents
module Mutant class Expression # Abstract base class for expressions matching namespaces class Namespace < self include AbstractType # Return matcher # # @param [Cache] cache # # @return [Matcher] # # @api private # def matcher(cache) self.class::MATCHER.new(cache, namespace) end private # Return namespace # # @return [Class, Module] # # @api private # def namespace Mutant.constant_lookup(match[__method__].to_s) end # Recursive namespace expression class Recursive < self register(/\A(?<namespace>#{SCOPE_PATTERN})?\*\z/) MATCHER = Matcher::Namespace # Initialize object # # @return [undefined] # # @api private def initialize(*) super namespace_src = Regexp.escape(namespace) @recursion_pattern = Regexp.union(/\A#{namespace_src}\z/, /\A#{namespace_src}::/) end # Return length of match # # @param [Expression] expression # # @return [Fixnum] # # @api private # def match_length(expression) if @recursion_pattern =~ expression.syntax namespace.length else 0 end end private # Return matched namespace # # @return [String] # # @api private # def namespace match[__method__] || '' end end # Recursive # Exact namespace expression class Exact < self register(/\A(?<namespace>#{SCOPE_PATTERN})\z/) MATCHER = Matcher::Scope end # Exact end # Namespace end # Namespace end # Mutant
Version data entries
6 entries across 6 versions & 1 rubygems