node_mutation 1.21.0 → 1.21.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bac003e717da366c7a0d9e1e0ee939db7173805fa2f9882b9141d089503cf00
4
- data.tar.gz: 0e1a8f58718b689cb50bd5177496cc0b782594abff2b90cc532f3770fffce6fe
3
+ metadata.gz: e659aa61170c013d38f7ae7fb18d7ce236b588cdd573d62af6a3eab683216a9f
4
+ data.tar.gz: 9fe3a31666deda95fef8cfd668e09b880d484e6763483ec573b3e5869e8b593b
5
5
  SHA512:
6
- metadata.gz: dee5df5d9cc61048b5b16b916527a8a031c80e16ff967bc547d65336a524bfd87e7135ebd72a8ac0aa1f3da6379520949c07d8a7c52baa13ea4a9d2a628c8318
7
- data.tar.gz: 3252841fb0ec840591e21bcd28a5ab987271b6900664b7cd25397f7254d93130903d79f328763e67667bd5671101ec449e260a1a54b399939e5fdc9ff90910ff
6
+ metadata.gz: a1f3b204d8cb0e74e7d9afc52893e7b2930ac51104ae61975406d93de2c4e617fef2afd12e57e73f15efd6d9ad11a19a57c2adcad14893b99f778dd0ebbde0d5
7
+ data.tar.gz: a193a00b15323f8edcebd30dbd225c0e82a5a8831e4d3ae54a16aa211c0ba7e694283aea25353e081cb94e7db3a707c856de73837f6da04c1fa4700f522911e1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.21.1 (2023-10-01)
4
+
5
+ * Update `parser_node_ext` to 1.2.1
6
+ * Add `actions` to `NodeMutation::Struct::Action`
7
+
3
8
  ## 1.21.0 (2023-09-26)
4
9
 
5
10
  * 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.0)
4
+ node_mutation (1.21.1)
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.0)
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:
@@ -4,8 +4,6 @@
4
4
  class NodeMutation::GroupAction < NodeMutation::Action
5
5
  DEFAULT_START = 2**30
6
6
 
7
- attr_accessor :actions
8
-
9
7
  def initialize
10
8
  @actions = []
11
9
  @type = :group
@@ -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
- attr_accessor :start, :end, :type
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
  #
@@ -21,7 +21,7 @@ class NodeMutation::Result
21
21
  def actions=(actions)
22
22
  @actions =
23
23
  actions.map { |action|
24
- NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code)
24
+ NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code, action.actions)
25
25
  }
26
26
  end
27
27
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation::Struct
4
- Action = Struct.new(:type, :start, :end, :new_code)
4
+ Action = Struct.new(:type, :start, :end, :new_code, :actions)
5
5
  Location = Struct.new(:line, :column)
6
6
  Range = Struct.new(:start, :end)
7
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.21.0"
4
+ VERSION = "1.21.1"
5
5
  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.21.0
4
+ version: 1.21.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: 2023-09-25 00:00:00.000000000 Z
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.18
76
+ rubygems_version: 3.4.20
77
77
  signing_key:
78
78
  specification_version: 4
79
79
  summary: ast node mutation apis