jueves, 1 de marzo de 2012

Gemfile.local

Hey guys,

From a while now, I've been looking for a way to add local dependencies to gems within my Rails project, but bundler is not defined to allow that by default :P

For me, as I work on a distributed team, with different operating systems and all, there are times that gems need to be different, one really silly sample is growl (a notification tool that is only available on Mac, but I use Linux so I always have to remove that dependency manually...)

Finally, I reach this post:

http://madebynathan.com/2010/10/19/how-to-use-bundler-with-plugins-extensions/

Which give me a really simple idea to accomplish what I wanted. Basically you can add this to the end of your Gemfile:


Dir.glob(File.join(File.dirname(__FILE__), "Gemfile.local")) do |gemfile|
eval(IO.read(gemfile), binding)
end


And then having Gemfile.local ignored on .gitignore, from there is trivial.

You just need to add any local dependency you need on Gemfile.local.

Hope it is useful for anybody out there ;)