Nikolay Sturm's Blog

Musings about Development and Operations

Ri vs. Bundler

| Comments

Being a long time unix user, I love my command line. When it comes to programming in ruby, I am a big fan of ri to look up documentation and generally figure out how stuff works.

Also, I am a big fan of rvm to organize my ruby projects. With rvm, gems are installed into project specific gemsets. rvm takes care of setting up my environment, so that ri has access to the proper files.

I was quite dumbfounded, when I realized bundler did not only not generate ri-documentation, but that there wasn’t any configuration option to enable it. After more than 2 years, I finally tackled this problem. As often, the solution turned out to be quite simple.

All it takes is a little shell function, that wraps my calls to bundler and generates missing documentation afterwards.

b() {
  bundle $* && gem rdoc --all --ri --no-rdoc 2>&1 | grep --color=auto -v -e '^Gem::SourceIndex' -e '^NOTE: Gem::SourceIndex'
}

So what does this do? First it calls bundle, passing all arguments right through. The usual use case is to install gems, of course. If bundle succeeds, gem rdoc creates all missing ri-documentation. This is actually pretty fast, as usually there’s not much to create. Finally I filter some annoying warning messages.

All it takes is to put this function declaration into one of your shell initialization files (I prefer ~/.bash_aliases), open a new shell and start hacking!

HTH

Comments