node_mutation 1.12.1 → 1.12.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: 377cc05adfb7a9f55647b1850a325d9ddcb20004e2574af39657248bd05a51b4
4
- data.tar.gz: 233c08e3fa49855270f62c11e1d9587b77886e9a6edded54f27096a9dc951849
3
+ metadata.gz: 3c09d8d3b9a1b4185382f7117d766d6220d9f9cbe4851f86af6c99e32af2ba88
4
+ data.tar.gz: e392926a8e647d85028c5d41c3890bea801f47dae425b885ff1892aaf8b396b2
5
5
  SHA512:
6
- metadata.gz: 593a0319dc715d587137e840d66694ed6f8c5d4a73312eb20847eee8383b4f47910f25d1d14f1e3fb95bee3ee1ab6627a08fdd2fa40c837c1a4d8e3422237066
7
- data.tar.gz: 9aca39fb58ae4b02687a310fdcc3a7f388ebc86bcdce29b8efff24069077e3ed9194c9556bd833737160c8a220af87c010eedfd588e71f98c5b3bdae0d578cd3
6
+ metadata.gz: 6bb3a9d27929b69bba72947e39160163d671a7ac493d0b861057b1e08fd651e4bbcadc90f56d9b4ae8a7ee825aa1c207af7136f1b2afb11a7533b0c9898d211d
7
+ data.tar.gz: '0943c3dfd903a6b9e789cfcb7289bbe2fed18f37a1176210ceff267233383c879813b67e3ff2e915e8c179f6144afe9c5ba5fb8baf3055845a93dd2885a58fce'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.12.3 (2023-03-30)
4
+
5
+ * `remove_whitespace` for both before and after whitespace
6
+
7
+ ## 1.12.2 (2023-03-25)
8
+
9
+ * `remove_whitespace` handles more cases
10
+
3
11
  ## 1.12.1 (2023-03-23)
4
12
 
5
13
  * Define `Action`, `Location` and `Range` in `NodeMutation::Struct`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.12.1)
4
+ node_mutation (1.12.3)
5
5
  erubis
6
6
 
7
7
  GEM
@@ -54,12 +54,21 @@ class NodeMutation::Action
54
54
  end
55
55
 
56
56
  # remove unused whitespace.
57
- # e.g. `foobar(foo, bar)`, if we remove `foo`, the whitespace should also be removed,
58
- # the code should be changed to `foobar(bar)`.
57
+ # e.g. `%i[foo bar]`, if we remove `foo`, the whitespace should also be removed,
58
+ # the code should be changed to `%i[bar]`.
59
59
  def remove_whitespace
60
- return unless [' ', '('].include?(file_source[@start - 1])
60
+ if file_source[@end] == ' ' && file_source[@start - 1] == ' '
61
+ @start -= 1
62
+ @end += 1
63
+ return
64
+ end
65
+
66
+ if ["\n", ';', ')', ']', '}', '|', nil].include?(file_source[@end]) && file_source[@start - 1] == ' '
67
+ @start -= 1
68
+ return
69
+ end
61
70
 
62
- while file_source[@end] == ' '
71
+ if ['(', '[', '{', '|'].include?(file_source[@start - 1]) && file_source[@end] == ' '
63
72
  @end += 1
64
73
  end
65
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.12.1"
4
+ VERSION = "1.12.3"
5
5
  end
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.12.1
4
+ version: 1.12.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-03-23 00:00:00.000000000 Z
11
+ date: 2023-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -83,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  requirements: []
86
- rubygems_version: 3.4.7
86
+ rubygems_version: 3.4.6
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: ast node mutation apis