Class: Mutant::Matcher::ObjectSpace

Inherits:
Mutant::Matcher show all
Defined in:
lib/mutant/matcher/object_space.rb

Overview

Matcher against object space

Constant Summary collapse

PATTERN =
%r(\A::(.+)\z)

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mutant::Matcher

from_string, #identification

Class Method Details

.parse(input) ⇒ Matcher::ObjectSpace?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parse matcher

Parameters:

  • input (String)

Returns:

  • (Matcher::ObjectSpace)

    returns object space matcher if successful

  • (nil)

    returns nil otherwise



21
22
23
24
25
26
# File 'lib/mutant/matcher/object_space.rb', line 21

def self.parse(input)
  match = PATTERN.match(input)
  return unless match

  new(%r(\A#{Regexp.escape(match[1])}(\z|::)))
end

Instance Method Details

#each(&block) ⇒ Enumerator<Subject>, self

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Enumerate subjects

Returns:

  • (Enumerator<Subject>)

    returns subject enumerator when no block given

  • (self)

    returns self otherwise



38
39
40
41
42
43
44
45
46
# File 'lib/mutant/matcher/object_space.rb', line 38

def each(&block)
  return to_enum unless block_given?

  scopes.each do |scope|
    emit_scope_matches(scope, &block)
  end

  self
end

#scope_name_patternRegexp

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return scope name pattern

Returns:

  • (Regexp)


54
# File 'lib/mutant/matcher/object_space.rb', line 54

def scope_name_pattern; @scope_name_pattern; end