If you’re a keen gem developer like myself and you regularly use them in your other applications, you may find it useful to know of this quick tip. It allows you to use local copies of your gems in your apps while still allowing other devs on the project to work without needing to clone the gems for themselves.
I’m currently working on my Seeka gem and I know I’ll be making a number of changes throughout the course of the development of another project. I don’t want to keep pushing new versions to RubyGems and I don’t want to keep pushing code up to GitHub. You might say, that’s easy… just do this:
gem "seeka", :path => "~/Development/gems/seeka"
This is fine if it’s just you working on the project, but a total pain if anyone else works on it with you. It enforces other developers to both clone other repositories and use your chosen directory structure. Not ideal but bundler has a feature just for this purpose.
In your Gemfile, add your gem and specify your remote repository using the git or github option. It doesn’t have to be on GitHub, it may be on the awesome Codebase but you do need to specify the branch name.
gem "seeka", :git => "https://github.com/adamcooke/seeka", :branch => "master"
Finally, you need to tell bundler that it should always use a local version of the repository on your computer. Just run the following:
$ bundle config local.seeka ~/Development/gems/seeka
You can now continue to work on your gem and remote users can still use and work on the application. More information can be found in Bundler’s documentation.