Skip to content

Commit

Permalink
Merge pull request #38 from nebulab/elia/ruby-3-3
Browse files Browse the repository at this point in the history
Use Prism to check code in Ruby 3.3
  • Loading branch information
elia authored Dec 29, 2023
2 parents af92a09 + 17972e1 commit 246816c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
strategy:
matrix:
combo:
- ruby: "3.3"
- ruby: "3.2"
- ruby: "3.1"
- ruby: "3.0"
Expand Down
15 changes: 11 additions & 4 deletions lib/erb/formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ class Error < StandardError; end

SELF_CLOSING_TAG = /\A(area|base|br|col|command|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)\z/i

RUBY_OPEN_BLOCK = ->(code) do
# is nil when the parsing is broken, meaning it's an open expression
Ripper.sexp(code).nil?
end.freeze
begin
require 'prism' # ruby 3.3
RUBY_OPEN_BLOCK = Prism.method(:parse_failure?)
rescue LoadError
require 'ripper'
RUBY_OPEN_BLOCK = ->(code) do
# is nil when the parsing is broken, meaning it's an open expression
Ripper.sexp(code).nil?
end.freeze
end

RUBY_CLOSE_BLOCK = /\Aend\z/
RUBY_REOPEN_BLOCK = /\A(else|elsif\b(.*)|when\b(.*))\z/

Expand Down

0 comments on commit 246816c

Please sign in to comment.