bitfluent

Kamal Fariz Mahyuddin on Ruby, Rails, Git, Chef and other web development geekery.

I'm available for hire for Ruby and Rails development and training, and infrastructure automation with Chef worldwide.

Email me today.

You should follow me on twitter here.
Feb
18th
Mon
permalink

Github, tweaked plugins, and how it changes the dynamics of opensource contribution

As I use various plugins in my Rails apps, I find that I always need to make small tweaks to the plugin or the files it generates. This is why I like to use something like piston or braid to manage the plugins. It allows me to make any change at will and know that it will be part of the app when I deploy, but at the same time keep up with any new upstream changes.

The problem with this is that I can’t easily centralize my hacks so that my other apps can use them. I could host the plugin myself but I want to be tethered to upstream for the occasional update.

I found the solution in Github.

Just today, I cloned the restful_authentication plugin so that I can move out the model authentication concern into lib/authenticated_base.rb. This will leave your User model squeaky clean, like so:

class User < ActiveRecord::Base
  include AuthenticatedBase
end

You can now focus on adding new associations, validations and methods that are unique to your app without being distracted by all the authentication cruft. Credit goes to the caboo.se sample app for exposing me to this organizational technique.

So, what I have now is twofold:

  • a tweaked plugin that others can freely use in their projects
  • an opportunity for the changes to be merged upstream (Github notifies the original creator of the repo, if I’m not mistaken)

This marks a turning point for me in my opensource contribution. The barrier to entry for pushing patches is so low that I expect to see myself cloning a bunch more repos and making my teeny tiny fixes.

You can imagine a future where, for example, the Rails project is on git and that there would be many competing forks, each with their own flavor. Heavy contributors like Pratik Naik and the Russian Mafia could have Lifo Rails and Performance Monster Rails respectively. Suddenly, Rails is no longer just a web framework, it’s a web framework distribution.

Anyway, if you want to get clean:

$ git-submodule add git://github.com/kamal/restful-authentication.git vendor/plugins/restful_authentication

(I’m sure you can use braid, but I’ve never gotten it to work with a git repo)

UPDATE: Cristi Balan, the creator of braid, emailed to let me know mirroring a git repo with braid only works if you have a pretty recent git, above 1.5.4 or so.

Fork me on GitHub