rufo 0.16.0 → 0.16.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +39 -20
- data/lib/rufo/erb_formatter.rb +9 -2
- data/lib/rufo/formatter.rb +19 -2
- data/lib/rufo/version.rb +1 -1
- metadata +3 -4
- data/bin/runtest +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9809eb345a055711f4ad309391cb96106eb90aff1cf09bcce15b537bad34e30
|
4
|
+
data.tar.gz: d77f6a70aeeb5fb6143f1dec1f29d8d645fa834f7a2fd467200c7d02b99a165b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f43322e74c6cbdd90ca355caa0e4d17a9c625e4ea487a40807ecad7a75915531954ac287818c56a1e72566d1f25a6add653fe186d717406f9f3d4c11b8474bf
|
7
|
+
data.tar.gz: c9cd5e085bfe77882b5b1215e5de7d3939ba4de9bae634d750e74bac5000511fdcbc376f6f53e2cdd1ad4703dc1b6d344da96007a2147d579c52ee7113e21510
|
data/CHANGELOG.md
CHANGED
@@ -12,11 +12,30 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
12
12
|
|
13
13
|
### Added
|
14
14
|
|
15
|
+
## [0.16.2] - 2023-07-29
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- Fix Bug: Unexpected EOF with blocks in .html.erb ([#297](https://github.com/ruby-formatter/rufo/issues/297))
|
19
|
+
|
20
|
+
### Changed
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
## [0.16.1] - 2023-05-04
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
- Fix Bug: raises error while formatting pattern matching syntax ([#304](https://github.com/ruby-formatter/rufo/issues/304))
|
28
|
+
- Fix Bug: avoid inserting a unnecessary comma to end of heredoc which in array with method call ([#303](https://github.com/ruby-formatter/rufo/pull/303))
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
### Added
|
33
|
+
|
15
34
|
## [0.16.0] - 2023-04-02
|
16
35
|
|
17
36
|
### Fixed
|
18
37
|
|
19
|
-
- Formats ERB files with configuration (
|
38
|
+
- Formats ERB files with configuration ([#275](https://github.com/ruby-formatter/rufo/issues/275))
|
20
39
|
|
21
40
|
### Changed
|
22
41
|
|
@@ -58,8 +77,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
58
77
|
|
59
78
|
### Added
|
60
79
|
|
61
|
-
- Support for partial argument forwarding. (
|
62
|
-
- Support for endless method. (
|
80
|
+
- Support for partial argument forwarding. ([#268](https://github.com/ruby-formatter/rufo/issues/268))
|
81
|
+
- Support for endless method. ([#271](https://github.com/ruby-formatter/rufo/issues/271))
|
63
82
|
- Add Ruby 3.2.0 to test runs on CI.
|
64
83
|
|
65
84
|
## [0.13.0] - 2021-05-07
|
@@ -84,7 +103,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
84
103
|
- File.read default encode UTF-8
|
85
104
|
- Handle case where the code is invalid but ripper does not raise an error.
|
86
105
|
- Removed implicit dependency on `rake`.
|
87
|
-
- Error when semicolon and then used in a case statement #230.
|
106
|
+
- Error when semicolon and then used in a case statement [#230](https://github.com/ruby-formatter/rufo/issues/230).
|
88
107
|
|
89
108
|
### Changed
|
90
109
|
|
@@ -175,22 +194,22 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
175
194
|
## [0.7.0] - 2019-04-28
|
176
195
|
|
177
196
|
### Fixed
|
178
|
-
- Argument align with splat (
|
197
|
+
- Argument align with splat ([#123](https://github.com/ruby-formatter/rufo/issues/123))
|
179
198
|
|
180
199
|
### Changed
|
181
200
|
|
182
201
|
### Added
|
183
|
-
- Support jbuilder files (
|
202
|
+
- Support jbuilder files ([#173](https://github.com/ruby-formatter/rufo/issues/173))
|
184
203
|
|
185
204
|
## [0.6.1] - 2019-04-27
|
186
205
|
|
187
206
|
### Fixed
|
188
|
-
- Fix bug: symbol literal like `:"foo"` in ruby 2.6.3 (
|
207
|
+
- Fix bug: symbol literal like `:"foo"` in ruby 2.6.3 ([#168](https://github.com/ruby-formatter/rufo/issues/168))
|
189
208
|
|
190
209
|
## [0.6.0] - 2019-03-04
|
191
210
|
|
192
211
|
### Fixed
|
193
|
-
- Fix odd indentation of nested one liner "if" statements (
|
212
|
+
- Fix odd indentation of nested one liner "if" statements ([#128](https://github.com/ruby-formatter/rufo/issues/128))
|
194
213
|
|
195
214
|
### Added
|
196
215
|
- Ignore `vendor` directories from files to be checked. This allows rufo to be run without any arguments against a directory both locally and on common CI tools without needing any configuration.
|
@@ -204,7 +223,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
204
223
|
|
205
224
|
### Fixed
|
206
225
|
|
207
|
-
- Fix bug: Rufo crashes on nested empty hash literal (
|
226
|
+
- Fix bug: Rufo crashes on nested empty hash literal ([#152](https://github.com/ruby-formatter/rufo/issues/152))
|
208
227
|
- Handle case where rufo would change formatting if run multiple times for hashes in some cases.
|
209
228
|
|
210
229
|
## [0.5.0] - 2019-02-09
|
@@ -222,7 +241,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
222
241
|
## [0.4.2] - 2019-01-22
|
223
242
|
|
224
243
|
### Fixed
|
225
|
-
- Fix bug: Rufo indents squiggly HEREDOC incorrectly causing bad formating (
|
244
|
+
- Fix bug: Rufo indents squiggly HEREDOC incorrectly causing bad formating ([#136](https://github.com/ruby-formatter/rufo/issues/136))
|
226
245
|
|
227
246
|
### Added
|
228
247
|
|
@@ -231,14 +250,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
231
250
|
## [0.4.1] - 2018-10-27
|
232
251
|
|
233
252
|
### Fixed
|
234
|
-
- Fix bug for double colon operator in method definition (
|
253
|
+
- Fix bug for double colon operator in method definition ([#120](https://github.com/ruby-formatter/rufo/issues/120))
|
235
254
|
|
236
255
|
## [0.4.0] - 2018-08-09
|
237
256
|
|
238
257
|
### Fixed
|
239
|
-
- Fix Bug: Rufo breaks HEREDOC syntax. (
|
240
|
-
- Fix Bug: formatter.rb:3700:in `block in adjust_other_alignments': undefined method `[]' for nil:NilClass (NoMethodError) (
|
241
|
-
- Fix Bug: Rufo keeps switching formatting on same file every time it runs (
|
258
|
+
- Fix Bug: Rufo breaks HEREDOC syntax. ([#88](https://github.com/ruby-formatter/rufo/issues/88)). This fixes heredoc within parens formatting causing bad formatting and subsequent syntax error.
|
259
|
+
- Fix Bug: formatter.rb:3700:in `block in adjust_other_alignments': undefined method `[]' for nil:NilClass (NoMethodError) ([#87](https://github.com/ruby-formatter/rufo/issues/87)). Check alignment target exists.
|
260
|
+
- Fix Bug: Rufo keeps switching formatting on same file every time it runs ([#86](https://github.com/ruby-formatter/rufo/issues/86)). Avoids re-indenting nested literal indents.
|
242
261
|
|
243
262
|
### Added
|
244
263
|
- Allow for simpler else_body node to suit new Ripper style in 2.6.0
|
@@ -250,7 +269,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
250
269
|
## [0.3.1] - 2018-04-12
|
251
270
|
|
252
271
|
### Fixed
|
253
|
-
- Fix `quote_style` config not being respected (
|
272
|
+
- Fix `quote_style` config not being respected ([#95](https://github.com/ruby-formatter/rufo/issues/95)).
|
254
273
|
|
255
274
|
## [0.3.0] - 2018-03-24
|
256
275
|
|
@@ -259,9 +278,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
259
278
|
- Normalize string quotes according to quote_style, which defaults to :double.
|
260
279
|
|
261
280
|
### Fixed
|
262
|
-
- Fix printing of extraneous trailing semicolons from inline classes, modules, methods (
|
263
|
-
- Fix unhandled white space between array getter/setters `x[0] [0]` (
|
264
|
-
- Fix comma printing for heredocs when inside a hash (
|
281
|
+
- Fix printing of extraneous trailing semicolons from inline classes, modules, methods ([#59](https://github.com/ruby-formatter/rufo/issues/59))
|
282
|
+
- Fix unhandled white space between array getter/setters `x[0] [0]` ([#62](https://github.com/ruby-formatter/rufo/issues/62))
|
283
|
+
- Fix comma printing for heredocs when inside a hash ([#61](https://github.com/ruby-formatter/rufo/issues/61))
|
265
284
|
- Fix array literals against changes to Ruby 2.5.0
|
266
285
|
|
267
286
|
## [0.2.0] - 2017-11-13
|
@@ -302,8 +321,8 @@ The following configuration options have been **removed**, and replaced with non
|
|
302
321
|
|
303
322
|
### Fixed
|
304
323
|
- Fix crash in Ruby <= 2.3.4, <= 2.4.1 in the presence of certain squiggly doc (`<<~`) with multiple embedded expressions. The real fix here is to upgrade Ruby to >= 2.3.5 / >= 2.4.2
|
305
|
-
- Fix dedent bug and bad formatting caused by comments within chained calls (
|
306
|
-
- Fix formatting bug for `for i, in [[1, 2]] ; x ; end` (
|
324
|
+
- Fix dedent bug and bad formatting caused by comments within chained calls ([#49](https://github.com/ruby-formatter/rufo/issues/49))
|
325
|
+
- Fix formatting bug for `for i, in [[1, 2]] ; x ; end` ([#45](https://github.com/ruby-formatter/rufo/issues/45))
|
307
326
|
|
308
327
|
## [0.1.0] - 2017-10-08
|
309
328
|
Beginning of logging changes!
|
data/lib/rufo/erb_formatter.rb
CHANGED
@@ -125,9 +125,16 @@ class Rufo::ErbFormatter
|
|
125
125
|
string
|
126
126
|
end
|
127
127
|
|
128
|
+
CODE_BLOCK_KEYWORDS = %w[BEGIN END begin case class def do else elsif end ensure for if module rescue unless until while]
|
129
|
+
|
130
|
+
def code_block_token?(token)
|
131
|
+
_, kind, value = token
|
132
|
+
kind == :on_kw && CODE_BLOCK_KEYWORDS.include?(value)
|
133
|
+
end
|
134
|
+
|
128
135
|
def determine_code_wrappers(code_str)
|
129
|
-
keywords = Ripper.lex("#{code_str}").filter { |lex_token| lex_token
|
130
|
-
lexical_tokens = keywords.
|
136
|
+
keywords = Ripper.lex("#{code_str}").filter { |lex_token| code_block_token?(lex_token) }
|
137
|
+
lexical_tokens = keywords.map { |lex_token| lex_token[3].to_s }
|
131
138
|
state_tally = lexical_tokens.group_by(&:itself).transform_values(&:count)
|
132
139
|
beg_token = state_tally["BEG"] || state_tally["EXPR_BEG"] || 0
|
133
140
|
end_token = state_tally["END"] || state_tally["EXPR_END"] || 0
|
data/lib/rufo/formatter.rb
CHANGED
@@ -600,8 +600,8 @@ class Rufo::Formatter
|
|
600
600
|
needs_comma = !comma? && trailing_commas
|
601
601
|
|
602
602
|
if inside_literal_elements_list && needs_comma
|
603
|
-
write ","
|
604
603
|
@last_was_heredoc = true
|
604
|
+
@end_of_heredoc_position = @output.length
|
605
605
|
end
|
606
606
|
|
607
607
|
@output << captured_output
|
@@ -2847,7 +2847,13 @@ class Rufo::Formatter
|
|
2847
2847
|
@literal_elements_level = nil
|
2848
2848
|
|
2849
2849
|
if needs_trailing_comma
|
2850
|
-
|
2850
|
+
if !wrote_comma && trailing_commas
|
2851
|
+
if @last_was_heredoc
|
2852
|
+
@output.insert(@end_of_heredoc_position, ",")
|
2853
|
+
else
|
2854
|
+
write ","
|
2855
|
+
end
|
2856
|
+
end
|
2851
2857
|
|
2852
2858
|
consume_end_of_line(first_space: first_space)
|
2853
2859
|
write_indent
|
@@ -3014,7 +3020,18 @@ class Rufo::Formatter
|
|
3014
3020
|
when :when
|
3015
3021
|
visit_comma_separated_list conds_or_pattern
|
3016
3022
|
when :in
|
3023
|
+
parens = current_token_kind == :on_lparen
|
3024
|
+
if parens
|
3025
|
+
consume_token :on_lparen
|
3026
|
+
skip_space_or_newline
|
3027
|
+
end
|
3028
|
+
|
3017
3029
|
visit conds_or_pattern
|
3030
|
+
|
3031
|
+
if parens
|
3032
|
+
skip_space_or_newline
|
3033
|
+
consume_token :on_rparen
|
3034
|
+
end
|
3018
3035
|
end
|
3019
3036
|
skip_space
|
3020
3037
|
end
|
data/lib/rufo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rufo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ary Borenszweig
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -171,7 +171,6 @@ files:
|
|
171
171
|
- README.md
|
172
172
|
- Rakefile
|
173
173
|
- bin/console
|
174
|
-
- bin/runtest
|
175
174
|
- bin/setup
|
176
175
|
- bin/verify-sample-code
|
177
176
|
- docs/developing-rufo.md
|
@@ -211,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
211
210
|
- !ruby/object:Gem::Version
|
212
211
|
version: '0'
|
213
212
|
requirements: []
|
214
|
-
rubygems_version: 3.
|
213
|
+
rubygems_version: 3.5.0.dev
|
215
214
|
signing_key:
|
216
215
|
specification_version: 4
|
217
216
|
summary: Ruby code formatter
|