Skip to content

Commit

Permalink
Improve bundled gem warnings
Browse files Browse the repository at this point in the history
Before, when requiring "bigdecimal" in a Bundler context:

> foo.rb:1: warning: bigdecimal which will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.

After:

> foo.rb:1: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems since Ruby 3.4.0. Add bigdecimal to your Gemfile or gemspec.
  • Loading branch information
deivid-rodriguez authored and hsbt committed Dec 8, 2023
1 parent d61af5c commit a530dfe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/bundled_gems.rb
Expand Up @@ -106,17 +106,18 @@ def self.warning?(name, specs: nil)
WARNED[name] = true
if gem == true
gem = name
"#{name} was loaded from the standard library, but"
elsif gem
return if WARNED[gem]
WARNED[gem] = true
"#{name} is found in #{gem}"
"#{name} is found in #{gem}, which"
else
return
end + build_message(gem)
end

def self.build_message(gem)
msg = " which #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."
msg = " #{RUBY_VERSION < SINCE[gem] ? "will no longer be" : "is not"} part of the default gems since Ruby #{SINCE[gem]}."

if defined?(Bundler)
msg += " Add #{gem} to your Gemfile or gemspec."
Expand Down

0 comments on commit a530dfe

Please sign in to comment.