GuessMethod 0.0.2
I am pleased to announce the initial release of GuessMethod (as demonstrated earlier here).
GuessMethod is an aggressive spell checker for irb. It is not for production.
Get it:
sudo gem install guessmethod
Its sole requirement is HighLine.
Thanks to Dr. Nic for telling me to release it and for newgem.
Enjoy!
Dr Nic said,
July 23, 2007 @ 12:29 am
require ‘guessmethod’
class Object; include GuessMethod; end
class Foo
def foo
“hi there”
end
end
Fo.nw.fo
attention: replacing non-existant constant Fo with Foo for Object
attention: sending new instead of nw to Foo:Class
attention: sending foo instead of fo to #:Foo
=> “hi there”
Very sexy magic indeed.
Can you add “class Object; include GuessMethod; end” to the bottom of the “guessmethod.rb” file so it does this automatically? If someone’s required the gem, they probably want to do this automatically (read: I do)
Dr Nic said,
July 23, 2007 @ 12:29 am
Oh well, no luck figuring out how to format stuff :)
Niko said,
July 23, 2007 @ 2:14 am
I’ve tried to put “require ‘guessmethod’” into my .irbrc but now it silently stops execution. The require itself and anything after don’t get executed. It works pasting it into the console itself. Any ideas?
Chris Shea said,
July 23, 2007 @ 8:31 am
Dr Nic: Thanks very much. I was a little wary of automatically including GuessMethod into Object, but I couldn’t imagine doing anything less now. Look for 0.0.4, due out today. (edit: out NOW!)
Niko: can you email me your irbrc and tell me more about your environment?
Niko said,
July 23, 2007 @ 12:03 pm
It’s ruby 1.8.6 (locomotive on mac), irb 0.9.5, all gems up to date. My irb.rc:
puts “this”
require ‘guessmethod’
puts “that”
…
“this” gets putsed, “that” doesn’t. If I delete the require everything’s ok. Thanks for the help.
Dr Nic said,
July 23, 2007 @ 12:42 pm
@chris - bug report here - http://drnicwilliams.com/2007/07/23/magic-wiggly-lines-guessmethod-by-chris-shea/#comment-38859
It won’t surprise me if there are lots of “gotchas” with integrating this into different parts of Rails. E.g. ActiveRecord dynamic loading of classes. So much fun to be had :)
Chris Shea said,
July 23, 2007 @ 1:35 pm
Niko: You’ll need to have
require 'rubygems'in your irbrc beforerequire 'guessmethod'. Give that a shot.Dr Nic said,
July 23, 2007 @ 1:49 pm
@niko - ah, sorry; I have
require 'rubygems'in my .irbrc file, so I forget that it is a dependent step.Niko said,
July 24, 2007 @ 12:18 am
Well… what should I say… me stupid :D Thanks for the help!
It works now. Although there seems to be some interference with Hobo (if I start the console of a Hobo project). I get invinite
no constant in threshold: for Rails, sending to Object’s const_missing
messages on startup. No time to figure out what that is atm… I’ll dive into it ASAP.
links for 2007-07-30 « membo said,
July 30, 2007 @ 1:22 am
[…] Ruby, a message to you » GuessMethod 0.0.2 (tags: ruby rails) […]
Back From RailsConf Europe » Viget’s Four Labs said,
September 22, 2007 @ 9:11 pm
[…] techniques in Ruby and demo’ed his Magic Model Generator plugin as well as some controversial uses of […]