Ruby Gems Either/Or Dependency?

Posted by Myron on Stack Overflow See other posts from Stack Overflow or by Myron
Published on 2010-04-10T18:54:05Z Indexed on 2010/04/11 14:33 UTC
Read the original article Hit count: 365

Filed under:
|
|

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

I'm working with the auther of WebMock (a library that provides similar functionality to FakeWeb) to get VCR to work with WebMock as well, so that users of VCR could use either FakeWeb or WebMock as the http stubbing library.

When it comes time to release the next version of VCR, I'm not sure of the best way to handle these dependencies. VCR will depend on either WebMock, or FakeWeb (but doesn't need both), and will have certain version requirements for both. I could add both as dependencies to my gemspec, but when you use bundler, it bundles all gem dependencies--so both FakeWeb and Webmock will get bundled with the application.

I've been thinking that maybe I won't declare either gem as a dependency, and check for the presence of either library at run-time (along with checking the version), and give the user a helpful error message if neither is present at a supported version. But I'm not really sure I like this approach either.

Does anyone have a suggestion for the best way to handle an either/or gem dependency?

Thanks!

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rubygems