Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a public API for registering an error #123

Merged
merged 2 commits into from
Jul 23, 2019
Merged

Add a public API for registering an error #123

merged 2 commits into from
Jul 23, 2019

Conversation

kddnewton
Copy link
Contributor

Hey there - I was wondering if it might be possible to add a public API in order to register spell checkers. It's a pretty small change, but ergonomically it feels better than merging into a hash. I've added did_you_mean functionality to both thor and rubygems and it would feel better to call a blessed method.

Let me know what you think! Thanks for the great tool!

@yuki24
Copy link
Member

yuki24 commented Jul 22, 2019

Thanks for the PR! I'm very much in favor of adding a concrete interface for registering an error. I thought about the same thing when I was working on another gem called did_you_mean-activerecord that basiaclly does exactly this.

The only tiny thing I have in mind is whether or not the error class should always prepend Correctable. The correct_error method could check it so that it prepends only when necessary. This way the SPELL_CHECKERS constant could be made private and the NoMethodError could be registered the same way other are registered.

Overall this is great and thanks again for your PR!

@kddnewton
Copy link
Contributor Author

Yeah that's a good idea. Just updated the PR.

@yuki24
Copy link
Member

yuki24 commented Jul 23, 2019

Awesome, thanks!

@yuki24 yuki24 merged commit 9d693e9 into ruby:master Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants