lib/node_mutation/adapter/parser.rb in node_mutation-1.19.0 vs lib/node_mutation/adapter/parser.rb in node_mutation-1.19.1
- old
+ new
@@ -45,10 +45,14 @@
#
# # to_symbol for str node
# node = Parser::CurrentRuby.parse("'foo'")
# rewritten_source(node, 'to_symbol') => ':foo'
#
+ # # to_string for sym node
+ # node = Parser::CurrentRuby.parse(":foo")
+ # rewritten_source(node, 'to_string') => 'foo'
+ #
# # to_lambda_literal for block node
# node = Parser::CurrentRuby.parse('lambda { foobar }')
# rewritten_source(node, 'to_lambda_literal') => '-> { foobar }'
#
# # strip_curly_braces for hash node
@@ -274,9 +278,11 @@
if node.respond_to?(direct_child_name)
child_node = node.send(direct_child_name)
elsif direct_child_name == 'to_symbol' && node.type == :str
child_node = ":#{node.to_value}"
+ elsif direct_child_name == 'to_string' && node.type == :sym
+ child_node = node.to_value.to_s
elsif direct_child_name == 'to_single_quote' && node.type == :str
child_node = "'#{node.to_value}'"
elsif direct_child_name == 'to_double_quote' && node.type == :str
child_node = "\"#{node.to_value}\""
elsif direct_child_name == 'to_lambda_literal' && node.type == :block && node.caller.type == :send && node.caller.receiver.nil? && node.caller.message == :lambda