Reading the Ruby mailing list

I’m sick of Google groups. I think ruby-forum is okay enough, but I’m sick of the F5 key. I’m not really into using email for mailing lists. I think I need to get over that. Until then…

rf: Ruby Forum (Reader)

One day I’ll have a real solution and I’ll be able to rm rf.

Comments

Writing specs for GuessMethod

I finally got around to writing some specs for GuessMethod. I know the idea is to do that while programming, but I still haven’t quite fully made that part of my habit. This is the sweet spot of the tests so far though:

Cass.nw.clss.should == Clas

Maybe having Clas on the right side of the == is going overboard, but this is what GuessMethod is for: fixing your mistakes so that you don’t have to.

Comments

Playing with Oniguruma

I’ve been busy reading Jeffrey Friedl’s Mastering Regular Expressions and getting a little sad that some of the coolest tricks available are not (yet) available in Ruby. Oniguruma, the regular expression engine coming in Ruby 2.0, is more feature-full and faster than what we have now, and makes whole swaths of Mastering Regular Expressions suddenly relevant. I hear it’s possible to recompile 1.8 to use Oniguruma instead, but I’m not quite ready for that.

I am ready for lookbehind and named captures, though. Thankfully, the Oniguruma gem is available to save me from trying to mess up my Ruby install.

The one unsettling thing about using the Oniguruma gem, though, is how they left String’s match method alone. It’s regexp.match(string) only for these things. Thankfully, that’s easily fixed:

class String

  def o_match(regexp)
    case regexp
    when Oniguruma::ORegexp
      regexp.match(self)
    else
      old_match(regexp)
    end
  end

  alias_method :old_match, :match
  alias_method :match, :o_match

end

Comments

GuessMethod 0.0.5

GuessMethod, the aggressive spell checker for irb, can now be turned off!

Every once in a while, GuessMethod will get in the way. I’m trying to fix that, but in the meantime, you can just set GuessMethod::Options[:active] = false if you need it to leave everything alone for a little while. Just set it back to true when you want it back. This is handy for people (like me, now) who have require 'guessmethod' in their .irbrc (or config/environments/development.rb for Railsers).

And GuessMethod now includes/extends itself in Object when you require it. That happened in 0.0.4.

It’s been interesting to use GuessMethod regularly (especially considering I deemed it a bad idea). Sometimes I see it trying to handle calls I had no idea were being handled by an object’s method_missing.

Give it a shot if you haven’t already:

sudo gem install guessmethod

Comments

GuessMethod 0.0.3

Another release of GuessMethod, the aggressive spell checker for irb!

GuessMethod now handles constants as well, giving you the opportunity for even more non-fatal typos. Prepare for yourself for this magic:

003:0> Strin.tos
attention: replacing non-existant constant Strin with String for Object
attention: sending to_s instead of tos to String:Class
"String"

Enjoy!

Comments