rufo 0.18.1 → 0.18.2

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: f4dd74a9e383128ba24cedbdfc7f008332f3a540ab89f9a5ab33be306413269a
4
- data.tar.gz: f725c8a39471a92251294a041a9ae63dcefab5f55614b4ed3215cf11bfb29c4e
3
+ metadata.gz: 87b000f131dd4c6b9e87e82513ed7009a9cbcc7078e44e51627a8b6205f15ea0
4
+ data.tar.gz: 05a5878c0d790d5fb867606b2cc6f064f0789757a9eecb62037e2adb41af249a
5
5
  SHA512:
6
- metadata.gz: a59736abaa4d40516afea2e130c835da5683ac17fbe34f540f64c61ad7a4051c3ba02c05b846b90d97438c6bb0909922261463b3d62003931fde81140ab74295
7
- data.tar.gz: 73bb9af67241c6552de2a3a6610d406c5566c50a5e473b753fbd18741d589a9009f6f2578754220456098f92cc91f4f457a29f3c95e51c89b16c8f5f671312b3
6
+ metadata.gz: 329e2b72b0755c40bb44226722b34199a8907a7911244c330e453d9fe3bc824d45179933d55736162727147068595e8e090f44e1852ad4b5ce0eb794a4dea517
7
+ data.tar.gz: e44a00c12494e7fd015583ed481e97fca7878115942fb4e5cfa5c10a6575ea46d6d1d21f4157871a738e2f2659354f310f0c4772bcd37922eb97dfb796887ae2
data/CHANGELOG.md CHANGED
@@ -12,6 +12,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
12
12
 
13
13
  ### Added
14
14
 
