Reputation: 4272
I am writing a gem that can be used with both Sinatra and Rails, however, the gem dependencies are different based on which framework the developer is using the gem on.
If it's a rails app, we need 'sass-rails' and 'coffee-rails' If it's a sinatra app, we need 'sass' and 'coffee-script'
Ideally bundler would just install the necessary gems based on which framework this gem is being loaded into, but I can't seem to figure out how to conditionally specify dependencies.
Any suggestions would be much appreciated.
Upvotes: 2
Views: 713
Reputation: 20868
I would suggest you not to do that. It would be hackish and unreliable.
What you can do however is divide and conquer! Build a generic version of your gem that is framework agnostic and only handles the logic, let's call it yourgem-core
, then you can build two other gems based on that first one, called yourgem-rails
and yourgems-sinatra
.
It's much better, only logic and logic test in yourgem-core
, only rails integration tests in yourgem-rails
, only sinatra integration tests in yourgem-sinatra
Upvotes: 3
Reputation: 1478
You can use :group
option in bundler.
Reference: http://bundler.io/v1.5/groups.html
Upvotes: 0