Sha256: 178422ff4ca69b08a6deb9c2c05235fdc8ea1de7a525fda5dd121f40d47604cd
Contents?: true
Size: 1.77 KB
Versions: 3
Compression:
Stored size: 1.77 KB
Contents
module Mutant class Expression # Abstract base class for expressions matching namespaces class Namespace < self include AbstractType, Anima.new(:scope_name) private(*anima.attribute_names) # Recursive namespace expression class Recursive < self REGEXP = /\A#{SCOPE_NAME_PATTERN}?\*\z/.freeze # Initialize object # # @return [undefined] def initialize(*) super @recursion_pattern = Regexp.union( /\A#{scope_name}\z/, /\A#{scope_name}::/, /\A#{scope_name}[.#]/ ) end # Syntax for expression # # @return [String] def syntax "#{scope_name}*" end memoize :syntax # Matcher for expression # # @return [Matcher] def matcher Matcher::Namespace.new(self) end # Length of match with other expression # # @param [Expression] expression # # @return [Integer] def match_length(expression) if @recursion_pattern =~ expression.syntax scope_name.length else 0 end end end # Recursive # Exact namespace expression class Exact < self MATCHER = Matcher::Scope private_constant(*constants(false)) REGEXP = /\A#{SCOPE_NAME_PATTERN}\z/.freeze # Matcher matcher on expression # # @return [Matcher] def matcher Matcher::Scope.new(Object.const_get(scope_name)) end # Syntax for expression # # @return [String] alias_method :syntax, :scope_name public :syntax end # Exact end # Namespace end # Expression end # Mutant
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
mutant-0.8.16 | lib/mutant/expression/namespace.rb |
mutant-0.8.15 | lib/mutant/expression/namespace.rb |
mutant-0.8.14 | lib/mutant/expression/namespace.rb |