synvert-core 0.53.0 → 0.54.0
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 +4 -0
- data/README.md +2 -2
- data/lib/synvert/core/rewriter/action/delete_action.rb +3 -3
- data/lib/synvert/core/rewriter/action/insert_action.rb +1 -1
- data/lib/synvert/core/rewriter/instance.rb +4 -4
- data/lib/synvert/core/rewriter/scope/goto_scope.rb +4 -4
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/scope/goto_scope_spec.rb +1 -1
- 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: 1c7ee99e848625ed3bad729d3e08186370d5fb58d4412fb1d09d89bf15559a22
|
4
|
+
data.tar.gz: 30f16d4aa02a2a6f6677a5657b24296127869e17c5237a4b63f2d6d1ed658203
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 936f304f6b829be86eb1da55aa110a7b3ed7c249cb9da4a1bc5246a1d687fb8dd7548fe68a2632c4df874c921f829e05ec5cab838373b587db5a3e59b900a0ab
|
7
|
+
data.tar.gz: 15f39e1386ee166762dd3afca86b8d246e3cc8ea0cbdcb5efd15eb9141f911ffcaabaf15a6062f9a6fe31dc720e7242fe4a81633bc12ffa06c18efe431d4d410
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# synvert-core-ruby
|
2
2
|
|
3
|
-
<img src="https://xinminlabs.
|
3
|
+
<img src="https://synvert.xinminlabs.com/img/logo_96.png" alt="logo" width="32" height="32" />
|
4
4
|
|
5
5
|

|
6
6
|
[](http://badge.fury.io/rb/synvert-core)
|
@@ -36,5 +36,5 @@ Or install it yourself as:
|
|
36
36
|
4. Push to the branch (`git push origin my-new-feature`)
|
37
37
|
5. Create a new Pull Request
|
38
38
|
|
39
|
-
[1]: https://xinminlabs.
|
39
|
+
[1]: https://synvert.xinminlabs.com
|
40
40
|
[2]: https://rubydoc.info/github/xinminlabs/synvert-core-ruby/master/frames
|
@@ -1,21 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Synvert::Core
|
4
|
-
#
|
4
|
+
# DeleteAction to delete code.
|
5
5
|
class Rewriter::DeleteAction < Rewriter::Action
|
6
6
|
def initialize(instance, *selectors)
|
7
7
|
super(instance, nil)
|
8
8
|
@selectors = selectors
|
9
9
|
end
|
10
10
|
|
11
|
-
# Begin position of code to
|
11
|
+
# Begin position of code to delete.
|
12
12
|
#
|
13
13
|
# @return [Integer] begin position.
|
14
14
|
def begin_pos
|
15
15
|
@selectors.map { |selector| @node.child_node_range(selector) }.compact.map(&:begin_pos).min
|
16
16
|
end
|
17
17
|
|
18
|
-
# End position of code to
|
18
|
+
# End position of code to delete.
|
19
19
|
#
|
20
20
|
# @return [Integer] end position.
|
21
21
|
def end_pos
|
@@ -139,7 +139,7 @@ module Synvert::Core
|
|
139
139
|
|
140
140
|
# Set current_node properly, process and set current_node back to original current_node.
|
141
141
|
#
|
142
|
-
# @param node [Parser::AST::Node] node set to
|
142
|
+
# @param node [Parser::AST::Node] node set to other_node
|
143
143
|
# @yield process
|
144
144
|
def process_with_other_node(node)
|
145
145
|
original_node = current_node
|
@@ -177,10 +177,10 @@ module Synvert::Core
|
|
177
177
|
# Parse goto_node dsl, it creates a [Synvert::Core::Rewriter::GotoScope] to go to a child node,
|
178
178
|
# then continue operating on the child node.
|
179
179
|
#
|
180
|
-
# @param
|
180
|
+
# @param child_node_name [Symbol|String] the name of the child nodes.
|
181
181
|
# @param block [Block] block code to continue operating on the matching nodes.
|
182
|
-
def goto_node(
|
183
|
-
Rewriter::GotoScope.new(self,
|
182
|
+
def goto_node(child_node_name, &block)
|
183
|
+
Rewriter::GotoScope.new(self, child_node_name, &block).process
|
184
184
|
end
|
185
185
|
|
186
186
|
# Parse if_exist_node dsl, it creates a [Synvert::Core::Rewriter::IfExistCondition] to check
|
@@ -6,11 +6,11 @@ module Synvert::Core
|
|
6
6
|
# Initialize a scope
|
7
7
|
#
|
8
8
|
# @param instance [Synvert::Core::Rewriter::Instance]
|
9
|
-
# @param
|
9
|
+
# @param child_node_name [Symbol|string]
|
10
10
|
# @param block [Block]
|
11
|
-
def initialize(instance,
|
11
|
+
def initialize(instance, child_node_name, &block)
|
12
12
|
@instance = instance
|
13
|
-
@
|
13
|
+
@child_node_name = child_node_name
|
14
14
|
@block = block
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,7 @@ module Synvert::Core
|
|
20
20
|
return unless current_node
|
21
21
|
|
22
22
|
child_node = current_node
|
23
|
-
@
|
23
|
+
@child_node_name.to_s.split('.').each do |child_node_name|
|
24
24
|
child_node = child_node_name.is_a?(Parser::AST::Node) ? child_node_name : child_node.send(child_node_name)
|
25
25
|
end
|
26
26
|
@instance.process_with_other_node child_node do
|
data/lib/synvert/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synvert-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.54.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|