Ruby 2.3 and later ships with this gem and it will automatically be require
d when a Ruby process starts up. No special setup is required.
methosd
# => NameError: undefined local variable or method `methosd' for main:Object
# Did you mean? methods
# method
OBject
# => NameError: uninitialized constant OBject
# Did you mean? Object
@full_name = "Yuki Nishijima"
first_name, last_name = full_name.split(" ")
# => NameError: undefined local variable or method `full_name' for main:Object
# Did you mean? @full_name
@@full_name = "Yuki Nishijima"
@@full_anme
# => NameError: uninitialized class variable @@full_anme in Object
# Did you mean? @@full_name
full_name = "Yuki Nishijima"
full_name.starts_with?("Y")
# => NoMethodError: undefined method `starts_with?' for "Yuki Nishijima":String
# Did you mean? start_with?
Aside from the basic features above, the did_you_mean
gem comes with experimental features. They can be enabled by calling require 'did_you_mean/experimental'
.
Keep in mind that these experimental features should never be enabled in production as they would impact Ruby's performance and use some unstable Ruby APIs.
require 'did_you_mean/experimental'
@full_name = "Yuki Nishijima"
@full_anme.split(" ")
# => NoMethodError: undefined method `split' for nil:NilClass
# Did you mean? @full_name
hash = {foo: 1, bar: 2, baz: 3}
hash.fetch(:fooo)
# KeyError: key not found: :fooo
# Did you mean? :foo
require 'did_you_mean/experimental'
class Person
def intialize
...
end
end
# => warning: intialize might be misspelled, perhaps you meant initialize?
This verbose formatter changes the error message format to take more lines/spaces so it'll be slightly easier to read the suggestions. This formatter can totally be used in any environment including production.
OBject
# => NameError: uninitialized constant OBject
# Did you mean? Object
require 'did_you_mean/verbose_formatter'
OBject
# => NameError: uninitialized constant OBject
#
# Did you mean? Object
#
- Fork it (http://github.com/yuki24/did_you_mean/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Make sure all tests pass (
bundle exec rake
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Copyright (c) 2014-16 Yuki Nishijima. See MIT-LICENSE for further details.