-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
In a non-gem Rails app, all the dependencies are declared in the Gemfile. Nice and tidy.
But in a gem, dependencies nowadays are often declared in 2 different files at the same time: Gemfile for dev dependencies, and my_gem.gemspec for runtime dependencies.
Wouldn't it be nice if all of a gem's dependencies could be declared in the Gemfile? Or is this a crazy idea?
I don't often create new gems but when I do, I wish I could declare all of my dependencies in the Gemfile. Gemfiles are nice. I like them. Declaring dependencies in them feels less clunky than in a gemspec.
Gemfiles can call a gemspec method to add dependencies from the gemspec, among other things.
Conversely, why can't gemspecs call a gemfile (or similar) method to add dependencies from the Gemfile?
It could look something like this:
# my_gem.gemspec
Gem::Specification.new do |spec|
# ...
spec.add_gemfile_dependencies
endor maybe just
Gem::Specification.new do |spec|
# ...
spec.gemfile
endor if you want to include specific Bundler groups:
Gem::Specification.new do |spec|
# ...
spec.add_gemfile_dependencies(:default, :release) # or whatever groups you want
endThis would be optional behavior and wouldn't break anything. Here is a hacky but working proof of concept: gist.
Would anyone find this useful, or is it just me?