Magic Wiggly Lines => GuessMethod, by Chris Shea
If you ever make time to code just for pleasure, then method_missing and const_missing are just begging for abuse.
Chris Shea has come up with GuessMethod - a very cool hack that now deprecates my concept of Magic Wiggly Lines - a spell-checker for runtime code.
What’s it do? Cop a squiz at this genius…
$ gem install guessmethod -y $ irb > require 'rubygems' > require 'guessmethod' > class Object; include GuessMethod; end # though this could go in the guessmethod.rb file in the gem > class Product; def name; "Some product"; end; end > Prodct.nw.nae attention: replacing non-existant constant Prodct with Product for Object attention: sending new instead of nw to Product:Class attention: sending name instead of nae to #<Product:0x144ff10>:Product => "Some product"
That’s going straight into my .irbrc file. My bad spelling, coupled with my British/Australian English, will never slow me down again!
UPDATE: actually, it doesn’t like being in the .irbrc file for Rails console; so in the config/environments/development.rb files will have to do for the moment.
Trackbacks
Use this link to trackback from your own site.






Ah, great for all those quick, frustrating typo’s I’m making in irb.
Haha
Talk about the principle of least surprise …
All right - awesome.
Be warned, it’s borking Rails’ routing behaviour:
“no constant in threshold: for ArticlesController, sending to Object’s const_missing”
Awesome. I do something very similar in my text-replacement program here:
http://kde-apps.org/content/show.php/Snippits?content=52197
Now, if the text snippit file isn’t found, it simply replaces the input with the first suggestion of the spellcheck. Useful in apps with no spellchecking, or when you *know* you are going to spell that word wrong.
@mlangenberg [via] - Yep. I guess I’m going to have to work a little harder to make sure Rails and co. aren’t getting ruined.
I really would suggest NOT putting it in development.rb, if you must use it
Do you really want to find out you made weird typos in your code, only after it goes live?
@Jerrett [via] - curse you spoiling my fun
[...] Dr Nic ยป Magic Wiggly Lines => GuessMethod, by Chris Shea (tags: rails) [...]
[...] Meta-Magic in Rails: Become a Master Magician Dr. Nic put on a great show explaining Ruby meta-programming, stressing that introspection is the ability to look at your own code, while reflection is the ability to change your on code dynamically. He also compared Perl to a puppy (fun, but with no understanding of itself), Java to Keith Richards (not so cute anymore) and Rails to Neo (knows about and can change his environment). Finally, the good doctor demonstrated a quite useless, though fun, plugin he had created written by Chris Shea; guessmethod, which attempts to catch and correct misspelled contant and method names dynamically. Download notes [...]
[...] Magic Wiggly Lines => GuessMethod, by Chris Shea [...]