node_mutation 1.15.0 → 1.15.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: 11054e72fcf35b7caeb2cee67b421206da2f980d4d1f23afa08f9db75f112f75
4
- data.tar.gz: 4dde234a2f4716b82d042b7d9f094469da04942cdca669c40a7d745f75480b77
3
+ metadata.gz: 382d91776358172b2310f5281edc413bf6066da9e333e150fa14a068219058bf
4
+ data.tar.gz: 5bdeef13cc69a5f4e6b9abef45ed95eeab57b13e95bed01a8fb0f25b02788140
5
5
  SHA512:
6
- metadata.gz: 5bfc255f3b2bf599debc4c8d882999d3083f89ec2e9cdb81aa2eb1d4245e65cafb61c9f9ee7db7286b4efddf66b96cb00742696f5215beab1b3cc847c2025b40
7
- data.tar.gz: 7c9063056156b1ee4accd50ad204040209c55ca096f543ecccc5f66175b1213a5611a4815263058514d81466e440d6cdf36f65c7208d048c48c3f3736e516706
6
+ metadata.gz: b35c57db840700ed2a53ea3f0b1713185da7c36b4759537709ce726cf1094f862dcdd9cc2e5a19cdb99b0ef34ebe1436414e17c35915f6694b3c7ee66bf4a163
7
+ data.tar.gz: 2ad6b1ec1f27bad428cc299ffb95f3fce4bd57338365a60707736ae9936aaf15f445d89d8cf339224f4994391907a9df6d3e7ee2dfb2cc394782c2b83261645f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.15.1 (2023-04-17)
4
+
5
+ * Fix `wrap` code for newline
6
+
3
7
  ## 1.15.0 (2023-04-17)
4
8
 
5
9
  * Add `indent` action
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.15.0)
4
+ node_mutation (1.15.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.15.0"
4
+ VERSION = "1.15.1"
5
5
  end
data/lib/node_mutation.rb CHANGED
@@ -205,9 +205,15 @@ class NodeMutation
205
205
  # end
206
206
  # end
207
207
  def wrap(node, prefix:, suffix:, newline: false)
208
- @actions << InsertAction.new(node, prefix, at: 'beginning').process
209
- @actions << InsertAction.new(node, suffix, at: 'end').process
210
- @actions << IndentAction.new(node).process if newline
208
+ if newline
209
+ indentation = NodeMutation.adapter.get_start_loc(node).column
210
+ @actions << InsertAction.new(node, prefix + "\n" + ' ' * indentation, at: 'beginning').process
211
+ @actions << InsertAction.new(node, "\n" + ' ' * indentation + suffix, at: 'end').process
212
+ @actions << IndentAction.new(node).process
213
+ else
214
+ @actions << InsertAction.new(node, prefix, at: 'beginning').process
215
+ @actions << InsertAction.new(node, suffix, at: 'end').process
216
+ end
211
217
  end
212
218
 
213
219
  # No operation.
@@ -33,7 +33,7 @@ module NodeMutation[T]
33
33
 
34
34
  def replace_with: (node: T, code: String) -> void
35
35
 
36
- def wrap: (node: T, with: String) -> void
36
+ def wrap: (node: T, prefix: String, suffix: String, newline: bool) -> void
37
37
 
38
38
  def noop: (node: T) -> void
39
39
 
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.15.0
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang