node_mutation 1.19.0 → 1.19.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f0f3e24e2bcc4c8de744080aeccf3b82741534b6d5681c582d4ea91318b156b5
4
- data.tar.gz: 33a39316e45592619c5ad3d520c6cb42411e41b6704bc1c52d840e0414c46322
3
+ metadata.gz: 07cffea51271875fe053793222f92ba3ed88fb977e90c875d7f6096b969de898
4
+ data.tar.gz: f532736d3c384703dca1cfa389b4cad86fb810d8b063540ad50774af649786c8
5
5
  SHA512:
6
- metadata.gz: 0064ba628586533f3687a2af1cdbfbd0af32a274bc127e7da97d72c5b4d7517c1f0a8658fba363762ede790b3ee1071fed6b702e75932f5e57719ff0a6f7c023
7
- data.tar.gz: 231809db15865e3c260b2aa67edf5335968968299b5e5135571a12631bb90ed563fdd1a9cd59996d909acee42b4770b1ca98c58734fcee26ea1255a2eb525371
6
+ metadata.gz: c900a66575d3c35780bf64f33aa3452a5cd558ba7e55cde46f0c322f5da8cf54f17b052683a71df74c51df7efda8e3626e451f987fd1ea5f3995afd3f72635f4
7
+ data.tar.gz: f2335ad6e3ad0a5dcd1ec36d0f595c114d703dea847f36d6b1235a4ceb1cc92e6fe27522cd941da0e34e3864ccb9abd169f9f83e02a9306ab6075f8d2ea1c09d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.19.1 (2023-06-22)
4
+
5
+ * Add `to_string` function
6
+
3
7
  ## 1.19.0 (2023-06-22)
4
8
 
5
9
  * Drop support for function in `child_node_by_name`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.19.0)
4
+ node_mutation (1.19.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.19.0"
4
+ VERSION = "1.19.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: node_mutation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang