Skip to content

Commit

Permalink
support did_you_mean >= v1.2.0 which has a breaking change on formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
gfx committed Mar 20, 2018
1 parent a8ebea2 commit 7c01069
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/rake/task_manager.rb
Expand Up @@ -63,9 +63,16 @@ def generate_message_for_undefined_task(task_name)
message = "Don't know how to build task '#{task_name}' (see --tasks)"

suggestion_message = \
if defined?(::DidYouMean::SpellChecker) && defined?(::DidYouMean::Formatter)
if defined?(::DidYouMean::SpellChecker)
suggestions = ::DidYouMean::SpellChecker.new(dictionary: @tasks.keys).correct(task_name.to_s)
::DidYouMean::Formatter.new(suggestions).to_s
puts "DidYouMean v#{DidYouMean::VERSION}"
if ::DidYouMean.respond_to?(:formatter)# did_you_mean v1.2.0 or later
::DidYouMean.formatter.message_for(suggestions)
elsif defined?(::DidYouMean::Formatter) # before did_you_mean v1.2.0
::DidYouMean::Formatter.new(suggestions).to_s
else
""
end
else
""
end
Expand Down

0 comments on commit 7c01069

Please sign in to comment.