node_mutation 1.18.2 → 1.18.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66c10f74e41d63887a03af240cdfe99086395505ef43e14dab21f9d7ece562ac
4
- data.tar.gz: 73728f0f84e095b7f97b65511cbd75fc01bcb7b8e9f2a56965dda31bfb7da622
3
+ metadata.gz: f841956c32adce81a0124670b81a180dc1a5c607946de843ee4ffb18df46eb59
4
+ data.tar.gz: 1f962b025780338e39f674d1a130a42ab85b7ed499630e77151ffb8cf8fcfbdc
5
5
  SHA512:
6
- metadata.gz: 030fff9b3477f6c8f35454f01cf24f430b1bcabd9f2002c97ebb6f7579db777432e3cddd40bb2c188bcedfab408c255b8aa554a03410df375b51e0ad498d6240
7
- data.tar.gz: 34078dd910cacc649c23334d13dea818d728cef40d7b130325b204bfb34ec46a07691bb98c94c6223c5d40cf808db1e83002473907ca94dededc661652b0bf85
6
+ metadata.gz: a67239ac105f6ba64aa52a67c228310e4b13a8b2f0076343f006faf562c0a4cf00d3eb83212fdd75d3c63421c8763a67a1afb2c067dceaf9e1fcd25d8fb935e5
7
+ data.tar.gz: 0b6c56d6114b997743a33e96c19976ceb9cdc15c0e1b515acf092e1275149c5ddb93359707700cca9b274decf1e73690ed12b23c8280eccda1500e9a5e88ccf4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.18.3 (2023-06-03)
4
+
5
+ * Fix rbs syntax
6
+
3
7
  ## 1.18.2 (2023-05-21)
4
8
 
5
9
  * Use `rindex` to calculate "do" index
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.18.2)
4
+ node_mutation (1.18.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -17,7 +17,8 @@ class NodeMutation::IndentAction < NodeMutation::Action
17
17
  # @return [String] rewritten code.
18
18
  def new_code
19
19
  source = NodeMutation.adapter.get_source(@node)
20
- source.each_line.map { |line| ' ' * NodeMutation.tab_width * @tab_size + line }.join
20
+ source.each_line.map { |line| (' ' * NodeMutation.tab_width * @tab_size) + line }
21
+ .join
21
22
  end
22
23
 
23
24
  private
@@ -106,7 +106,9 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
106
106
  node.body.last.loc.expression.end_pos
107
107
  )
108
108
  end
109
- when %i[class name], %i[const name], %i[cvar name], %i[def name], %i[defs name], %i[gvar name], %i[ivar name], %i[lvar name]
109
+ when %i[class name], %i[const name], %i[cvar name], %i[def name], %i[defs name],
110
+ %i[gvar name], %i[ivar name], %i[lvar name]
111
+
110
112
  NodeMutation::Struct::Range.new(node.loc.name.begin_pos, node.loc.name.end_pos)
111
113
  when %i[const double_colon]
112
114
  NodeMutation::Struct::Range.new(node.loc.double_colon.begin_pos, node.loc.double_colon.end_pos)
@@ -19,7 +19,10 @@ class NodeMutation::Result
19
19
  end
20
20
 
21
21
  def actions=(actions)
22
- @actions = actions.map { |action| NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code) }
22
+ @actions =
23
+ actions.map { |action|
24
+ NodeMutation::Struct::Action.new(action.type, action.start, action.end, action.new_code)
25
+ }
23
26
  end
24
27
 
25
28
  def to_json(*args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.18.2"
4
+ VERSION = "1.18.3"
5
5
  end
data/lib/node_mutation.rb CHANGED
@@ -208,8 +208,8 @@ class NodeMutation
208
208
  def wrap(node, prefix:, suffix:, newline: false)
209
209
  if newline
210
210
  indentation = NodeMutation.adapter.get_start_loc(node).column
211
- @actions << InsertAction.new(node, prefix + "\n" + ' ' * indentation, at: 'beginning').process
212
- @actions << InsertAction.new(node, "\n" + ' ' * indentation + suffix, at: 'end').process
211
+ @actions << InsertAction.new(node, prefix + "\n" + (' ' * indentation), at: 'beginning').process
212
+ @actions << InsertAction.new(node, "\n" + (' ' * indentation) + suffix, at: 'end').process
213
213
  @actions << IndentAction.new(node).process
214
214
  else
215
215
  @actions << InsertAction.new(node, prefix, at: 'beginning').process
@@ -1,18 +1,18 @@
1
1
  class NodeMutation::Struct
2
2
  class Action < ::Struct
3
- prop :type, Symbol
4
- prop :start, Integer
5
- prop :end, Integer
6
- prop :new_code, String
3
+ atr_accessor type (): Symbol
4
+ atr_accessor start (): Integer
5
+ atr_accessor end (): Integer
6
+ atr_accessor new_code (): String
7
7
  end
8
8
 
9
9
  class Location < ::Struct
10
- prop :line, Integer
11
- prop :column, Integer
10
+ atr_accessor line (): Integer
11
+ atr_accessor column (): Integer
12
12
  end
13
13
 
14
14
  class Range < ::Struct
15
- prop :start, Integer
16
- prop :end, Integer
15
+ atr_accessor start (): Integer
16
+ atr_accessor end (): Integer
17
17
  end
18
18
  end
@@ -21,7 +21,7 @@ module NodeMutation[T]
21
21
 
22
22
  def append: (node: T, code: String) -> void
23
23
 
24
- def delete: (node: T, *selectors: Array[String], **options: { and_comma: bool }) -> void
24
+ def delete: (node: T, selectors: Array[String], and_comma: bool) -> void
25
25
 
26
26
  def indent: (node: T, ?tab_size: Integer) -> void
27
27
 
@@ -29,9 +29,9 @@ module NodeMutation[T]
29
29
 
30
30
  def prepend: (node: T, code: String) -> void
31
31
 
32
- def remove: (node: T, **options: { and_comma: bool }) -> void
32
+ def remove: (node: T, and_comma: bool) -> void
33
33
 
34
- def replace: (node: T, *selectors: Array[String], with: String) -> void
34
+ def replace: (node: T, selectors: Array[String], with: String) -> void
35
35
 
36
36
  def replace_with: (node: T, code: String) -> void
37
37
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: node_mutation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.2
4
+ version: 1.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-21 00:00:00.000000000 Z
11
+ date: 2023-06-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ast node mutation apis
14
14
  email: