Ruby Gems Either or or a dependency?

My VCR gem is currently dependent on FakeWeb . I have it declared as a dependency in my gemspec .

I am working with the author of WebMock (a library that provides similar functionality to FakeWeb) to make the VCR work with WebMock so that VCR users can use FakeWeb or WebMock as their stubbing http library.

When it comes time to release the next version of the VCR, I'm not sure if you can handle these dependencies. The VCR will depend on either WebMock or FakeWeb (but doesn't need both), and they will have specific version requirements for both. I could add both depending on my gemspec, but when you use bundler , it bundles all gem dependencies - so FakeWeb and Webmock will be bundled with the app.

I thought that maybe I would neither declare the gem as a dependency, nor check for the existence of the library at runtime (along with version checking), and give the user a helpful error message if none are present in the supported version. But I'm not sure if I like this approach too.

Does anyone have a suggestion on the best way to handle the dependency / or gem?

Thank!

+2


source to share


1 answer


since it is not possible to declare either / or dependencies, I think not specifying any dependency in your gemspec and checking for any library at runtime is the way to go.



+2


source







All Articles