diff options
| author | Austin Pray <austin@austinpray.com> | 2020-08-01 20:30:32 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2025-11-18 10:38:28 +0000 |
| commit | dd6ccb44f0a5207ea5a0308f0917a23f7157dcfe (patch) | |
| tree | bf83d286a3a555c17c8bbbf354c5b880a55e04fb | |
| parent | 6aa16246f78de49df5ebd6dc5ea3a8c26830025a (diff) | |
[ruby/rubygems] Progressively enhance if DidYouMean is available
https://github.com/ruby/rubygems/commit/a02353fb96
| -rw-r--r-- | lib/bundler/cli/common.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bundler/cli/common.rb b/lib/bundler/cli/common.rb index c0eefadf51..b410ba9d26 100644 --- a/lib/bundler/cli/common.rb +++ b/lib/bundler/cli/common.rb @@ -94,11 +94,12 @@ module Bundler end def self.gem_not_found_message(missing_gem_name, alternatives) - require "did_you_mean/spell_checker" message = "Could not find gem '#{missing_gem_name}'." - alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a } - suggestions = DidYouMean::SpellChecker.new(:dictionary => alternate_names).correct(missing_gem_name) - message += "\nDid you mean #{word_list(suggestions)}?" unless suggestions.empty? + if defined?(DidYouMean::SpellChecker) + alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a } + suggestions = DidYouMean::SpellChecker.new(:dictionary => alternate_names).correct(missing_gem_name) + message += "\nDid you mean #{word_list(suggestions)}?" unless suggestions.empty? + end message end |
