Skip to content

Commit 3019cb5

Browse files
committed
Fix up keyword argument usage in did_you_mean for ruby 1.8
1 parent 44dfb35 commit 3019cb5

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/thor/error.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@ class Thor
22
Correctable =
33
begin
44
require 'did_you_mean'
5+
6+
module DidYouMean
7+
# In order to support versions of Ruby that don't have keyword
8+
# arguments, we need our own spell checker class that doesn't take key
9+
# words. Even though this code wouldn't be hit because of the check
10+
# above, it's still necessary because the interpreter would otherwise be
11+
# unable to parse the file.
12+
class NoKwargSpellChecker < SpellChecker
13+
def initialize(dictionary)
14+
@dictionary = dictionary
15+
end
16+
end
17+
end
18+
519
DidYouMean::Correctable
620
rescue LoadError
721
end
@@ -29,7 +43,7 @@ def corrections
2943
end
3044

3145
def spell_checker
32-
DidYouMean::SpellChecker.new(dictionary: error.all_commands)
46+
DidYouMean::NoKwargSpellChecker.new(error.all_commands)
3347
end
3448
end
3549

@@ -72,7 +86,7 @@ def corrections
7286

7387
def spell_checker
7488
@spell_checker ||=
75-
DidYouMean::SpellChecker.new(dictionary: error.switches)
89+
DidYouMean::NoKwargSpellChecker.new(error.switches)
7690
end
7791
end
7892

0 commit comments

Comments
 (0)