If you have multiple projects and want to re-use code between them, extracting the shared code into gems and hosting them on a private gem server is a common pattern.

You goal is to avoid copy-and-pasting the same stuff over and over again. But you also want to make sure all projects are using the same version of a thing. Be that library code, assets, higher level components or tooling configs. A private gem is an easy way to achieve this, while also making your code smaller and easier to understand.

The annoying part

The workflow to keep everything aligned has been a bit annoying so far. Packaging and publishing your private gem is easy enough, but now you want to make sure all projects using that gem are on the latest version. That means updating the gem manually in each project that uses it. In bigger companies you might not even know all users of the gem or you depend on other teams to do the update.

At Depfu we’ve just released support for private package repositories. That means we can now help you to keep your shared code aligned using automation.

Push instead of pull

With Depfu releasing your private gem essentially pushes the update out to all your repos using it.

A pull request that will update your private gem to the just released version will be created on each repo. So instead of pulling the update, we push it out to all your users. And the best part is that you don’t have to do this

git pull
bundle update myprivate_gem
rake test
git commit -m "Update myprivate_gem"
git push

on all your repos and can easily apply the update without ever leaving the GitHub UI. Or leave it to the team working on that project to merge it when it fits into their workflow.

Depfu supports all private registries, be it services like Gemfury and packagecloud or your own self-hosted instance of Geminabox and Gemstash. You’ll just have to supply your credentials like you would need to on your CI service.

We monitor your private registries for new versions and create individual pull requests that include the update. The PR will trigger your CI build and you can quickly see if the new version causes problems in any of the repos.

If you ever had to do the checkout/update/push-dance to update a shared gem in a lot of projects at the same time, you’ll realize how much nicer the push model is. We think this makes it a lot nicer to use private gems.

Why don’t you see for yourself how Depfu can help you? You can try it for 3 weeks on your private repos and it’s free for open source: Keep your private gems aligned.