node_mutation 1.21.0 → 1.21.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 +9 -0
- data/Gemfile.lock +2 -2
- data/README.md +5 -0
- data/lib/node_mutation/action/group_action.rb +0 -2
- data/lib/node_mutation/action.rb +8 -1
- data/lib/node_mutation/result.rb +1 -4
- data/lib/node_mutation/struct.rb +1 -1
- 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: e1f63b9205f77a333104b27187a81f8643d25771c440308eaeebe61133a18128
|
4
|
+
data.tar.gz: 48002aeb8687c03ee62b0cd41f3ac76793873c0039caa9f73d6203ad6aab645d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 249ff1d6f50cb3395d3d8307bbfeedaaa642c9eec532b130fecdb07653bb608bf697ebfa0b4e9c0f6209a323e85c1bc7207aa8141e80f2a81dd258e5e22cbef7
|
7
|
+
data.tar.gz: cbcedfcfa1a60fc2020301d66bd3f56b055d7a150a7db14a562fa927b651abf4ab0e575ab66473ebf150950beb5856f17c0a0264ebd5eeebfc0c744faa6934ca
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# NodeMutation
|
2
2
|
|
3
|
+
## 1.12.2 (2023-10-02)
|
4
|
+
|
5
|
+
* Result saves group actions properly
|
6
|
+
|
7
|
+
## 1.21.1 (2023-10-01)
|
8
|
+
|
9
|
+
* Update `parser_node_ext` to 1.2.1
|
10
|
+
* Add `actions` to `NodeMutation::Struct::Action`
|
11
|
+
|
3
12
|
## 1.21.0 (2023-09-26)
|
4
13
|
|
5
14
|
* Rename `combine` dsl to `group`
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
node_mutation (1.21.
|
4
|
+
node_mutation (1.21.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -37,7 +37,7 @@ GEM
|
|
37
37
|
parser (3.2.2.3)
|
38
38
|
ast (~> 2.4.1)
|
39
39
|
racc
|
40
|
-
parser_node_ext (1.2.
|
40
|
+
parser_node_ext (1.2.1)
|
41
41
|
parser
|
42
42
|
prettier_print (1.2.1)
|
43
43
|
pry (0.14.1)
|
data/README.md
CHANGED
@@ -51,6 +51,11 @@ mutation.replace_with node, 'create {{arguments}}'
|
|
51
51
|
mutation.wrap node, prefix: 'module Foo', suffix: 'end', newline: true
|
52
52
|
# no operation
|
53
53
|
mutation.noop
|
54
|
+
# group actions
|
55
|
+
mutation.group do
|
56
|
+
mutation.delete node, :message, :dot
|
57
|
+
mutation.replace node, 'receiver.caller.message', with: 'flat_map'
|
58
|
+
end
|
54
59
|
```
|
55
60
|
|
56
61
|
3. process actions and write the new source code to file:
|
data/lib/node_mutation/action.rb
CHANGED
@@ -8,7 +8,9 @@ class NodeMutation::Action
|
|
8
8
|
# @return [Integer] end position
|
9
9
|
# @!attribute [rw] type
|
10
10
|
# @return [Symbol] action type, :insert, :replace or :delete
|
11
|
-
|
11
|
+
# @!attribute [rw] actions
|
12
|
+
# @return [Array<NodeMutation::Action>] child actions
|
13
|
+
attr_accessor :start, :end, :type, :actions
|
12
14
|
|
13
15
|
# Initialize an action.
|
14
16
|
#
|
@@ -39,6 +41,11 @@ class NodeMutation::Action
|
|
39
41
|
end
|
40
42
|
end
|
41
43
|
|
44
|
+
def to_struct
|
45
|
+
to_struct_actions = @actions ? @actions.map(&:to_struct) : nil
|
46
|
+
NodeMutation::Struct::Action.new(@type, @start, @end, new_code, to_struct_actions)
|
47
|
+
end
|
48
|
+
|
42
49
|
protected
|
43
50
|
|
44
51
|
# Calculate the begin the end positions.
|
data/lib/node_mutation/result.rb
CHANGED
@@ -19,10 +19,7 @@ class NodeMutation::Result
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def actions=(actions)
|
22
|
-
@actions =
|
23
|
-
actions.map { |action|
|
24
|
-
NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code)
|
25
|
-
}
|
22
|
+
@actions = actions.map(&:to_struct)
|
26
23
|
end
|
27
24
|
|
28
25
|
def to_json(*args)
|
data/lib/node_mutation/struct.rb
CHANGED
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.21.
|
4
|
+
version: 1.21.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: 2023-
|
11
|
+
date: 2023-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ast node mutation apis
|
14
14
|
email:
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.4.
|
76
|
+
rubygems_version: 3.4.20
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: ast node mutation apis
|