-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Silence parser warning and patch version mismatch when loading parser…
…/current (#613) * Implement RubyParserFactory to avoid warning when requiring parser/current
- Loading branch information
Showing
4 changed files
with
33 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
# This module provides a factory class for creating a Ruby parser instance. | ||
# It temporarily disables verbose mode to suppress compatibility warnings | ||
# when loading the "parser/current" library. | ||
# | ||
# Example warning for the release of Ruby 3.4.1: | ||
# warning: parser/current is loading parser/ruby34, which recognizes | ||
# 3.4.0-compliant syntax, but you are running 3.4.1. | ||
# Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri. | ||
# | ||
# By disabling verbose mode, these warnings are suppressed to provide a cleaner | ||
# output and avoid confusion. The verbose mode is restored after the parser | ||
# instance is created to maintain the original behavior. | ||
|
||
module I18n::Tasks::Scanners | ||
class RubyParserFactory | ||
def self.create_parser | ||
prev = $VERBOSE | ||
$VERBOSE = nil | ||
require 'parser/current' | ||
::Parser::CurrentRuby.new | ||
ensure | ||
$VERBOSE = prev | ||
end | ||
end | ||
end |