node_mutation 1.7.1 → 1.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 +8 -0
- data/Gemfile.lock +3 -2
- data/lib/node_mutation/parser_adapter.rb +6 -4
- data/lib/node_mutation/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e468a837b5ab1417a0675f92ae5848b87b66cfe9605a3ce56142f58859ba7036
|
4
|
+
data.tar.gz: 898a9e080a406c84027b3ea84bf76826c8deb2ea36c406a767774c7610809dea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40498dd85e42e77268ed72851692c906221e2ea167765867155a30c0e992b6e4a8c4e89cfee7295743dd94f6d3405dcaeabeb845be3a3dc1a7cb473983ba6bf2
|
7
|
+
data.tar.gz: f99ba22c58428b002285e9dd6e959b993725216265457d2df8a4b7fd934537861ca04ce6955bedc8dea0fb29efb0174e44a53a7ae6e07c9aad2e68daa2dab154
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# NodeMutation
|
2
2
|
|
3
|
+
## 1.8.1 (2022-12-26)
|
4
|
+
|
5
|
+
* `child_node_by_name` index starts from `0`
|
6
|
+
|
7
|
+
## 1.8.0 (2022-12-26)
|
8
|
+
|
9
|
+
* `child_node_range` index starts from `0`
|
10
|
+
|
3
11
|
## 1.7.1 (2022-10-26)
|
4
12
|
|
5
13
|
* Return empty string for `NilClass` in `ParserAdapter#rewritten_source`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
node_mutation (1.
|
4
|
+
node_mutation (1.8.1)
|
5
5
|
activesupport (< 7.0.0)
|
6
6
|
erubis
|
7
7
|
|
@@ -75,10 +75,11 @@ GEM
|
|
75
75
|
thor (1.2.1)
|
76
76
|
tzinfo (2.0.5)
|
77
77
|
concurrent-ruby (~> 1.0)
|
78
|
-
zeitwerk (2.6.
|
78
|
+
zeitwerk (2.6.6)
|
79
79
|
|
80
80
|
PLATFORMS
|
81
81
|
x86_64-darwin-21
|
82
|
+
x86_64-darwin-22
|
82
83
|
x86_64-linux
|
83
84
|
|
84
85
|
DEPENDENCIES
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
INDEX_REGEXP = /\A-?\d+\z/
|
4
|
+
|
3
5
|
class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
4
6
|
def get_source(node)
|
5
7
|
if node.is_a?(Array)
|
@@ -60,8 +62,8 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
60
62
|
direct_child_name, nested_child_name = child_name.to_s.split('.', 2)
|
61
63
|
|
62
64
|
if node.is_a?(Array)
|
63
|
-
if direct_child_name =~
|
64
|
-
child_node = node[direct_child_name.to_i
|
65
|
+
if direct_child_name =~ INDEX_REGEXP
|
66
|
+
child_node = node[direct_child_name.to_i]
|
65
67
|
raise NodeMutation::MethodNotSupported, "#{direct_child_name} is not supported for #{get_source(node)}" unless child_node
|
66
68
|
return child_node_range(child_node, nested_child_name) if nested_child_name
|
67
69
|
return OpenStruct.new(start: child_node.loc.expression.begin_pos, end: child_node.loc.expression.end_pos)
|
@@ -163,8 +165,8 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
163
165
|
direct_child_name, nested_child_name = child_name.to_s.split('.', 2)
|
164
166
|
|
165
167
|
if node.is_a?(Array)
|
166
|
-
if direct_child_name =~
|
167
|
-
child_node = node[direct_child_name.to_i
|
168
|
+
if direct_child_name =~ INDEX_REGEXP
|
169
|
+
child_node = node[direct_child_name.to_i]
|
168
170
|
raise NodeMutation::MethodNotSupported, "#{direct_child_name} is not supported for #{get_source(node)}" unless child_node
|
169
171
|
return child_node_by_name(child_node, nested_child_name) if nested_child_name
|
170
172
|
return child_node
|
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.
|
4
|
+
version: 1.8.1
|
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-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.3.
|
99
|
+
rubygems_version: 3.3.26
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: ast node mutation apis
|