mutant 0.11.32 → 0.11.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mutant/bootstrap.rb +1 -1
- data/lib/mutant/expression/descendants.rb +2 -1
- data/lib/mutant/expression/method.rb +3 -1
- data/lib/mutant/expression/methods.rb +3 -1
- data/lib/mutant/expression/namespace.rb +4 -2
- data/lib/mutant/expression/source.rb +46 -0
- data/lib/mutant/matcher.rb +6 -4
- data/lib/mutant/parser.rb +1 -1
- data/lib/mutant/version.rb +1 -1
- data/lib/mutant.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14a2999151fdced3adcf95c921ef755b416f3753bef2073c7eafb5648d5a1117
|
4
|
+
data.tar.gz: 0e6587233ae3ff944daf6ad9740be5b16749da34b8312207b7827afd4a79efb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 477a3d6cf75df00b4b3732932aa0042c7b7b07cf2dea107ac3537c24be585e5d3f4d1a9fc76a26cf1e2fa317c16bb5b63b0a41352a18733dfcabe4be8312a17a
|
7
|
+
data.tar.gz: a29d9393fab0760cd0c463d22d8f54b6f0b9578feb0da38068e20a075af21bd28cca417ea9820a5af1926eb37338754cf25cfbed4f60e491ebaa5267c7956ed2
|
data/lib/mutant/bootstrap.rb
CHANGED
@@ -38,7 +38,7 @@ module Mutant
|
|
38
38
|
.with(matchable_scopes: matchable_scopes(env))
|
39
39
|
|
40
40
|
matched_subjects = env.record(:subject_match) do
|
41
|
-
Matcher.
|
41
|
+
Matcher.expand(env: env).call(env)
|
42
42
|
end
|
43
43
|
|
44
44
|
selected_subjects = subject_select(env, matched_subjects)
|
@@ -39,7 +39,9 @@ module Mutant
|
|
39
39
|
# Matcher for expression
|
40
40
|
#
|
41
41
|
# @return [Matcher]
|
42
|
-
|
42
|
+
#
|
43
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
44
|
+
def matcher(env:)
|
43
45
|
matcher_candidates = MATCHERS.fetch(scope_symbol)
|
44
46
|
.map { |submatcher| submatcher.new(scope: scope) }
|
45
47
|
|
@@ -34,7 +34,9 @@ module Mutant
|
|
34
34
|
# Matcher on expression
|
35
35
|
#
|
36
36
|
# @return [Matcher::Method]
|
37
|
-
|
37
|
+
#
|
38
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
39
|
+
def matcher(env:)
|
38
40
|
matcher_candidates = MATCHERS.fetch(scope_symbol)
|
39
41
|
.map { |submatcher| submatcher.new(scope: scope) }
|
40
42
|
|
@@ -34,7 +34,9 @@ module Mutant
|
|
34
34
|
# Matcher for expression
|
35
35
|
#
|
36
36
|
# @return [Matcher]
|
37
|
-
|
37
|
+
#
|
38
|
+
# rubocop:disable Lint/UnusedMethodArgument
|
39
|
+
def matcher(env:)
|
38
40
|
Matcher::Namespace.new(expression: self)
|
39
41
|
end
|
40
42
|
|
@@ -65,7 +67,7 @@ module Mutant
|
|
65
67
|
# Matcher matcher on expression
|
66
68
|
#
|
67
69
|
# @return [Matcher]
|
68
|
-
def matcher
|
70
|
+
def matcher(env:)
|
69
71
|
raw_scope = find_raw_scope
|
70
72
|
|
71
73
|
if raw_scope
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mutant
|
4
|
+
class Expression
|
5
|
+
class Source < self
|
6
|
+
include Anima.new(:glob_expression)
|
7
|
+
|
8
|
+
REGEXP = /\Asource:(?<glob_expression>.+)\z/
|
9
|
+
|
10
|
+
def syntax
|
11
|
+
"source:#{glob_expression}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def matcher(env:)
|
15
|
+
Matcher::Chain.new(matchers: find_matchers(env: env))
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def find_matchers(env:)
|
21
|
+
scope_names(env: env).uniq.map do |scope_name|
|
22
|
+
Namespace::Recursive.new(scope_name: scope_name).matcher(env: nil)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def scope_names(env:)
|
27
|
+
env.world.pathname.glob(glob_expression).flat_map do |path|
|
28
|
+
toplevel_consts(env.parser.call(path).node).map(&Unparser.public_method(:unparse))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def toplevel_consts(node)
|
33
|
+
children = node.children
|
34
|
+
|
35
|
+
case node.type
|
36
|
+
when :class, :module
|
37
|
+
[children.fetch(0)]
|
38
|
+
when :begin
|
39
|
+
children.flat_map(&method(__method__))
|
40
|
+
else
|
41
|
+
EMPTY_ARRAY
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end # Source
|
45
|
+
end # Expression
|
46
|
+
end # Mutant
|
data/lib/mutant/matcher.rb
CHANGED
@@ -15,13 +15,15 @@ module Mutant
|
|
15
15
|
|
16
16
|
# Turn config into matcher
|
17
17
|
#
|
18
|
-
# @param [
|
18
|
+
# @param [Env] env
|
19
19
|
#
|
20
20
|
# @return [Matcher]
|
21
|
-
def self.
|
21
|
+
def self.expand(env:)
|
22
|
+
matcher_config = env.config.matcher
|
23
|
+
|
22
24
|
Filter.new(
|
23
|
-
matcher: Chain.new(matchers:
|
24
|
-
predicate: method(:allowed_subject?).curry.call(
|
25
|
+
matcher: Chain.new(matchers: matcher_config.subjects.map { |subject| subject.matcher(env: env) }),
|
26
|
+
predicate: method(:allowed_subject?).curry.call(matcher_config)
|
25
27
|
)
|
26
28
|
end
|
27
29
|
|
data/lib/mutant/parser.rb
CHANGED
data/lib/mutant/version.rb
CHANGED
data/lib/mutant.rb
CHANGED
@@ -204,6 +204,7 @@ module Mutant
|
|
204
204
|
require 'mutant/expression/methods'
|
205
205
|
require 'mutant/expression/namespace'
|
206
206
|
require 'mutant/expression/parser'
|
207
|
+
require 'mutant/expression/source'
|
207
208
|
require 'mutant/test'
|
208
209
|
require 'mutant/test/runner'
|
209
210
|
require 'mutant/test/runner/sink'
|
@@ -347,7 +348,8 @@ module Mutant
|
|
347
348
|
Expression::Method,
|
348
349
|
Expression::Methods,
|
349
350
|
Expression::Namespace::Exact,
|
350
|
-
Expression::Namespace::Recursive
|
351
|
+
Expression::Namespace::Recursive,
|
352
|
+
Expression::Source
|
351
353
|
]
|
352
354
|
),
|
353
355
|
environment_variables: EMPTY_HASH,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mutant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Markus Schirp
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|
@@ -189,6 +189,7 @@ files:
|
|
189
189
|
- lib/mutant/expression/methods.rb
|
190
190
|
- lib/mutant/expression/namespace.rb
|
191
191
|
- lib/mutant/expression/parser.rb
|
192
|
+
- lib/mutant/expression/source.rb
|
192
193
|
- lib/mutant/hooks.rb
|
193
194
|
- lib/mutant/integration.rb
|
194
195
|
- lib/mutant/integration/null.rb
|