1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #18395 from shunsukeaida/improve_generator_name_suggestions

Improve generator name suggestions a bit.
This commit is contained in:
Richard Schneeman 2015-02-23 09:48:48 -06:00
commit 98d896e0ae

View file

@ -159,7 +159,7 @@ module Rails
options = sorted_groups.flat_map(&:last)
suggestions = options.sort_by {|suggested| levenshtein_distance(namespace.to_s, suggested) }.first(3)
msg = "Could not find generator '#{namespace}'. "
msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.join(" or ") }\n"
msg << "Maybe you meant #{ suggestions.map {|s| "'#{s}'"}.to_sentence(last_word_connector: " or ") }\n"
msg << "Run `rails generate --help` for more options."
puts msg
end
@ -260,11 +260,9 @@ module Rails
t = str2
n = s.length
m = t.length
max = n/2
return m if (0 == n)
return n if (0 == m)
return n if (n - m).abs > max
d = (0..m).to_a
x = nil