7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/unifig/providers.rb', line 7
def self.list(providers = nil)
return all if providers.nil?
providers.map do |provider|
all
.detect { |pp| pp.name == provider }
.tap do |found|
unless found
msg = %("#{provider}" is not in the list of available providers)
dym = DidYouMean::SpellChecker.new(dictionary: all.map(&:name))
correction = dym.correct(provider).first
msg += "\nDid you mean? #{correction}" if correction
raise MissingProviderError, msg
end
end
end
end
|