I need to use two gems in my project that both claim the PDF namespace: pdf-reader and htmldoc.
Is there any way to get them to play nice together? The only way I can think of is to rewrite my own version of htmldoc to give it a different namespace.
There's probably no elegant solution to the problem. If you really need the two gems working side by side I think your best option is to fork one of them (or possibly both) and use your fork. This is how I'd go about it:
.gemspecfile in the root of the repository, the next step will not work otherwise.
Use Bundler to manage your projects dependencies. Instead of specifying the dependency to the library you've modified as
specify it like this:
gem 'the_gem', :git => 'git://github.com/you/the_gem.git'
(but change the URL to the repository to the actual one)
Send an e-mail to the maintainer of the gem you modified and ask him or her to consider merging in your changes in the next release.
Bundler makes it really easy to use alternative versions of gems with minimal hassle. I often fork gems, fix bugs or add features, change my
Gemfile to point to my version, then ask the maintainer to merge in my changes. When, or if, that happens I simply change my
Gemfile back to just refer to the official version of the gem.
An alternative strategy, if the maintainer does not want to merge in your changes and you want to distribute your version to others is to push up your version to Rubygems as a new gem, but in that case prefix the gem name with your name, or some other string that identifies your gem as a variant.