node_mutation 1.2.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +0 -1
- data/Gemfile.lock +6 -8
- data/lib/node_mutation/result.rb +4 -0
- data/lib/node_mutation/version.rb +1 -1
- data/lib/node_mutation.rb +28 -5
- data/node_mutation.gemspec +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e39eb120d51bf9d1839013e1e0b408c1d9f8eefc2eb2767e594f83e01171d323
|
4
|
+
data.tar.gz: 63688a3c83e512004a010d29a373c91f8b542fe8ce1f8ccd16c89ebd8b059103
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1089cb5497135200f0b935fb2c4a3c2537581b5c53bedd8c2ca9392fc6a989de764f116f90040628b4f06f24a8cf29998d1ad7330a37fe4d29026b71d558c2e
|
7
|
+
data.tar.gz: dfa661d9080738bf60f486ea05eba4f7fea7bb8320d7a76953ccdb00498d71f6c8070917ff2c0169aa351e9276f7317f1cbd7044c5e3039e88b12feabc0f53cd
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,19 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
node_mutation (1.
|
5
|
-
activesupport
|
4
|
+
node_mutation (1.3.0)
|
5
|
+
activesupport (< 7.0.0)
|
6
6
|
erubis
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
activesupport (
|
11
|
+
activesupport (6.1.7)
|
12
12
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
13
|
i18n (>= 1.6, < 2)
|
14
14
|
minitest (>= 5.1)
|
15
15
|
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
16
17
|
ast (2.4.2)
|
17
18
|
coderay (1.1.3)
|
18
19
|
concurrent-ruby (1.1.10)
|
@@ -41,7 +42,7 @@ GEM
|
|
41
42
|
rb-inotify (~> 0.9, >= 0.9.10)
|
42
43
|
lumberjack (1.2.8)
|
43
44
|
method_source (1.0.0)
|
44
|
-
minitest (5.16.
|
45
|
+
minitest (5.16.3)
|
45
46
|
nenv (0.3.0)
|
46
47
|
notiffany (0.1.3)
|
47
48
|
nenv (~> 0.1)
|
@@ -50,9 +51,6 @@ GEM
|
|
50
51
|
ast (~> 2.4.1)
|
51
52
|
parser_node_ext (0.4.0)
|
52
53
|
parser
|
53
|
-
pp (0.3.0)
|
54
|
-
prettyprint
|
55
|
-
prettyprint (0.1.1)
|
56
54
|
pry (0.14.1)
|
57
55
|
coderay (~> 1.1)
|
58
56
|
method_source (~> 1.0)
|
@@ -77,6 +75,7 @@ GEM
|
|
77
75
|
thor (1.2.1)
|
78
76
|
tzinfo (2.0.5)
|
79
77
|
concurrent-ruby (~> 1.0)
|
78
|
+
zeitwerk (2.6.0)
|
80
79
|
|
81
80
|
PLATFORMS
|
82
81
|
x86_64-darwin-21
|
@@ -88,7 +87,6 @@ DEPENDENCIES
|
|
88
87
|
node_mutation!
|
89
88
|
parser
|
90
89
|
parser_node_ext
|
91
|
-
pp
|
92
90
|
rake (~> 13.0)
|
93
91
|
rspec (~> 3.0)
|
94
92
|
|
data/lib/node_mutation/result.rb
CHANGED
data/lib/node_mutation.rb
CHANGED
@@ -207,18 +207,16 @@ class NodeMutation
|
|
207
207
|
@actions << WrapAction.new(node, with: with).process
|
208
208
|
end
|
209
209
|
|
210
|
-
#
|
211
|
-
# rewrite the source code based on all actions,
|
212
|
-
# then write the new source code back to the file.
|
210
|
+
# Process actions and return the new source.
|
213
211
|
#
|
214
212
|
# If there's an action range conflict,
|
215
213
|
# it will raise a ConflictActionError if strategy is set to THROW_ERROR,
|
216
214
|
# it will process all non conflicted actions and return `{ conflict: true }`
|
217
215
|
# if strategy is set to KEEP_RUNNING.
|
218
|
-
# @return {
|
216
|
+
# @return {NodeMutation::Result}
|
219
217
|
def process
|
220
218
|
if @actions.length == 0
|
221
|
-
return NodeMutation::Result.new(affected: false)
|
219
|
+
return NodeMutation::Result.new(affected: false, conflicted: false)
|
222
220
|
end
|
223
221
|
|
224
222
|
conflict_actions = []
|
@@ -238,6 +236,31 @@ class NodeMutation
|
|
238
236
|
)
|
239
237
|
end
|
240
238
|
|
239
|
+
# Test actions and return the actions.
|
240
|
+
#
|
241
|
+
# If there's an action range conflict,
|
242
|
+
# it will raise a ConflictActionError if strategy is set to THROW_ERROR,
|
243
|
+
# it will process all non conflicted actions and return `{ conflict: true }`
|
244
|
+
# if strategy is set to KEEP_RUNNING.
|
245
|
+
# @return {NodeMutation::Result}
|
246
|
+
def test
|
247
|
+
if @actions.length == 0
|
248
|
+
return NodeMutation::Result.new(affected: false, conflicted: false, actions: [])
|
249
|
+
end
|
250
|
+
|
251
|
+
conflict_actions = []
|
252
|
+
@actions.sort_by! { |action| [action.start, action.end] }
|
253
|
+
conflict_actions = get_conflict_actions
|
254
|
+
if conflict_actions.size > 0 && NodeMutation.strategy == THROW_ERROR
|
255
|
+
raise ConflictActionError, "mutation actions are conflicted"
|
256
|
+
end
|
257
|
+
NodeMutation::Result.new(
|
258
|
+
affected: true,
|
259
|
+
conflicted: !conflict_actions.empty?,
|
260
|
+
actions: @actions
|
261
|
+
)
|
262
|
+
end
|
263
|
+
|
241
264
|
private
|
242
265
|
|
243
266
|
# It changes source code from bottom to top, and it can change source code twice at the same time,
|
data/node_mutation.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.require_paths = ["lib"]
|
30
30
|
|
31
31
|
# Uncomment to register a new dependency of your gem
|
32
|
-
spec.add_dependency "activesupport"
|
32
|
+
spec.add_dependency "activesupport", "< 7.0.0"
|
33
33
|
spec.add_dependency "erubis"
|
34
34
|
|
35
35
|
# For more information and examples about making a new gem, check out our
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node_mutation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "<"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "<"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 7.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: erubis
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|