I’ve been working on some utilities (not libraries) that I’d like to share. What is the proper way to use rubygems to package them? Are there any best practices?
Specifically, I’d like to know how to deal with the possibility of the user having multiple versions of a dependency. Bundler does an excellent job in a development environment; is there any equivalent for end-user applications? Any way to use the gemspec to automatically require the correct version of all specified gems?
I’m aware of several package-everything-as-executable solutions, but I’d like to avoid them. I think the user should be able to issue gem install my_utility and get the latest version with the correct dependencies and still have a sane environment.
Looks like your biggest question is how to get the correct version of a gem dependency when using a gemspec file, am I right?
Well, here’s an example of the typical gemspec file:
If you wanted to use only the json version 1.5.4, try this sort of thing:
This will only make sure that the specified version is installed already, but to actually make sure you load that in your utility, you can do this: