Skip to content

Commit

Permalink
Merge pull request #640 from quixoten/patch-1
Browse files Browse the repository at this point in the history
Do not require did_you_mean
  • Loading branch information
rafaelfranca committed Nov 15, 2018
2 parents 4344761 + 8c57f1d commit d3762d0
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions lib/thor/error.rb
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
class 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

# 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.
Expand Down

0 comments on commit d3762d0

Please sign in to comment.