15
+ ## [0.18.2] - 2025-12-24
16
+
17
+ ### Fixed
18
+
19
+ ### Changed
20
+
21
+ ### Added
22
+ - Support formatting ERB native comment. ([#352](https://github.com/ruby-formatter/rufo/pull/352))
23
+
15
24
  ## [0.18.1] - 2025-02-22
16
25
 
17
26
  ### Fixed
data/Gemfile CHANGED
@@ -12,4 +12,4 @@ gem "rspec", "~> 3.0"
12
12
  gem "rspec_junit_formatter", "~> 0.6.0"
13
13
  gem "rubocop", "~> 1.69.2"
14
14
  gem "simplecov", "~> 0.22.0"
15
- gem "simplecov-cobertura", "~> 2.1"
15
+ gem "simplecov-cobertura", "~> 3.1"
@@ -1,17 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
  repos = {
4
- "rspec/rspec-core" => {
5
- "--exclude-pattern" => [
6
- "spec/rspec/core/world_spec.rb",
7
- "spec/rspec/core/formatters/exception_presenter_spec.rb",
8
- "spec/rspec/core/formatters/snippet_extractor_spec.rb",
9
- "spec/rspec/core/metadata_spec.rb",
10
- "spec/rspec/core/formatters/html_formatter_spec.rb",
11
- "spec/rspec/core/formatters/progress_formatter_spec.rb",
12
- "spec/rspec/core/formatters_spec.rb",
13
- "spec/rspec/core/formatters/documentation_formatter_spec.rb",
14
- ].join(","),
4
+ "rspec/rspec" => {
5
+ path: "rspec-core",
6
+ rspec_flags: {
7
+ "--exclude-pattern" => [
8
+ "spec/rspec/core/world_spec.rb",
9
+ "spec/rspec/core/formatters/exception_presenter_spec.rb",
10
+ "spec/rspec/core/formatters/snippet_extractor_spec.rb",
11
+ "spec/rspec/core/metadata_spec.rb",
12
+ "spec/rspec/core/formatters/html_formatter_spec.rb",
13
+ "spec/rspec/core/formatters/progress_formatter_spec.rb",
14
+ "spec/rspec/core/formatters_spec.rb",
15
+ "spec/rspec/core/formatters/documentation_formatter_spec.rb",
16
+ ].join(","),
17
+ },
15
18
  },
16
19
  }
17
20
 
@@ -45,7 +48,7 @@ end
45
48
 
46
49
  def format_repo(repo)
47
50
  run_command(
48
- "bundle exec rake rufo:run sample_code/#{repo}",
51
+ "bundle exec rake rufo:run[sample_code/#{repo}]",
49
52
  allowed_statuses: [0, 1, 3],
50
53
  )
51
54
  end
@@ -54,10 +57,13 @@ def post_format_checks(repo, rspec_flags)
54
57
  run_rspec(repo, rspec_flags)
55
58
  end
56
59
 
57
- repos.each do |repo, rspec_flags|
60
+ repos.each do |repo, options|
61
+ path = "#{repo}/#{options[:path]}"
62
+ rspec_flags = options[:rspec_flags]
63
+
58
64
  clone_repo(repo)
59
- setup_repo(repo)
60
- pre_format_checks(repo, rspec_flags)
61
- format_repo(repo)
62
- post_format_checks(repo, rspec_flags)
65
+ setup_repo(path)
66
+ pre_format_checks(path, rspec_flags)
67
+ format_repo(path)
68
+ post_format_checks(path, rspec_flags)
63
69
  end
@@ -34,7 +34,7 @@ class Rufo::ErbFormatter
34
34
  def format
35
35
  out = []
36
36
  process_erb do |(type, content)|
37
- if type == :code
37
+ if type == :code && !erb_comment?(content)
38
38
  formatted_code = process_code(content)
39
39
  indented_code = formatted_code.lines.join(" " * current_column)
40
40
  out << " #{indented_code} "
@@ -176,4 +176,8 @@ class Rufo::ErbFormatter
176
176
  def disable_code_mode
177
177
  @code_mode = false
178
178
  end
179
+
180
+ def erb_comment?(code)
181
+ code.start_with?("#")
182
+ end
179
183
  end
@@ -243,35 +243,7 @@ class Rufo::Formatter
243
243
  when :string_concat
244
244
  visit_string_concat node
245
245
  when :@tstring_content
246
- # [:@tstring_content, "hello ", [1, 1]]
247
- heredoc, tilde = @current_heredoc
248
- looking_at_newline = current_token_kind == :on_tstring_content && current_token_value == "\n"
249
- if heredoc && tilde && !@last_was_newline && looking_at_newline
250
- check :on_tstring_content
251
- consume_token_value(current_token_value)
252
- next_token
253
- else
254
- # For heredocs with tilde we sometimes need to align the contents
255
- if heredoc && tilde
256
- while (current_token_kind == :on_ignored_sp) ||
257
- (current_token_kind == :on_tstring_content)
258
- if @last_was_newline && current_token_value != "\n"
259
- write_indent(next_indent)
260
- @last_was_newline = false
261
- end
262
- if current_token_kind == :on_ignored_sp
263
- skip_ignored_space
264
- else
265
- consume_token current_token_kind
266
- end
267
- end
268
- else
269
- while (current_token_kind == :on_ignored_sp) ||
270
- (current_token_kind == :on_tstring_content)
271
- consume_token current_token_kind
272
- end
273
- end
274
- end
246
+ visit_at_tstring_content node
275
247
  when :string_content
276
248
  # [:string_content, exp]
277
249
  visit_exps node[1..-1], with_lines: false
@@ -741,6 +713,38 @@ class Rufo::Formatter
741
713
  visit string2
742
714
  end
743
715
 
716
+ def visit_at_tstring_content(_node)
717
+ # [:@tstring_content, "hello ", [1, 1]]
718
+ heredoc, tilde = @current_heredoc
719
+ looking_at_newline = current_token_kind == :on_tstring_content && current_token_value == "\n"
720
+ if heredoc && tilde && !@last_was_newline && looking_at_newline
721
+ check :on_tstring_content
722
+ consume_token_value(current_token_value)
723
+ next_token
724
+ else
725
+ # For heredocs with tilde we sometimes need to align the contents
726
+ if heredoc && tilde
727
+ while (current_token_kind == :on_ignored_sp) ||
728
+ (current_token_kind == :on_tstring_content)
729
+ if @last_was_newline && current_token_value != "\n"
730
+ write_indent(next_indent)
731
+ @last_was_newline = false
732
+ end
733
+ if current_token_kind == :on_ignored_sp
734
+ skip_ignored_space
735
+ else
736
+ consume_token current_token_kind
737
+ end
738
+ end
739
+ else
740
+ while (current_token_kind == :on_ignored_sp) ||
741
+ (current_token_kind == :on_tstring_content)
742
+ consume_token current_token_kind
743
+ end
744
+ end
745
+ end
746
+ end
747
+
744
748
  def visit_string_interpolation(node)
745
749
  # [:string_embexpr, exps]
746
750
  consume_token :on_embexpr_beg
data/lib/rufo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rufo
4
- VERSION = "0.18.1"
4
+ VERSION = "0.18.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rufo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.1
4
+ version: 0.18.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ary Borenszweig
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2025-02-22 00:00:00.000000000 Z
10
+ date: 2025-12-24 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Fast and unobtrusive Ruby code formatter
14
13
  email:
@@ -55,7 +54,6 @@ licenses:
55
54
  - MIT
56
55
  metadata:
57
56
  rubygems_mfa_required: 'true'
58
- post_install_message:
59
57
  rdoc_options: []
60
58
  require_paths:
61
59
  - lib
@@ -70,8 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
68
  - !ruby/object:Gem::Version
71
69
  version: '0'
72
70
  requirements: []
73
- rubygems_version: 3.5.22
74
- signing_key:
71
+ rubygems_version: 3.6.2
75
72
  specification_version: 4
76
73
  summary: Ruby code formatter
77
74
  test_files: []