Subgroups #1863

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
2 participants

This patch adds a new method include_group to the Bundler DSL which allows one group to be included in another. The goal is to be able to group dependencies by their function, and later declare which functional groups should be loaded in which environments (e.g. production, development). It would look something like this simplified example:

# Default group

gem "rails"

# Functional groups

group :pry do
  gem "pry"
  gem "pry-rails"
  gem "pry-nav"
end

group :unit_tests do
  gem "rspec-rails"
  gem "factory_girl"
end

group :integration_tests do
  gem "capybara"
  gem "poltergeist"
end

# Environment groups

group :development do
  include_group :pry
end

group :test do
  include_group :unit_tests
  include_group :integration_tests
end

These composable groups allow for better organization of large Gemfiles.

This is my first foray into the Bundler code, so I'm opening this pull request very early to get feedback on whether or not the Bundler team would be receptive to this feature. If so, I'd like to get some feedback on my approach and what potential complications and edge cases I should consider and test for. The most obvious limitation so far is that subgroups must be defined before they are included in order to have any effect.

Thanks for your time!

This pull request fails (merged 971828dd into 8ef7b59).

Updated the implementation so groups no longer have to be defined before they are included.

I see from the comment above that the build failed, but it doesn't seem to be related to this patch, as builds from other pull requests are failing the same examples.

This pull request fails (merged ebe655f8 into 52abb77).

This pull request passes (merged 09721c7 into c666754).

Here's another approach I'm using now in a project. This uses a separate concept of a real "subgroup" but the implementation is actually much simpler. The advantage is that subgroups are lazily evaluated into real groups, allowing you to compose groups by functionality and install the bundle without groups you don't need in different environments.

https://gist.github.com/ee7bf493b57ffce403b2

@jimmycuadra jimmycuadra deleted the jimmycuadra:subgroups branch Jan 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment