mutant 0.8.0 → 0.8.1
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/Changelog.md +7 -0
- data/config/flay.yml +1 -1
- data/config/reek.yml +1 -0
- data/lib/mutant.rb +10 -3
- data/lib/mutant/actor.rb +2 -5
- data/lib/mutant/actor/env.rb +1 -3
- data/lib/mutant/actor/mailbox.rb +2 -4
- data/lib/mutant/actor/receiver.rb +0 -2
- data/lib/mutant/actor/sender.rb +0 -1
- data/lib/mutant/ast.rb +22 -28
- data/lib/mutant/ast/meta.rb +8 -88
- data/lib/mutant/ast/named_children.rb +1 -8
- data/lib/mutant/ast/sexp.rb +0 -2
- data/lib/mutant/cache.rb +1 -3
- data/lib/mutant/cli.rb +9 -19
- data/lib/mutant/color.rb +0 -3
- data/lib/mutant/config.rb +6 -2
- data/lib/mutant/context.rb +2 -4
- data/lib/mutant/context/scope.rb +10 -16
- data/lib/mutant/delegator.rb +0 -3
- data/lib/mutant/diff.rb +8 -17
- data/lib/mutant/env.rb +3 -5
- data/lib/mutant/env/bootstrap.rb +32 -39
- data/lib/mutant/expression.rb +14 -132
- data/lib/mutant/expression/method.rb +25 -42
- data/lib/mutant/expression/methods.rb +17 -29
- data/lib/mutant/expression/namespace.rb +33 -28
- data/lib/mutant/expression/parser.rb +71 -0
- data/lib/mutant/integration.rb +17 -16
- data/lib/mutant/isolation.rb +14 -14
- data/lib/mutant/loader.rb +2 -4
- data/lib/mutant/matcher.rb +1 -11
- data/lib/mutant/matcher/chain.rb +0 -1
- data/lib/mutant/matcher/compiler.rb +19 -52
- data/lib/mutant/matcher/config.rb +65 -5
- data/lib/mutant/matcher/filter.rb +11 -1
- data/lib/mutant/matcher/method.rb +11 -21
- data/lib/mutant/matcher/method/instance.rb +2 -16
- data/lib/mutant/matcher/method/singleton.rb +3 -20
- data/lib/mutant/matcher/methods.rb +11 -21
- data/lib/mutant/matcher/namespace.rb +0 -4
- data/lib/mutant/matcher/null.rb +0 -1
- data/lib/mutant/matcher/scope.rb +0 -12
- data/lib/mutant/meta.rb +0 -1
- data/lib/mutant/meta/example.rb +12 -26
- data/lib/mutant/meta/example/dsl.rb +1 -8
- data/lib/mutant/mutation.rb +6 -14
- data/lib/mutant/mutator.rb +2 -14
- data/lib/mutant/mutator/node.rb +6 -33
- data/lib/mutant/mutator/node/and_asgn.rb +0 -1
- data/lib/mutant/mutator/node/argument.rb +0 -5
- data/lib/mutant/mutator/node/arguments.rb +1 -7
- data/lib/mutant/mutator/node/begin.rb +0 -2
- data/lib/mutant/mutator/node/binary.rb +0 -3
- data/lib/mutant/mutator/node/block.rb +0 -2
- data/lib/mutant/mutator/node/break.rb +0 -1
- data/lib/mutant/mutator/node/case.rb +0 -3
- data/lib/mutant/mutator/node/conditional_loop.rb +0 -1
- data/lib/mutant/mutator/node/const.rb +0 -1
- data/lib/mutant/mutator/node/define.rb +0 -1
- data/lib/mutant/mutator/node/defined.rb +0 -1
- data/lib/mutant/mutator/node/dstr.rb +0 -1
- data/lib/mutant/mutator/node/dsym.rb +0 -1
- data/lib/mutant/mutator/node/generic.rb +0 -1
- data/lib/mutant/mutator/node/if.rb +0 -4
- data/lib/mutant/mutator/node/kwbegin.rb +0 -1
- data/lib/mutant/mutator/node/literal/array.rb +0 -2
- data/lib/mutant/mutator/node/literal/boolean.rb +0 -1
- data/lib/mutant/mutator/node/literal/fixnum.rb +2 -5
- data/lib/mutant/mutator/node/literal/float.rb +1 -4
- data/lib/mutant/mutator/node/literal/hash.rb +0 -3
- data/lib/mutant/mutator/node/literal/nil.rb +0 -1
- data/lib/mutant/mutator/node/literal/range.rb +1 -5
- data/lib/mutant/mutator/node/literal/regex.rb +1 -3
- data/lib/mutant/mutator/node/literal/string.rb +0 -1
- data/lib/mutant/mutator/node/literal/symbol.rb +0 -1
- data/lib/mutant/mutator/node/masgn.rb +0 -1
- data/lib/mutant/mutator/node/match_current_line.rb +0 -1
- data/lib/mutant/mutator/node/mlhs.rb +0 -1
- data/lib/mutant/mutator/node/named_value/access.rb +0 -1
- data/lib/mutant/mutator/node/named_value/constant_assignment.rb +0 -2
- data/lib/mutant/mutator/node/named_value/variable_assignment.rb +0 -2
- data/lib/mutant/mutator/node/next.rb +0 -1
- data/lib/mutant/mutator/node/noop.rb +0 -1
- data/lib/mutant/mutator/node/nthref.rb +0 -1
- data/lib/mutant/mutator/node/op_asgn.rb +0 -1
- data/lib/mutant/mutator/node/or_asgn.rb +1 -2
- data/lib/mutant/mutator/node/resbody.rb +0 -2
- data/lib/mutant/mutator/node/rescue.rb +1 -6
- data/lib/mutant/mutator/node/return.rb +0 -1
- data/lib/mutant/mutator/node/send.rb +16 -17
- data/lib/mutant/mutator/node/send/attribute_assignment.rb +0 -3
- data/lib/mutant/mutator/node/send/binary.rb +0 -1
- data/lib/mutant/mutator/node/send/index.rb +0 -3
- data/lib/mutant/mutator/node/splat.rb +0 -1
- data/lib/mutant/mutator/node/super.rb +0 -1
- data/lib/mutant/mutator/node/when.rb +2 -7
- data/lib/mutant/mutator/node/yield.rb +0 -1
- data/lib/mutant/mutator/node/zsuper.rb +0 -1
- data/lib/mutant/mutator/registry.rb +1 -4
- data/lib/mutant/mutator/util.rb +0 -2
- data/lib/mutant/mutator/util/array.rb +0 -3
- data/lib/mutant/mutator/util/symbol.rb +0 -1
- data/lib/mutant/parallel.rb +3 -9
- data/lib/mutant/parallel/master.rb +7 -17
- data/lib/mutant/parallel/source.rb +2 -7
- data/lib/mutant/parallel/worker.rb +1 -5
- data/lib/mutant/reporter.rb +0 -4
- data/lib/mutant/reporter/cli.rb +1 -8
- data/lib/mutant/reporter/cli/format.rb +7 -18
- data/lib/mutant/reporter/cli/printer.rb +2 -12
- data/lib/mutant/reporter/cli/printer/config.rb +1 -4
- data/lib/mutant/reporter/cli/printer/env_progress.rb +3 -7
- data/lib/mutant/reporter/cli/printer/env_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/mutation_progress_result.rb +0 -2
- data/lib/mutant/reporter/cli/printer/mutation_result.rb +3 -11
- data/lib/mutant/reporter/cli/printer/status.rb +1 -4
- data/lib/mutant/reporter/cli/printer/status_progressive.rb +1 -3
- data/lib/mutant/reporter/cli/printer/subject_progress.rb +0 -5
- data/lib/mutant/reporter/cli/printer/subject_result.rb +0 -1
- data/lib/mutant/reporter/cli/printer/test_result.rb +0 -1
- data/lib/mutant/reporter/cli/tput.rb +4 -1
- data/lib/mutant/reporter/trace.rb +2 -4
- data/lib/mutant/repository.rb +88 -0
- data/lib/mutant/require_highjack.rb +0 -1
- data/lib/mutant/result.rb +25 -48
- data/lib/mutant/runner.rb +7 -16
- data/lib/mutant/runner/sink.rb +3 -11
- data/lib/mutant/selector.rb +1 -2
- data/lib/mutant/selector/expression.rb +1 -2
- data/lib/mutant/subject.rb +10 -21
- data/lib/mutant/subject/method.rb +11 -12
- data/lib/mutant/subject/method/instance.rb +1 -5
- data/lib/mutant/subject/method/singleton.rb +1 -3
- data/lib/mutant/test.rb +1 -2
- data/lib/mutant/version.rb +2 -2
- data/lib/mutant/warning_filter.rb +2 -7
- data/lib/mutant/zombifier.rb +6 -10
- data/meta/send.rb +8 -0
- data/spec/spec_helper.rb +5 -1
- data/spec/support/corpus.rb +5 -9
- data/spec/support/rb_bug.rb +0 -1
- data/spec/support/rspec.rb +0 -1
- data/spec/support/ruby_vm.rb +0 -2
- data/spec/unit/mutant/ast/meta/send_spec.rb +42 -0
- data/spec/unit/mutant/ast/named_children_spec.rb +51 -0
- data/spec/unit/mutant/ast/sexp_spec.rb +36 -0
- data/spec/unit/mutant/ast_spec.rb +8 -0
- data/spec/unit/mutant/cli_spec.rb +34 -19
- data/spec/unit/mutant/context/scope_spec.rb +11 -0
- data/spec/unit/mutant/env/boostrap_spec.rb +5 -2
- data/spec/unit/mutant/env_spec.rb +14 -15
- data/spec/unit/mutant/expression/method_spec.rb +10 -14
- data/spec/unit/mutant/expression/methods_spec.rb +24 -11
- data/spec/unit/mutant/expression/namespace/flat_spec.rb +5 -6
- data/spec/unit/mutant/expression/namespace/recursive_spec.rb +16 -10
- data/spec/unit/mutant/expression/parser_spec.rb +67 -0
- data/spec/unit/mutant/expression_spec.rb +24 -57
- data/spec/unit/mutant/integration/rspec_spec.rb +7 -7
- data/spec/unit/mutant/integration_spec.rb +2 -2
- data/spec/unit/mutant/isolation_spec.rb +31 -29
- data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +2 -2
- data/spec/unit/mutant/matcher/compiler_spec.rb +27 -58
- data/spec/unit/mutant/matcher/config_spec.rb +45 -0
- data/spec/unit/mutant/matcher/filter_spec.rb +12 -5
- data/spec/unit/mutant/matcher/method/instance_spec.rb +0 -1
- data/spec/unit/mutant/matcher/method/singleton_spec.rb +0 -1
- data/spec/unit/mutant/matcher/namespace_spec.rb +4 -4
- data/spec/unit/mutant/parallel/worker_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +4 -4
- data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +7 -7
- data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +2 -2
- data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +12 -12
- data/spec/unit/mutant/reporter/cli/printer/subject_progress_spec.rb +1 -1
- data/spec/unit/mutant/reporter/cli_spec.rb +9 -10
- data/spec/unit/mutant/repository/diff_spec.rb +80 -0
- data/spec/unit/mutant/repository/subject_filter_spec.rb +28 -0
- data/spec/unit/mutant/result/env_spec.rb +1 -1
- data/spec/unit/mutant/runner_spec.rb +0 -1
- data/spec/unit/mutant/selector/expression_spec.rb +14 -14
- data/spec/unit/mutant/subject/method/instance_spec.rb +2 -2
- data/spec/unit/mutant/subject/method/singleton_spec.rb +2 -2
- data/spec/unit/mutant/subject_spec.rb +5 -2
- metadata +20 -3
- data/spec/support/mutation_verifier.rb +0 -96
@@ -24,6 +24,8 @@ module Mutant
|
|
24
24
|
to_s: %i[to_str],
|
25
25
|
to_i: %i[to_int],
|
26
26
|
to_a: %i[to_ary],
|
27
|
+
at: %i[fetch],
|
28
|
+
:[] => %i[at fetch],
|
27
29
|
:== => %i[eql? equal?],
|
28
30
|
:>= => %i[> == eql? equal?],
|
29
31
|
:<= => %i[< == eql? equal?],
|
@@ -38,7 +40,6 @@ module Mutant
|
|
38
40
|
# @return [undefined]
|
39
41
|
#
|
40
42
|
# @api private
|
41
|
-
#
|
42
43
|
def dispatch
|
43
44
|
emit_singletons
|
44
45
|
if meta.index_assignment?
|
@@ -53,24 +54,31 @@ module Mutant
|
|
53
54
|
# @return [undefined]
|
54
55
|
#
|
55
56
|
# @api private
|
56
|
-
#
|
57
57
|
def non_index_dispatch
|
58
|
-
|
59
|
-
when meta.binary_method_operator?
|
58
|
+
if meta.binary_method_operator?
|
60
59
|
run(Binary)
|
61
|
-
|
60
|
+
elsif meta.attribute_assignment?
|
62
61
|
run(AttributeAssignment)
|
63
62
|
else
|
64
63
|
normal_dispatch
|
65
64
|
end
|
66
65
|
end
|
67
66
|
|
68
|
-
#
|
67
|
+
# AST metadata for node
|
69
68
|
#
|
70
|
-
# @return [
|
69
|
+
# @return [AST::Meta::Send]
|
71
70
|
#
|
72
71
|
# @api private
|
72
|
+
def meta
|
73
|
+
AST::Meta::Send.new(node)
|
74
|
+
end
|
75
|
+
memoize :meta
|
76
|
+
|
77
|
+
# Arguments being send
|
78
|
+
#
|
79
|
+
# @return [Enumerable<Parser::AST::Node>]
|
73
80
|
#
|
81
|
+
# @api private
|
74
82
|
alias_method :arguments, :remaining_children
|
75
83
|
|
76
84
|
# Perform normal, non special case dispatch
|
@@ -78,7 +86,6 @@ module Mutant
|
|
78
86
|
# @return [undefined]
|
79
87
|
#
|
80
88
|
# @api private
|
81
|
-
#
|
82
89
|
def normal_dispatch
|
83
90
|
emit_naked_receiver
|
84
91
|
emit_selector_replacement
|
@@ -92,11 +99,8 @@ module Mutant
|
|
92
99
|
# @return [undefined]
|
93
100
|
#
|
94
101
|
# @api private
|
95
|
-
#
|
96
102
|
def emit_selector_replacement
|
97
|
-
SELECTOR_REPLACEMENTS.fetch(selector, EMPTY_ARRAY).each
|
98
|
-
emit_selector(replacement)
|
99
|
-
end
|
103
|
+
SELECTOR_REPLACEMENTS.fetch(selector, EMPTY_ARRAY).each(&method(:emit_selector))
|
100
104
|
end
|
101
105
|
|
102
106
|
# Emit naked receiver mutation
|
@@ -104,7 +108,6 @@ module Mutant
|
|
104
108
|
# @return [undefined]
|
105
109
|
#
|
106
110
|
# @api private
|
107
|
-
#
|
108
111
|
def emit_naked_receiver
|
109
112
|
emit(receiver) if receiver && !NOT_ASSIGNABLE.include?(receiver.type)
|
110
113
|
end
|
@@ -114,7 +117,6 @@ module Mutant
|
|
114
117
|
# @return [undefined]
|
115
118
|
#
|
116
119
|
# @api private
|
117
|
-
#
|
118
120
|
def mutate_arguments
|
119
121
|
emit_type(receiver, selector)
|
120
122
|
remaining_children_with_index.each do |_node, index|
|
@@ -128,7 +130,6 @@ module Mutant
|
|
128
130
|
# @return [undefined]
|
129
131
|
#
|
130
132
|
# @api private
|
131
|
-
#
|
132
133
|
def emit_argument_propagation
|
133
134
|
node = arguments.first
|
134
135
|
emit(node) if arguments.one? && !NOT_STANDALONE.include?(node.type)
|
@@ -139,7 +140,6 @@ module Mutant
|
|
139
140
|
# @return [undefined]
|
140
141
|
#
|
141
142
|
# @api private
|
142
|
-
#
|
143
143
|
def mutate_receiver
|
144
144
|
return unless receiver
|
145
145
|
emit_implicit_self
|
@@ -153,7 +153,6 @@ module Mutant
|
|
153
153
|
# @return [undefined]
|
154
154
|
#
|
155
155
|
# @api private
|
156
|
-
#
|
157
156
|
def emit_implicit_self
|
158
157
|
emit_receiver(nil) if n_self?(receiver) && !(
|
159
158
|
KEYWORDS.include?(selector) ||
|
@@ -12,7 +12,6 @@ module Mutant
|
|
12
12
|
# @return [undefined]
|
13
13
|
#
|
14
14
|
# @api private
|
15
|
-
#
|
16
15
|
def dispatch
|
17
16
|
normal_dispatch
|
18
17
|
emit_attribute_read
|
@@ -23,7 +22,6 @@ module Mutant
|
|
23
22
|
# @return [undefined]
|
24
23
|
#
|
25
24
|
# @api private
|
26
|
-
#
|
27
25
|
def mutate_arguments
|
28
26
|
remaining_children_indices.each do |index|
|
29
27
|
mutate_child(index)
|
@@ -35,7 +33,6 @@ module Mutant
|
|
35
33
|
# @return [undefined]
|
36
34
|
#
|
37
35
|
# @api private
|
38
|
-
#
|
39
36
|
def emit_attribute_read
|
40
37
|
emit_type(receiver, selector.to_s[0..-2].to_sym)
|
41
38
|
end
|
@@ -19,7 +19,6 @@ module Mutant
|
|
19
19
|
# @return [undefined]
|
20
20
|
#
|
21
21
|
# @api private
|
22
|
-
#
|
23
22
|
def dispatch
|
24
23
|
emit_naked_receiver
|
25
24
|
emit_value_mutations
|
@@ -33,7 +32,6 @@ module Mutant
|
|
33
32
|
# @return [undefined]
|
34
33
|
#
|
35
34
|
# @api private
|
36
|
-
#
|
37
35
|
def mutate_indices
|
38
36
|
children_indices(INDEX_RANGE).each do |index|
|
39
37
|
delete_child(index)
|
@@ -46,7 +44,6 @@ module Mutant
|
|
46
44
|
# @return [undefined]
|
47
45
|
#
|
48
46
|
# @api private
|
49
|
-
#
|
50
47
|
def emit_index_read
|
51
48
|
emit_type(receiver, :[], *children[INDEX_RANGE])
|
52
49
|
end
|
@@ -14,7 +14,6 @@ module Mutant
|
|
14
14
|
# @return [undefined]
|
15
15
|
#
|
16
16
|
# @api private
|
17
|
-
#
|
18
17
|
def dispatch
|
19
18
|
if body
|
20
19
|
mutate_body
|
@@ -29,7 +28,6 @@ module Mutant
|
|
29
28
|
# @return [undefined]
|
30
29
|
#
|
31
30
|
# @api private
|
32
|
-
#
|
33
31
|
def mutate_conditions
|
34
32
|
conditions = children.length - 1
|
35
33
|
children[0..-2].each_index do |index|
|
@@ -43,12 +41,11 @@ module Mutant
|
|
43
41
|
# @return [undefined]
|
44
42
|
#
|
45
43
|
# @api private
|
46
|
-
#
|
47
44
|
def mutate_body
|
48
45
|
mutate_child(body_index)
|
49
46
|
end
|
50
47
|
|
51
|
-
#
|
48
|
+
# Body node
|
52
49
|
#
|
53
50
|
# @return [Parser::AST::Node]
|
54
51
|
# if body is present
|
@@ -57,17 +54,15 @@ module Mutant
|
|
57
54
|
# otherwise
|
58
55
|
#
|
59
56
|
# @api private
|
60
|
-
#
|
61
57
|
def body
|
62
58
|
children[body_index]
|
63
59
|
end
|
64
60
|
|
65
|
-
#
|
61
|
+
# Index of body node
|
66
62
|
#
|
67
63
|
# @return [Fixnum]
|
68
64
|
#
|
69
65
|
# @api private
|
70
|
-
#
|
71
66
|
def body_index
|
72
67
|
children.length - 1
|
73
68
|
end
|
@@ -8,7 +8,6 @@ module Mutant
|
|
8
8
|
# @return [undefined]
|
9
9
|
#
|
10
10
|
# @api private
|
11
|
-
#
|
12
11
|
def initialize
|
13
12
|
@registry = {}
|
14
13
|
end
|
@@ -21,10 +20,9 @@ module Mutant
|
|
21
20
|
# @param [Symbol] type
|
22
21
|
# @param [Class:Mutator] mutator
|
23
22
|
#
|
24
|
-
# @api private
|
25
|
-
#
|
26
23
|
# @return [self]
|
27
24
|
#
|
25
|
+
# @api private
|
28
26
|
def register(type, mutator)
|
29
27
|
fail RegistryError, "Invalid type registration: #{type}" unless AST::Types::ALL.include?(type)
|
30
28
|
fail RegistryError, "Duplicate type registration: #{type}" if @registry.key?(type)
|
@@ -42,7 +40,6 @@ module Mutant
|
|
42
40
|
# raises argument error when mutator class cannot be found
|
43
41
|
#
|
44
42
|
# @api private
|
45
|
-
#
|
46
43
|
def lookup(node)
|
47
44
|
type = node.type
|
48
45
|
@registry.fetch(type) do
|
data/lib/mutant/mutator/util.rb
CHANGED
@@ -15,7 +15,6 @@ module Mutant
|
|
15
15
|
# otherwise
|
16
16
|
#
|
17
17
|
# @api private
|
18
|
-
#
|
19
18
|
def self.each(object, parent, &block)
|
20
19
|
return to_enum(__method__, object, parent) unless block_given?
|
21
20
|
|
@@ -33,7 +32,6 @@ module Mutant
|
|
33
32
|
# @return [Boolean]
|
34
33
|
#
|
35
34
|
# @api private
|
36
|
-
#
|
37
35
|
def new?(generated)
|
38
36
|
!input.eql?(generated)
|
39
37
|
end
|
@@ -15,7 +15,6 @@ module Mutant
|
|
15
15
|
# @return [undefined]
|
16
16
|
#
|
17
17
|
# @api private
|
18
|
-
#
|
19
18
|
def dispatch
|
20
19
|
input.each_index do |index|
|
21
20
|
dup = dup_input
|
@@ -36,7 +35,6 @@ module Mutant
|
|
36
35
|
# @return [undefined]
|
37
36
|
#
|
38
37
|
# @api private
|
39
|
-
#
|
40
38
|
def dispatch
|
41
39
|
input.each_with_index do |element, index|
|
42
40
|
Mutator.each(element).each do |mutation|
|
@@ -56,7 +54,6 @@ module Mutant
|
|
56
54
|
# @return [undefined]
|
57
55
|
#
|
58
56
|
# @api private
|
59
|
-
#
|
60
57
|
def dispatch
|
61
58
|
run(Element)
|
62
59
|
run(Presence)
|
data/lib/mutant/parallel.rb
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
module Mutant
|
2
|
-
# Parallel
|
2
|
+
# Parallel execution engine of arbitrary payloads
|
3
3
|
module Parallel
|
4
4
|
|
5
5
|
# Driver for parallelized execution
|
6
6
|
class Driver
|
7
7
|
include Concord.new(:binding)
|
8
8
|
|
9
|
-
#
|
9
|
+
# Scheduler status
|
10
10
|
#
|
11
11
|
# @return [Object]
|
12
12
|
#
|
13
13
|
# @api private
|
14
|
-
#
|
15
14
|
def status
|
16
15
|
binding.call(__method__)
|
17
16
|
end
|
@@ -21,7 +20,6 @@ module Mutant
|
|
21
20
|
# @return [self]
|
22
21
|
#
|
23
22
|
# @api private
|
24
|
-
#
|
25
23
|
def stop
|
26
24
|
binding.call(__method__)
|
27
25
|
self
|
@@ -33,7 +31,6 @@ module Mutant
|
|
33
31
|
# @return [Driver]
|
34
32
|
#
|
35
33
|
# @api private
|
36
|
-
#
|
37
34
|
def self.async(config)
|
38
35
|
Driver.new(config.env.new_mailbox.bind(Master.call(config)))
|
39
36
|
end
|
@@ -49,15 +46,13 @@ module Mutant
|
|
49
46
|
# @return [self]
|
50
47
|
#
|
51
48
|
# @api private
|
52
|
-
#
|
53
49
|
abstract_method :result
|
54
50
|
|
55
|
-
#
|
51
|
+
# Sink status
|
56
52
|
#
|
57
53
|
# @return [Object]
|
58
54
|
#
|
59
55
|
# @api private
|
60
|
-
#
|
61
56
|
abstract_method :status
|
62
57
|
|
63
58
|
# Test if processing should stop
|
@@ -65,7 +60,6 @@ module Mutant
|
|
65
60
|
# @return [Boolean]
|
66
61
|
#
|
67
62
|
# @api private
|
68
|
-
#
|
69
63
|
abstract_method :stop?
|
70
64
|
end # Sink
|
71
65
|
|
@@ -13,7 +13,6 @@ module Mutant
|
|
13
13
|
# @return [Actor::Sender]
|
14
14
|
#
|
15
15
|
# @api private
|
16
|
-
#
|
17
16
|
def self.call(config)
|
18
17
|
config.env.spawn do |mailbox|
|
19
18
|
new(config, mailbox).__send__(:run)
|
@@ -25,7 +24,6 @@ module Mutant
|
|
25
24
|
# @return [undefined]
|
26
25
|
#
|
27
26
|
# @api private
|
28
|
-
#
|
29
27
|
def initialize(*)
|
30
28
|
super
|
31
29
|
|
@@ -39,10 +37,11 @@ module Mutant
|
|
39
37
|
|
40
38
|
# Run work loop
|
41
39
|
#
|
42
|
-
# @api private
|
43
|
-
#
|
44
40
|
# rubocop:disable MethodLength
|
45
41
|
#
|
42
|
+
# @return [undefined]
|
43
|
+
#
|
44
|
+
# @api private
|
46
45
|
def run
|
47
46
|
config.jobs.times do
|
48
47
|
@workers += 1
|
@@ -72,7 +71,6 @@ module Mutant
|
|
72
71
|
# @return [undefined]
|
73
72
|
#
|
74
73
|
# @api private
|
75
|
-
#
|
76
74
|
def handle(message)
|
77
75
|
type, payload = message.type, message.payload
|
78
76
|
method = MAP.fetch(type) do
|
@@ -86,7 +84,6 @@ module Mutant
|
|
86
84
|
# @return [undefined]
|
87
85
|
#
|
88
86
|
# @api private
|
89
|
-
#
|
90
87
|
def receive_loop
|
91
88
|
handle(mailbox.receiver.call) until @workers.zero? && @stop
|
92
89
|
end
|
@@ -98,7 +95,6 @@ module Mutant
|
|
98
95
|
# @return [undefined]
|
99
96
|
#
|
100
97
|
# @api private
|
101
|
-
#
|
102
98
|
def handle_status(sender)
|
103
99
|
status = Status.new(
|
104
100
|
payload: sink.status,
|
@@ -115,7 +111,6 @@ module Mutant
|
|
115
111
|
# @return [undefined]
|
116
112
|
#
|
117
113
|
# @api private
|
118
|
-
#
|
119
114
|
def handle_result(job_result)
|
120
115
|
@active_jobs.delete(job_result.job)
|
121
116
|
sink.result(job_result.payload)
|
@@ -128,7 +123,6 @@ module Mutant
|
|
128
123
|
# @return [undefined]
|
129
124
|
#
|
130
125
|
# @api private
|
131
|
-
#
|
132
126
|
def handle_stop(sender)
|
133
127
|
@stop = true
|
134
128
|
receive_loop
|
@@ -142,7 +136,6 @@ module Mutant
|
|
142
136
|
# @return [undefined]
|
143
137
|
#
|
144
138
|
# @api private
|
145
|
-
#
|
146
139
|
def handle_ready(sender)
|
147
140
|
if stop_work?
|
148
141
|
stop_worker(sender)
|
@@ -152,13 +145,14 @@ module Mutant
|
|
152
145
|
sender.call(Actor::Message.new(:job, next_job))
|
153
146
|
end
|
154
147
|
|
155
|
-
#
|
148
|
+
# Next job if any
|
156
149
|
#
|
157
150
|
# @return [Job]
|
158
151
|
# if next job is available
|
159
152
|
#
|
160
153
|
# @return [nil]
|
161
154
|
#
|
155
|
+
# @api private
|
162
156
|
def next_job
|
163
157
|
Job.new(
|
164
158
|
index: @index,
|
@@ -176,7 +170,6 @@ module Mutant
|
|
176
170
|
# @return [undefined]
|
177
171
|
#
|
178
172
|
# @api private
|
179
|
-
#
|
180
173
|
def stop_worker(sender)
|
181
174
|
@workers -= 1
|
182
175
|
sender.call(Actor::Message.new(:stop))
|
@@ -187,27 +180,24 @@ module Mutant
|
|
187
180
|
# @return [Boolean]
|
188
181
|
#
|
189
182
|
# @api private
|
190
|
-
#
|
191
183
|
def stop_work?
|
192
184
|
@stop || !source.next? || sink.stop?
|
193
185
|
end
|
194
186
|
|
195
|
-
#
|
187
|
+
# Job source
|
196
188
|
#
|
197
189
|
# @return [Source]
|
198
190
|
#
|
199
191
|
# @api private
|
200
|
-
#
|
201
192
|
def source
|
202
193
|
config.source
|
203
194
|
end
|
204
195
|
|
205
|
-
#
|
196
|
+
# Job result sink
|
206
197
|
#
|
207
198
|
# @return [Sink]
|
208
199
|
#
|
209
200
|
# @api private
|
210
|
-
#
|
211
201
|
def sink
|
212
202
|
config.sink
|
213
203
|
end
|