node_mutation 1.19.0 → 1.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/node_mutation/adapter/parser.rb +6 -0
- data/lib/node_mutation/adapter/syntax_tree.rb +6 -0
- data/lib/node_mutation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07cffea51271875fe053793222f92ba3ed88fb977e90c875d7f6096b969de898
|
4
|
+
data.tar.gz: f532736d3c384703dca1cfa389b4cad86fb810d8b063540ad50774af649786c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c900a66575d3c35780bf64f33aa3452a5cd558ba7e55cde46f0c322f5da8cf54f17b052683a71df74c51df7efda8e3626e451f987fd1ea5f3995afd3f72635f4
|
7
|
+
data.tar.gz: f2335ad6e3ad0a5dcd1ec36d0f595c114d703dea847f36d6b1235a4ceb1cc92e6fe27522cd941da0e34e3864ccb9abd169f9f83e02a9306ab6075f8d2ea1c09d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -47,6 +47,10 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
47
47
|
# node = Parser::CurrentRuby.parse("'foo'")
|
48
48
|
# rewritten_source(node, 'to_symbol') => ':foo'
|
49
49
|
#
|
50
|
+
# # to_string for sym node
|
51
|
+
# node = Parser::CurrentRuby.parse(":foo")
|
52
|
+
# rewritten_source(node, 'to_string') => 'foo'
|
53
|
+
#
|
50
54
|
# # to_lambda_literal for block node
|
51
55
|
# node = Parser::CurrentRuby.parse('lambda { foobar }')
|
52
56
|
# rewritten_source(node, 'to_lambda_literal') => '-> { foobar }'
|
@@ -276,6 +280,8 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
276
280
|
child_node = node.send(direct_child_name)
|
277
281
|
elsif direct_child_name == 'to_symbol' && node.type == :str
|
278
282
|
child_node = ":#{node.to_value}"
|
283
|
+
elsif direct_child_name == 'to_string' && node.type == :sym
|
284
|
+
child_node = node.to_value.to_s
|
279
285
|
elsif direct_child_name == 'to_single_quote' && node.type == :str
|
280
286
|
child_node = "'#{node.to_value}'"
|
281
287
|
elsif direct_child_name == 'to_double_quote' && node.type == :str
|
@@ -44,6 +44,10 @@ class NodeMutation::SyntaxTreeAdapter < NodeMutation::Adapter
|
|
44
44
|
# node = SyntaxTree::Parser.new("'foo'").parse.statements.body.first
|
45
45
|
# rewritten_source(node, 'to_symbol') => ':foo'
|
46
46
|
#
|
47
|
+
# # to_string for SymbolLiteral node
|
48
|
+
# node = SyntaxTree::Parser.new(":foo").parse.statements.body.first
|
49
|
+
# rewritten_source(node, 'to_string') => 'foo'
|
50
|
+
#
|
47
51
|
# # to_lambda_literal for MethodAddBlock node
|
48
52
|
# node = SyntaxTree::Parser.new('lambda { foobar }').parse.statements.body.first
|
49
53
|
# rewritten_source(node, 'to_lambda_literal') => '-> { foobar }'
|
@@ -167,6 +171,8 @@ class NodeMutation::SyntaxTreeAdapter < NodeMutation::Adapter
|
|
167
171
|
child_node = node.send(direct_child_name)
|
168
172
|
elsif direct_child_name == 'to_symbol' && node.is_a?(SyntaxTree::StringLiteral)
|
169
173
|
child_node = ":#{node.to_value}"
|
174
|
+
elsif direct_child_name == 'to_string' && node.is_a?(SyntaxTree::SymbolLiteral)
|
175
|
+
child_node = node.to_value.to_s
|
170
176
|
elsif direct_child_name == 'to_single_quote' && node.is_a?(SyntaxTree::StringLiteral)
|
171
177
|
child_node = "'#{node.to_value}'"
|
172
178
|
elsif direct_child_name == 'to_double_quote' && node.is_a?(SyntaxTree::StringLiteral)
|