node_mutation 1.6.0 → 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/node_mutation/parser_adapter.rb +3 -2
- data/lib/node_mutation/version.rb +1 -1
- data/lib/node_mutation.rb +9 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b2edcdadf3b7283b4446c8b0da41cb72daa4da3c180042b9e896973a8132cba
|
4
|
+
data.tar.gz: 3fc7cfe62f0e7ea6699b1d3bb9a918f14d1d451bd045b5d82cf09237db3a5c5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d04f31b6f9983e66555cfa640c52af13546cb066468b657db99f6dffcff5d1513a26a6f3bcb58c433b6a700e8db544e638807e9e3ccd30578a979fec0cc58e4
|
7
|
+
data.tar.gz: a35fb59ca28655346782ea46410b34784c965f06b00f66ba6b70a5647695a20e5cfcdf4010a32cf7f4fbf9c44ca3d1e4a37db1860a46f16db1ee8149994bb05c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# NodeMutation
|
2
2
|
|
3
|
+
## 1.6.2 (2022-10-25)
|
4
|
+
|
5
|
+
* Mark same position as conflict action
|
6
|
+
|
7
|
+
## 1.6.1 (2022-10-24)
|
8
|
+
|
9
|
+
* Better error message when node does not respond to a key
|
10
|
+
|
3
11
|
## 1.6.0 (2022-10-19)
|
4
12
|
|
5
13
|
* Raise `NodeMutation::MethodNotSupported` if not respond to child node name
|
data/Gemfile.lock
CHANGED
@@ -13,7 +13,8 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
13
13
|
def rewritten_source(node, code)
|
14
14
|
code.gsub(/{{(.+?)}}/m) do
|
15
15
|
old_code = Regexp.last_match(1)
|
16
|
-
|
16
|
+
first_key = old_code.split('.').first
|
17
|
+
if node.respond_to?(first_key)
|
17
18
|
evaluated = child_node_by_name(node, old_code)
|
18
19
|
case evaluated
|
19
20
|
when Parser::AST::Node
|
@@ -44,7 +45,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
44
45
|
raise "can not parse \"#{code}\""
|
45
46
|
end
|
46
47
|
else
|
47
|
-
raise "
|
48
|
+
raise NodeMutation::MethodNotSupported, "#{first_key} is not supported for #{get_source(node)}"
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
data/lib/node_mutation.rb
CHANGED
@@ -262,13 +262,19 @@ class NodeMutation
|
|
262
262
|
conflict_actions = []
|
263
263
|
return [] if i < 0
|
264
264
|
|
265
|
-
|
265
|
+
begin_pos = @actions[i].start
|
266
|
+
end_pos = @actions[i].end
|
266
267
|
while j > -1
|
267
|
-
if
|
268
|
+
# if we have two insert actions at same position.
|
269
|
+
same_position = begin_pos == @actions[j].start && begin_pos == end_pos && @actions[j].start == @actions[j].end
|
270
|
+
# if we have two actions with overlapped range.
|
271
|
+
overlapped_position = begin_pos < @actions[j].end
|
272
|
+
if same_position || overlapped_position
|
268
273
|
conflict_actions << @actions.delete_at(j)
|
269
274
|
else
|
270
275
|
i = j
|
271
|
-
|
276
|
+
begin_pos = @actions[i].start
|
277
|
+
end_pos = @actions[i].end
|
272
278
|
end
|
273
279
|
j -= 1
|
274
280
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: node_mutation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.2
|
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-10-
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|