summaryrefslogtreecommitdiff
path: root/lib/bundler/vendor/thor/lib/thor/error.rb
diff options
context:
space:
mode:
authorHiroshi SHIBATA <hsbt@ruby-lang.org>2019-11-13 07:57:02 +0900
committerSHIBATA Hiroshi <hsbt@ruby-lang.org>2019-11-13 10:19:51 +0900
commitbb9ecd026a6cadd5d0f85ac061649216806ed935 (patch)
tree237975b9702a837fd0a8d24575f1edadb4d773d0 /lib/bundler/vendor/thor/lib/thor/error.rb
parent00d56bdf66a3aeaadbc84196aacbd8d4e698cf79 (diff)
Merge Bundler 2.1.0.pre3 released version
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/2674
Diffstat (limited to 'lib/bundler/vendor/thor/lib/thor/error.rb')
-rw-r--r--lib/bundler/vendor/thor/lib/thor/error.rb32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/bundler/vendor/thor/lib/thor/error.rb b/lib/bundler/vendor/thor/lib/thor/error.rb
index 16c68294e4..1553afd201 100644
--- a/lib/bundler/vendor/thor/lib/thor/error.rb
+++ b/lib/bundler/vendor/thor/lib/thor/error.rb
@@ -1,22 +1,18 @@
class Bundler::Thor
- Correctable =
- begin
- require 'did_you_mean'
-
- # In order to support versions of Ruby that don't have keyword
- # arguments, we need our own spell checker class that doesn't take key
- # words. Even though this code wouldn't be hit because of the check
- # above, it's still necessary because the interpreter would otherwise be
- # unable to parse the file.
- class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
- def initialize(dictionary)
- @dictionary = dictionary
- end
- end
-
- DidYouMean::Correctable
- rescue LoadError, NameError
- end
+ Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable)
+ # In order to support versions of Ruby that don't have keyword
+ # arguments, we need our own spell checker class that doesn't take key
+ # words. Even though this code wouldn't be hit because of the check
+ # above, it's still necessary because the interpreter would otherwise be
+ # unable to parse the file.
+ class NoKwargSpellChecker < DidYouMean::SpellChecker # :nodoc:
+ def initialize(dictionary)
+ @dictionary = dictionary
+ end
+ end
+
+ DidYouMean::Correctable
+ end
# Bundler::Thor::Error is raised when it's caused by wrong usage of thor classes. Those
# errors have their backtrace suppressed and are nicely shown to the user.